티스토리 뷰
Paper/TTS
[Paper 리뷰] StyleTTS2: Towards Human-Level Text-to-Speech through Style Diffusion and Adversarial Training with Large Speech Language Models
feVeRin 2024. 3. 17. 13:45반응형
StyleTTS2: Towards Human-Level Text-to-Speech through Style Diffusion and Adversarial Training with Large Speech Language Models
- Human-level text-to-speech를 위해 large speech language model (SLM)을 활용할 수 있음
- StyleTTS2
- Diffusion model을 통해 style을 latent random variable로 모델링하여 reference speech 없이 text에 적합한 style을 생성
- End-to-End training을 위해 differentiable duration modeling이 가능한 discriminator를 도입하고 large pre-trained SLM을 사용하여 naturalness를 향상
- 논문 (NeurIPS 2024) : Paper Link
1. Introduction
- Text-to-Speech (TTS)는 더 expressive 한 합성을 위해 발전하고 있지만, 아직 human-level TTS 까지는 한계가 있음
- Diverse하고 expressive한 speech, Out-of-Domain (OOD) text에 대한 robustness가 여전히 부족하기 때문
- 특히 고성능의 zero-shot TTS를 위해서는 대규모의 dataset이 필요함
-> 그래서 human-level TTS를 위해 style-based generative model인 StyleTTS2를 제안
- StyleTTS2
- Speech style을 latent random variable로 모델링하고, stochastic diffusion model을 통해 sampling
- 이를 통해 model이 reference audio 없이도 realistic 한 음성을 합성할 수 있도록 함 - 이때 entire speech를 latent variable로 사용하지 않고 style vector만 sampling 하면 되기 때문에, StyleTTS2는 다른 diffusion TTS model 보다 더 빠르고 효율적인 합성이 가능함
- 특히 StyleTTS2는 HuBERT, WavLM과 같은 large pre-trained speech language model (SLM)을 differentiable duration modeling과 함께 discriminator로써 사용함
- 이러한 end-to-end (E2E) training을 통해 SLM의 knowledge를 transferring 하고, SLM representation을 통해 naturalness를 향상함
- Speech style을 latent random variable로 모델링하고, stochastic diffusion model을 통해 sampling
< Overall of StyleTTS2 >
- Diffusion model을 통해 style을 latent random variable로 모델링하여 reference speech 없이 text에 적합한 style을 생성
- End-to-End training을 위해 large pre-trained SLM과 differentiable duration modeling을 사용하는 discriminator를 도입해 naturalness를 향상
- 결과적으로 우수한 합성 품질과 zero-shot TTS 성능을 보임
2. Method
- StyleTTS Overview
- StyleTTS는 style encoder를 사용하여 reference audio에서 style vector를 파생하는 non-autoregressive TTS model
- Style vector는 Adaptive Instance Normalization (AdaIN)을 사용하여 decoder, duration/prosody predictor에 incorporate 됨
- 이를 통해 다양한 duration, prosody, emotion을 가진 음성을 생성함 - 모델은 크게 3가지 category로 나눌 수 있음
- Speech generation system (Acoustic module) : Text encoder, Style encoder, Speech decoder를 포함
- TTS prediction system : Duration/Prosody predictor를 포함
- Training을 위한 utility system : Discriminator, Text aligner, Pitch extractor를 포함
- Style vector는 Adaptive Instance Normalization (AdaIN)을 사용하여 decoder, duration/prosody predictor에 incorporate 됨
- 이때 StyleTTS는 two-stage training process를 활용
- First Stage : 먼저 mel-spectrogram reconstruction을 위한 acoustic module을 training
- Text encoder
는 input phonemeT 를 phoneme representationt 로 encodinghtext=T(t) - Text aligner
는 input speechA 와 phonemex 에서 speech-phoneme alignmentt 를 추출하여 dot product를 통해 얻어지는 aligned phoneme representationaalgn=A(x,t) 을 생성halgn=htext⋅aalgn - Style encooder
는 style vectorE 를 얻고, Pitch extractors=E(x) 는 energyF 와 함께 pitch curvenx=||x|| 를 추출함px=F(x) - Speech decoder
는G 를 reconstruct 함ˆx=G(halgn,s,px,nx)
- 이때 reconstruction lossL1 과 adversarial objectiveLmel 을 DiscriminatorLadv,Lfm 와 함께 사용하여 inputD 와 match 되도록 training 됨x
- 추가적으로 optimal alignment를 학습하기 위해 Transferable Monotonic Aligner (TMA) objective도 적용됨
- Text encoder
- Second Stage : 앞서 training 된 fixed acoustic module을 사용하여 TTS predictor module을 학습함
- Discriminator
를 제외한 모든 component를 fix 하고 duration/prosdy predictor만 training 함D - Duration predictor
는S 로 phoneme duration을 예측하고, Prosody predictordpred=S(htext,s) 는P 로 pitch와 energy를 예측함ˆpx,ˆnx=P(htext,s)
- Duration predictor는 lossL1 를 갖는 time axis를 따라 alignmentLdur 의 summed monotonic version으로부터 얻어진 ground-truth durationaalgn 와 예측된 duration이 match 되도록 학습됨dgt
- Prosody predictor는 lossL1 을 사용하여 pitch extractorLf0,Ln 에서 파생된 ground-truth pitchF , energypx 와 예측된 pitch, energynx 가 match 되도록 학습됨ˆpx,ˆnx - 추론 시
는,dpred 에서ℓi−1 에 대해 value 1을 repeating 하여 얻은 predicted alignmentdpred[i] 를 사용하여apred 를 upsampling 함htext
- :ℓi 에 대해k∈{1,...,i} 를 summing 하여 계산된dpred[k] -th phonemei 의 end positionti
- :dpred[i] 의 predicted durationti - Mel-spectrogram은
의 style에 영향을 미치는 arbitrary reference audioxpred 를 반영하여˜x 으로 합성되고, pre-trained vocoder를 사용하여 waveform으로 변환됨xpred=G(htext⋅apred,E(˜x),ˆp˜x,ˆn˜x)
- Discriminator
- First Stage : 먼저 mel-spectrogram reconstruction을 위한 acoustic module을 training
- StyleTTS2
- StyleTTS2는 StyleTTS를 개선하여 human-level quality와 out-of-distribution 성능을 갖춘 expressive TTS 모델을 제공함
- 이를 위해 differentiable duration modeling을 통해 제공되는 large speech language model (SLM)을 사용한 adversarial training을 통해 모든 component를 jointly optimize 하는 end-to-end training process를 도입
- 이때 speech style은 diffusion model을 통해 sampling 된 latent variable로 모델링 되므로 reference audio 없이도 다양한 음성 생성이 가능
- End-to-End Training
- End-to-End (E2E) training은 mel-spectrogram을 waveform으로 변환하는 vocoder와 같은 fixed component에 의존하지 않고 전체 TTS system을 최적화하는 방식
- 이를 위해 StyleTTS2는 style vector, aligned phoneme representation, pitch/energy curve로부터 waveform을 직접 생성할 수 있도록 decoder
를 수정G
- 따라서 mel-spectrogram projection layer를 제거하고 waveform decoder를 추가함 - 이때 decoder로써 HiFi-GAN-based, iSTFTNet-based 두 가지 방식을 활용할 수 있음
- HiFi-GAN은 waveform을 직접 생성할 수 있고, iSTFTNet은 inverse STFT를 사용하여 magnitude와 phase를 생성해 더 빠른 추론이 가능함
- 다음으로 waveform 생성에 효과적인 snake activation function을 도입하고, AdaIN module은 기존의 StyleTTS decoder와 유사하게 각 activation function 다음에 추가됨
- 결과적으로 mel-discriminator를 LSGAN loss와 함께 Multi-Period Discriminator (MPD), Multi-Resolution Discriminator (MRD)로 대체하고, 음질을 향상하기 위해 truncated pointwise relative loss function을 도입
- 이때 well-trained acoustic module은 TTS prediction module의 training process를 가속화할 수 있음
- 따라서 모든 component를 jointly optimize 하기 이전에, epoch에 대한N 과 TMA objective를 통해 pitch extractor, text aligner와 함께 acoustic module을 pre-training 함Lmel,Ladv,Lfm
- 이때 은 training set size에 따라 결정됨N - Acoustic module에 대한 pre-training 이후
을 jointly optimize 함Lmel,Ladv,Lfm,Ldur,Lf0,Ln - 여기서
은 예측된 pitchLmel , energyˆpx 에서 reconstruction 된 waveform의 mel-spectrogram과 match 되도록 modify 됨ˆnx - Joint training 중에는 style encoder가 acoustic, prosodic information 모두를 encoding 해야 하므로 diverging gradient로 인해 stability issue가 발생함
- 이를 해결하기 위해, 기존 acoustic style encoder 와 prosody style encoderEa 를 활용Ep - 이때
대신 predictorsa=Ea(x) 는S,P 를 input style vector로 사용하고, style diffusion model은 augmented style vectorsp=Ep(x) 를 생성s=[sp,sa]
- 결과적으로 해당 modification을 통해 sample 품질이 향상됨
- 여기서
- 추가적으로 acoustic module과 predictor를 decouple 하기 위해,
- 기존 acoustic text encoder
의 phoneme representationT 를 prosodic text encoder인 BERT transformer를 기반으로 하는 text encoderhtext 의B 로 대체함hbert - Prosodic text encoder로써 Wikipedia article로 pre-train 된 phoneme-level BERT를 사용함
- 이를 통해 StyleTTS의 naturalness를 향상 가능
- 기존 acoustic text encoder
- StyleTTS2는 differentiable upsampling과 fast style diffusion을 통해, training 중에 fully differentiable 하게 음성 sample을 생성할 수 있음
- 해당 sample은 joint training 중에 parameter를 업데이트하기 위해 을 최적화하는데 사용됨Lslm
- Style Diffusion
- StyleTTS2는 분포
를 따르는 latent variablep(s|t) 를 통해 음성s 를 conditional 분포x 로써 모델링함p(x|t)=∫p(x|t,s)p(s|t)ds
- 여기서 latent variable 를 prosody, lexical stress 등을 나타내는 generalized speech style이라고 함s - 따라서 combined probability flow와 time-varying Langevin dynamics를 따르는 EDM으로
를 sampling 할 수 있음:s
(Eq. 1)s=∫−σ(τ)[β(τ)σ(τ)+˙σ(τ)]∇slogpτ(s|t)dτ+∫√2β(τ)σ(τ)d˜Wτ
- : noise level schedule,σ(τ) : time derivative,˙σ(τ) : stochasticity termβ(τ)
- :˜Wτ 에서 backward Wiener process,τ∈[T,0] : time∇slogpτ(s|t) 에서의 score functionτ - 이때 아래와 같이 pre-condition 된 denoiser
를 사용하는 EDM formulation을 활용:K(s;t,σ)
(Eq. 2)K(s;t,σ):=(σdataσ∗)2s+σ⋅σdataσ∗⋅V(sσ∗;t,14lnσ)
- :σ 인 log-normal 분포Pmean=−1.2,Pstd=1.2 lnσ∼N(Pmean,P2std)
- : scaling term,σ∗:=√σ2+σ2data 는 style vector standard deviation에 대한 경험적 추정치σdata=0.2 - 여기서
는 아래와 같이 training 된V 에 대해 condition 된 3-layer transfromer:t,σ
(Eq. 3)Ledm=Ex,t,σ,ξ∼N(0,I)[λ(σ)||K(E(x)+σξ;t,σ)−E(x)||22]
- : weighting factorE(x):=[Ea(x),Ep(x)],λ(σ):=(σ∗/(σ⋅σdata))2 - 해당 framework에서
은 score function이∇xlogp(x;σ(t))=(D(x;σ)−x)/σ2 대신τ 에 의존하는 ODE가 됨:σ
(Eq. 4)dsdσ=−σ∇slogpσ(s|t)=s−K(s;t,σ)σ,s(σ(T))∼N(0,σ(T)2I)
- 2nd-order Heun method를 사용하는 경우와 달리, StyleTTS2는 더 빠르고 다양한 sampling을 위해 ancestral DPM-2 solver를 사용하여 (Eq. 4)를 solve 함
- 이때 인 scheduler를 사용σmin=0.0001,σmax=3,ρ=9
- 이를 통해 3 step만으로 고품질 음성 합성을 위한 style vector를 sampling 할 수 있음 - 추가적으로
- Noisy input
와 concatenate 된E(x)+σξ 부터t 까지의hbert condition과V 는 sinusoidal positional embedding을 통해 condition 됨σ - Multi-speaker에서는
를p(s|t,c) 로 모델링하고, additional speaker embeddingK(s;t,c,σ) 를 사용c=E(xref)
- 이때 는 target speaker의 reference audio이고, speaker embeddingxref 는 adaptive layer normalization에 의해c 에 inject 됨V
- Noisy input
- StyleTTS2는 분포

- SLM Discriminators
- Speech Language Model (SLM)은 acoustic, semantic을 포함한 valuable information을 encoding 하고, 이러한 SLM representation은 human perception을 모방할 수 있음
- 따라서 StyleTTS2는 discriminator로 94k hours의 data로 pre-train 된 12-layer WavLM을 사용하여 adversarial training을 통해 SLM encoder의 knowledge를 transfer 함
- 이때 WavLM의 parameter 수가 StyleTTS2 보다 크기 때문에 discriminator overpowering을 방지하기 위해, pre-trained WavLM 를 fix 하고 CNNW 를 discriminative head로 추가함C
- 즉, SLM discriminator 로 나타낼 수 있음DSLM=C˙W - Generator component (
를T,B,G,S,P,V 로 denote)와G 을 training 하여 다음을 최적화함:DSLM
(Eq. 5)Lslm=minGmaxDSLM(Ex[logDSLM(x)]+Et[log(1−DSLM(G(t)))])
- : textG(t) 로 생성된 음성,t : human recordingx - 추가적으로:
(Eq. 6)D∗SLM(x)=PW∘T(x)PW∘T(x)+PW∘G(x)
- : optimal discriminator,D∗SLM(x) : 각각 실제 data 분포와 생성된 data 분포,T,G : 각각의 densityPT,PG
- 이때 optimal 는G∗ 인 경우 달성됨PW∘T=PW∘G
- 이는 수렴할 때 가 SLM representation space에서 생성된 실제 분포와 match 되어 human-level synthesis가 가능함을 의미G∗ - (Eq. 5)에서 generator loss는 ground-truth
와 independent 하고 input textx 에만 의존함t
- 이를 통해 out-of-distribution (OOD) text에 대한 training이 가능함
- 실질적으로 이 overfitting 되는 것을 방지하기 위해, training 중에 동일한 확률로 in-distribution과 OOD text를 sampling 함DSLM

- Differentiable Duration Modeling
- Duration predictor는 phoneme duration
를 생성하지만,dpred 를 얻기 위한 upsampling 과정은 non-differentiable 하기 때문에 E2E training에 대한 gradient flow를 방해함apred - 단순하게
에서dgt 의 deviation으로 인한 length mismatch로 인해 extra loss term 없이 (Eq. 5)의 adversarial objective 만을 사용하여 differentiable upsampling을 구현하면, StyleTTS2의 training이 unstable 해질 수 있음dpred
- 이러한 mismatch는 soft dynamic time warping을 통해 해결할 수 있지만, 계산 비용이 많이 필요 - 결과적으로 stable adversarial training과 human-level의 합성 품질을 달성하기 위해서는 non-parametric upsampling이 선호됨
- Gaussian upsampling은 non-parametric method로써, hyperparameter
와σ 로 centered 된 Gaussian kernelci:=ℓi−12dpred[i] 를 사용하여 예측 durationNci(n;σ) 를dpred 로 변환:apred[n,i]
(Eq. 7)Nci(n;σ):=exp(−(n−ci)22σ2)
(Eq. 8)ℓi:=∑ik=1dpred[k]
- : end position,ℓi :ci -th phonemei 의 center positionti - Gaussian upsampling은
에 의해 결정되는 Gaussian kernel의 fixed width로 인해 한계가 있음σ
- 해당 constraint는 에 따라 다양한 length의 alignment를 모델링하는 것을 방해함dpred
- Gaussian upsampling은 non-parametric method로써, hyperparameter
- 따라서 다양한 alignment length를 고려하면서 additional training 없이 수행될 수 있는 새로운 non-parametric differentiable upsampler를 제안
- 먼저 각 phoneme
에 대해 random variableti 으로, phonemeai∈N 가 aligned speech frame의 index를 indicate 하도록 alignment를 모델링함ti - 이후
-th phoneme의 duration을 다른 random variablei 이라 하자di∈{1,...,L}
- 이때 은 maximum phoneme duration hyperparameter로 1.25초에 해당L=50 - 그러면
를 얻을 수 있지만, 각ai=∑ik=1dk 는 서로 dependent 하므로 summation을 모델링하기 어려움dk - 대신
로 근사하면,ai=di+ℓi−1 의 근사 probability mass function (PMF)는 다음과 같이 얻어짐:ai
(Eq. 9)fai[n]=fdi+ℓi−1[n]=fdi[n]∗fℓi−1[n]=∑kfdi[k]⋅δℓi−1[n−k]
- 은δℓi−1 에서의 PMF로, (Eq. 8)에서 정의된 constantℓi−1
- 해당 delta function은 non-differentiable 하므로 (Eq. 7)에서 로 정의된σ=1.5 로 대체Nℓi−1
- 먼저 각 phoneme
를 모델링하기 위해, duration predictor를 modify 하여fdi 를 output 함q[k,i] - 이는
에 대해 적어도k∈{1,...,L} 의 duration을 가지는k -th phoneme의 확률로써, cross-entropy loss를 사용하여i 일 때 1이 되도록 최적화됨dgt≥k - 위 방식은
를 서로 match 하도록 training 된dgt,Ldur 로 근사할 수 있음dpred[i]:=∑Lk=1q[k,i]
- 여기서 vector 는 intervalq[:,i] 에 걸쳐 uniformly distribute 되도록 train 되었지만,[1,di] 의 unnormalized version으로도 볼 수 있음fdi - Speech frame 수
은 일반적으로 input phoneme 수M 보다 크기 때문에, 해당 uniform 분포는 single phoneme을 multiple speech frame으로 align 할 수 있음N - 마지막으로, phoneme axis에 걸쳐 differentiable approximation
을 normalize 하여 softmax function을 통해˜fai[n] 를 얻음:apred
(Eq. 10)apred[n,i]:=e(˜fai[n])∑Ni=1e(˜fai[n])
(Eq. 11)˜fai[n]:=∑ˆMk=0q[n,i]⋅Nℓi−1(n−k;σ)
- : predicted total duration,ˆM:=⌈ℓN⌉ n∈{1,...,ˆM}
- 이는
- Duration predictor는 phoneme duration

3. Experiments
- Settings
- Results
- Model Performance
- LJSpeech에서 StyleTTS2는 NaturalSpeech 보다 1.07 더 높은 CMOS-N를 달성함 (
)p≪0.01 - 마찬가지로 VCTK에서 StyleTTS2는 VITS 보다 높은 CMOS 결과를 보임
- Zero-shot 환경에서 VALL-E와 비교하여 StyleTTS2는 +0.67 CMOS-N로 자연스러운 합성이 가능하지만, CMOS-S 측면에서는 -0.47로 similarity는 다소 낮음
- LJSpeech에서 StyleTTS2는 NaturalSpeech 보다 1.07 더 높은 CMOS-N를 달성함 (

- Out-of-Domain (OOD) text에 대한 합성 품질을 비교해 보면, StyleTTS2는 OOD text에 대해 어떠한 성능 저하도 발생하지 않았지만 다른 모델들은 품질 저하가 나타남

- Style Diffusion
- Style diffusion process를 통해 생성된 style vector에 대한 t-SNE 결과를 확인해 보면
- LJSpeech model의 style vector는 input text sentiment에 response 하여 distinct emotional style을 드러냄
- LibriTTS model에서도 distinct cluster가 형성되어 single reference audio에서 파생된 stylistic diversity를 보여줌
- First speaker에 대한 nuanced view 측면에서, 일부 overlap에도 불구하고 visible emotion-based cluster가 나타나는 것을 확인할 수 있음
- 이는 reference audio tone에 관계없이 unseen speaker의 emotional tone을 manipulate 할 수 있다는 것을 의미

- 동일한 input text에 대해 coefficient of variation of duration
과 pitch curveCVdur 를 사용하여 합성된 음성의 diversity를 비교해 보면CVf0 - StyleTTS2가 가장 높은 variation을 나타내므로 다양한 음성을 생성할 수 있음
- 추가적으로 RTF 측면에서도 StyleTTS2는 diffusion-based 임에도 불구하고 가장 빠른 추론 속도를 보임

- Ablation Study
- Style vector가 random encoding으로 대체되는 경우, CMOS의 저하가 나타남
- 마찬가지로 differentiable upsampler, SLM discriminator, prosodic style encoder를 제거하는 경우에도 품질 저하가 발생
- 추가적으로 adversarial training에서 OOD text를 제외하는 경우에도 CMOS 저하가 발생함

반응형