티스토리 뷰
Paper/TTS
[Paper 리뷰] Grad-TTS: A Diffusion Probabilistic Model for Text-to-Speech
feVeRin 2024. 1. 21. 14:31반응형
Grad-TTS: A Diffusion Probabilistic Model for Text-to-Speech
- Denoising diffuion probabilistic model과 generative score matching은 복잡한 data 분포를 모델링하는데 뛰어남
- Grad-TTS
- Encoder에 의해 예측된 noise를 점진적으로 변환하고 Monotonic Alignment Search를 통해 text input에 맞춰 정렬된 mel-spectrogram을 생성
- Stochastic differential equation을 통해 noise로부터 data를 reconstruct
- 논문 (ICML 2021) : Paper Link
1. Introduction
- Text-to-Speech (TTS) 모델은 two-stage 방식으로 설계되는 경우가 많음
- Feature Generator : input text를 time-frequency domain acoustic feature로 변환
- Feature generator로써 Tacotron2, Transformer-TTS가 우수한 성능을 보였지만 상당히 계산 비효율적임
- FastSpeech의 경우 non-autoregressive architecture를 활용하고 monotonic alignment를 적용하여 pronunciation robstness를 향상 가능
- BUT, character duration을 학습하기 위해 teacher model의 pre-computed alignment를 필요로 함 - Vocoder : Conditioned feature로부터 raw waveform을 합성
- 고품질 음성을 합성에서도 parallel non-autoregressive vocoder들이 주로 활용됨
- WaveGlow는 Normalizing Flow를 활용하여 빠른 합성 속도를 달성했지만, GPU와 같은 특정 device에서만 가능함
- HiFi-GAN, Mel-GAN과 같이 Generative Adversarial Network (GAN)을 활용하는 방식들도 있음
- Feature Generator : input text를 time-frequency domain acoustic feature로 변환
- Normalizing Flow를 활용한 Glow-TTS는 pronunciation 문제와 latency 문제를 해결할 수 있음
- Glow-TTS는 input text를 mel-spectrogram에 mapping 하기 위해 Monotonic Alignment Search (MAS)를 도입
- MAS를 통해 Tacotron2와 같은 autoregressive 방식의 pronunciation 문제를 해결
- 추가적으로 Glow-TTS는 병렬 합성을 가능하게 하여 빠른 추론 속도를 달성했음 - 특히 Glow-TTS는 FastSpeech와 달리 MAS가 unsupervised 방식으로 동작하여 token duration에 대한 external aligner를 필요로 하지 않음
- Glow-TTS는 input text를 mel-spectrogram에 mapping 하기 위해 Monotonic Alignment Search (MAS)를 도입
- 최근에는 Diffusion Proobabilistic Model (DPM)의 등장으로 복잡한 data를 효과적으로 모델링할 수 있게 됨
- DPM의 기본 idea:
1. Simple 분포(일반적으로 표준 정규 분포)를 얻을 때까지 original data를 반복적으로 변환하는 forward diffusion process를 구축하고
2. Reverse-time forward diffusion trajectory를 따르도록 parameterize 된 neural network를 구축 - 추론 시에는 numerical differential equation solver를 기반으로 활용
- 이를 활용하여 WaveGrad와 DiffWave는 vocoder 작업에서 유망한 raw waveform reconstruction 성능을 보임
-> BUT, feature generator 측면에서는 DPM을 활용한 방식들이 아직 제시되지 않음
- DPM의 기본 idea:
-> 그래서 diffusion probabilistic modelling을 활용하는 acoustic feature generator인 Grad-TTS를 제안
- Grad-TTS
- MAS-aligned encoder output을 decoder로 전달되어 Gaussian noise를 mel-spectrogram으로 변환
- Gaussian noise로부터 data를 reconstruct 하기 위해 forward/reverse diffusion에 대한 generalized version을 활용
- 특히 Grad-TTS는 output mel-spectrogram 품질과 추론 속도 간의 trade-off를 명시적으로 제어 가능
< Overall of Grad-TTS >
- Encoder에 의해 예측된 noise를 점진적으로 변환하고 Monotonic Alignment Search를 통해 text input에 맞춰 정렬된 mel-spectrogram을 생성
- 결과적으로 10번의 reverse diffusion 만으로도 고품질의 mel-spectrogram을 생성 가능하고, 추론 속도 측면에서 Tacotron2 보다 빠른 속도를 보임
2. Diffusion Probabilistic Modelling
- Diffusion process는 Stochastic Differential Equation (SDE)를 만족하는 stochastic process라고 할 수 있음:
(Eq. 1)dXt=b(Xt,t)dt+a(Xt,t)dWt
- : standard Brownian motion, 유한 시간 범위Wt 내에서T t∈[0,T]
- : 각각 drift, diffusion coefficientb,a - 임의의 inital data 분포
에 대해Law(X0) 일 때 최종적인 분포T→∞ 가 standard NormalLaw(XT) 로 수렴하는 forward process를 고려할 수 있음N(0,I) :I identity matrix,n×n : data dimensionalityn - 이러한 특성을 가지는 모든 diffusion process를 forward process라고 하고, diffusion probabilistic modelling의 목표는 trajectory가 forward process와 비슷하지만 time order는 반대인 reverse diffusion을 찾는 것
- Reverse diffusion은 forward diffusion보다 어렵지만, 적절한 neural network를 사용하여 reverse diffusion을 parameterize 하는 것으로 해결할 수 있음
- 이를 위해 일반적으로 에서 random noise를 sampling 한 다음, first-order Euler-Maruyama scheme과 같은 numerical solver를 사용함N(0,I) - Forward와 reverse diffusion process의 trajectory가 가까운 경우, sample 분포는 data
의 분포와 매우 유사함Law(X0)
- Score-based / Denoising diffusion probabilistic model은 주로 Markov chain으로 formalize 됨
- BUT, Markov chain은 특정 SDE를 만족하는 stochastic process의 trajectory에 근사될 수 있다는 것이 입증됨
- 따라서 Grad-TTS는 Markov chain을 사용하지 않고 SDE 측면에서 diffusion probabilistic model (DPM)을 정의
- Infinite time horizon에 대해 forward diffusion이 모든 data 분포를 대신, 주어진 평균N(0,I) 와 diagonal covariance matrixμ 에 대한Σ 로 변환하는 방식으로 DPM을 generalizeN(μ,Σ)

- Forward Diffusion
- 먼저 Infinite time horizon
가 주어졌을 때, data를 Gaussian noise로 변환하는 forward diffusion process를 정의하자.T -dimensional stochsatic processn 가 다음의 SDE를 만족한다면:Xt
(Eq. 2)dXt=12Σ−1(μ−Xt)βtdt+√βtdWt,t∈[0,T] - Non-negative function
(noise schedule)에 대해, vectorβt 와 positive element를 가지는 diagonal matrixμ 에 대한 solution은:Σ
(Eq. 3)Xt=(I−e−12Σ−1∫t0βsds)μ+e−12Σ−1∫t0βsdsX0+∫t0√βse−12Σ−1βududWs - 이때 diagonal matrix의 exponential은 element-wise exponential이므로,
(Eq. 4)ρ(X0,Σ,μ,t)=(I−e−12Σ−1∫t0βsds)μ+e−12Σ−1∫t0βsdsX0
(Eq. 5)λ(Σ,t)=Σ(I−e−Σ−1∫t0βsds) 가 주어졌을 때,X0 의 integral condition 분포는 Ito's property에 의해 Gaussian임:Xt
(Eq. 6)Law(Xt|X0)=N(ρ(X0,Σ,μ,t),λ(Σ,t)) - 이는 infinite time horizon을 고려했을 때, 어떠한 noise schedule
에 대해서도βt 이라는 것을 의미하므로:lim
(Eq. 7)
- 위에 따라 random variable
는 와 독립적으로 로 수렴함
- 결과적으로 (Eq. 2)를 만족하는 forward diffusion은 data 분포 를 Gaussian noise 로 변환된다는 property를 얻음
- Reverse Diffusion
- DPM의 reverse diffusion은 reverse-time dynamics에 대한 명시적인 formula로써
- 아래의 SDE로 표현될 수 있음:
(Eq. 8)
- : reverse-time Brownian motion
- : random variable 의 probability density function
- 위의 SDE는 terminal condition 에서 시작하여 backward 방향으로 solve 됨 - 이때 (Eq. 8) 대신 Ordinary Differential Equation (ODE)를 고려할 수 있음
(Eq. 9)
- 이때 (Eq. 2)와 (Eq. 9)에 해당하는 Kolmogorov equation은 동일하므로, (Eq. 2)와 (Eq. 9)를 따르는 stochastic process에서의 probability density function의 변화는 동일 - 결과적으로 noisy data의 log-density gradient
를 추정하는 neural network 가 있는 경우,
- 에서 를 sampling 하고,
- (Eq. 8) 또는 (Eq. 9)를 backward solve 하여 data 분포 를 모델링 가능
- 아래의 SDE로 표현될 수 있음:
- Loss Function
- Noisy data
에서 log-density gradient를 추정하는 것을 score matching이라고 함- 일반적으로
loss를 사용하여 gradient를 근사 - (Eq. 6)으로 인해 intermediate value
를 sampling 하지 않고도 initial data 만 주어지면 noisy data 를 생성할 수 있음
- 이때 는 Gaussian이므로 log-density는 단순한 closed form을 가짐 에서 를 sampling 하고 (Eq. 6)에 넣으면:
(Eq. 10)- 이때
에서의 log-density gradient는:
(Eq. 11)
- : conditional 분포 (Eq. 6)의 probability density function - 결과적으로 time
동안 누적된 noise로 corrupte 된 data 의 log-density gradient를 추정하는 것에 대한 loss function은:
(Eq. 12)
- : 에서 sampling 되고, 는 (Eq. 10)에 따라 계산됨
- 일반적으로
3. Grad-TTS
- 제안하는 feature generator인 Grad-TTS는 encoder, duration predictor, decoder의 3가지 module로 구성됨

- Inference
- Grad-TTS는 length
을 가지는 input text sequence 로부터 mel-spectrogram 를 생성하는 것을 목표로 함 ( : frame 수)- Encoder는,
- Input text sequenc 을 duration predictor가 사용하는 feature sequence 로 변환하여
- Encoded text sequence 와 frame-wise feature 사이의 hard monotonic alignment 를 생성
- 이때 function 는 과 사이의 monotonic surjective mapping으로, 임의의 integer 에 대해 - Duration predictor는
- Text input의 각 element가 지속되는 frame 수를 알려주는 역할
- 의 monotonicity와 surjectiveness는 text input을 skipping 하지 않고 correct order로 pronounce 되는 것을 보장함
- 이때 예측된 duration에 대해 몇 가지 factor를 곱하여 합성된 음성의 tempo를 제어하는 것이 가능함
- Encoder는,
- Output sequence
는 decoder로 전달됨- Decoder는 Diffusion Probabilistic Model로써
- 이때 parameter 가 있는 neural network 는 아래의 Ordinary Differential Equation (ODE)를 정의:
(Eq. 13)
- 이후 위 식을 first-order Euler scheme을 통해 time에 따라 backward로 solve - Sequence
는 terminal condition 를 정의하는 데 사용됨
- Noise schedule 와 time horizon 는 data에 따라 달라지는 hyperparameter
- Euler scheme의 step size 는 Grad-TTS가 학습된 이후에 선택할 수 있는 hyperparameter로 합성 품질과 추론 속도의 trade-off를 조절
- Decoder는 Diffusion Probabilistic Model로써
- Grad-TTS의 reverse diffusion은 (Eq. 13)을 통해 전개됨
- (Eq. 8)보다 (Eq. 9)를 사용할 때 더 나은 결과를 얻을 수 있기 때문
- Step size 가 작을 때는 비슷한 결과를 보이지만, 큰 size에 대해서는 (Eq. 9)가 더 나은 합성 품질을 보였음 - Feature generation pipeline을 단순화하기 위해
를 사용 - Neural network
에 대한 additional input으로 를 활용
- (Eq. 11)에서 neural network 는 noisy data 만을 사용하여 에 추가된 Gaussian noise를 예측함
- 따라서 매 time 마다 limiting noise 에 대한 additional knowledge를 에 제공하면 network는 time 에서 더 정확하게 noise를 예측할 수 있음
- (Eq. 8)보다 (Eq. 9)를 사용할 때 더 나은 결과를 얻을 수 있기 때문
- 추가적으로 Grad-TTS는 temperature hyperparameter
를 도입-
대신 에서 terminal condition 를 sampling하는 것이 성능 향상에 유리 를 조절함으로써 큰 step size 를 사용할 때 output mel-spectrogram의 품질을 유지할 수 있음
-
- Training
- Grad-TTS의 training objective는 aligned encoder output
와 target mel-spectrogram 사이의 거리를 최소화하는 것- 위에서 설명한 Grad-TTS의 추론이 random noise
에서 decoding이 시작되기 때문
- 만약 target 에 가까운 noise에서 시작한다면 더 쉬운 decoding이 가능함 - Aligned encoder output
가 decoder의 시작 noise를 parameterize 한다고 하면 encoder output 를 Normal 분포 로 고려할 수 있고,
- 이때 negative log-likelihood encoder loss는:
(Eq. 14)
- : 의 probability density function
- Encoder loss 없이 학습시키는 것도 가능하지만, 이 경우 alignment를 학습하지 못하는 것으로 관찰됨 - Encoder loss
는 encoder parameter와 alignment function 모두에 대해 최적화되어야 함
- 이때 joint optimization을 수행하는 것은 어렵기 때문에, iterative approach를 활용
- Fixed encoder parameter가 주어지면 최적의 alignment
를 search
- 이를 위해 Monotonic Alignment Search (MAS)를 도입
- MAS는 loss function 의 관점에서 dynamic programming을 통해 monotonic surjective alignment를 찾음 - Alignment
를 fix 하고 stochastic gradient descent를 수행해 encoder parameter에 대한 loss function을 최적화
- Fixed encoder parameter가 주어지면 최적의 alignment
- 위에서 설명한 Grad-TTS의 추론이 random noise
- 추론 시 최적의 alignment
를 추정하기 위해, Grad-TTS는 duration predictor network를 활용- Duration predictor
는 log-domain에서 Mean Squared Error (MSE)를 통해 학습됨:
(Eq. 15)
- : indicator function
- ,
- : 가 encoder parameter에 영향을 주지 않도록 하는 stop gradient - DPM과 관련된 loss 계산 시, Grad-TTS는
로 사용하므로 (Eq. 6)에 따른 noisy data의 분포를 단순화할 수 있고, covariance matrix는 scalar를 곱한 identity matrix 가 됨:
(Eq. 16)
- Duration predictor
- 최종적인 diffusion loss function
는,- 서로 다른 time
에서 noisy data의 log-density gradient를 추정하는 weighted loss에 대한 기댓값
(Eq. 17)
- : training data에서 sampling 된 target mel-spectrogram
- 는 uniform 분포 에서 sampling 됨 는 및 (Eq. 6)에 따라 noisy data 를 얻는 데 사용되는 아래 식으로 sampling 됨:
(Eq. 18)- (Eq. 17)과 (Eq. 18)에서
로 치환하면 (Eq. 12)와 (Eq. 10)을 따름
- 이때 (Eq. 12)에 대해 에 비례하는 weight 를 적용
- 서로 다른 time
- 결론적으로 training procedure는 아래와 같이 진행됨
- Encoder, duration predictor, decoder의 parameter를 fix 하고, MAS를 통해
를 최소화하는 alignment 를 search - Alignment
를 fix하고, encoder, duration predictor, decoder의 parameter에 대해 를 최소화 - 위 과정을 수렴할 때까지 반복
- Encoder, duration predictor, decoder의 parameter를 fix 하고, MAS를 통해
- Model Architecture
- Encoder와 Duration predictor는 Glow-TTS와 동일한 architecture를 사용
- Duration predictor는 2개의 convolution layer와 log duration을 예측한 projection layer로 구성됨
- Encoder는 pre-net, 6개의 transformer block, linear projection layer로 구성됨
- Pre-net은 3개의 convolution layer와 fully-connected layer로 구성됨
- Decoder network
는 U-Net architecture를 활용- 이때 model size를 줄이기 위해 2배 더 적은 channel과 3개의 feature map resolution을 활용
- 80-dimensional mel-spectrogram을 사용한다고 했을 때,
는 , , resolution에서 동작
- Frame 수 가 4의 배수가 아닌 경우, mel-spectrogram을 zero-padding
- Aligned encoder output 는 U-Net input 와 concatenate 됨

4. Experiments
- Settings
- Dataset : LJSpeech
- Comparisons : FastSpeech, Glow-TTS, Tacotron2
- Result
- Subjective Evaluation
- MOS 측면에서 합성 품질을 비교해 보면, reverse diffusion을 많이 반복할수록 Grad-TTS의 합성 품질이 좋아짐
- 대신 특정 반복 이상부터는 품질 향상이 미미함 - FastSpeech 등의 다른 모델들과 비교했을 때도 Grad-TTS가 가장 우수한 품질을 달성
- MOS 측면에서 합성 품질을 비교해 보면, reverse diffusion을 많이 반복할수록 Grad-TTS의 합성 품질이 좋아짐
- Objective Evaluation
- Grad-TTS는 Glow-TTS 보다 더 나은 log-likelihood를 보임
- 특히 parameter 측면에서 Grad-TTS는 Glow-TTS 보다 3배 더 적은 decoder만으로도 더 우수한 성능을 달성

- Generalized DPM framework의 효과를 확인하기 위해
대신 에서의 mel-spectrogram reconstruction을 비교 에서 모델을 10, 20, 50번 반복하는 것보다 를 사용하는 기존의 Grad-TTS가 더 선호되는 것으로 나타남 에서 reconstruction을 수행할 때, 기존 Grad-TTS 보다 더 많은 ODE-solver step이 필요하다는 것을 의미

- 각 TTS 모델에서 발생하는 error의 종류에 대한 테스트를 수행
- Glow-TTS의 경우 단어를 잘못된 방식으로 stress 하는 경우와 robotic 한 음성을 생성하는 경우가 많은 것으로 나타남
- 그에 비해 Grad-TTS는 Glow-TTS, Tacotron2 보다 더 적은 error를 발생시킴

- Efficiency Estimation
- Grad-TTS는 decoder step이 100 이하인 경우 0.37보다 작은 RTF를 달성 가능
- 추론 속도 측면에서는 Glow-TTS, FastSpeech2보다 다소 느리지만 Tacotron2보다는 빠른 속도를 보임
- 특히 Grad-TTS는 약 15M의 parameter를 가지므로 model size 측면에서는 가장 효율적임

반응형