티스토리 뷰
Paper/TTS
[Paper 리뷰] P-Flow: A Fast and Data-Efficient Zero-Shot TTS through Speech Prompting
feVeRin 2024. 3. 16. 13:00반응형
P-Flow: A Fast and Data-Efficient Zero-Shot TTS through Speech Prompting
- Neural codec language model은 대규모의 data를 학습하여 zero-shot text-to-speech 성능을 크게 향상함
- BUT, robustness가 부족하고, sampling 속도가 매우 느리고, pre-trained neural codec representation에 의존적임 - P-Flow
- Speaker adaptation을 위해 speech prompt를 사용하는 빠르고 data-efficient 한 zero-shot text-to-speech 모델
- Speech-prompted text encoder와 flow matching generative decoder로 구성
- Speech-prompted text encoder는 speech prompt와 text input을 사용하여 speaker-conditional text representation을 생성
- Flow matching generative decoder는 speaker-conditional output을 사용하여 빠르고 고품질의 음성을 합성 - 이때 neural codec language model과 달리 continuous mel-representation을 사용하여 P-Flow를 학습
- 논문 (NeurIPS 2024) : Paper Link
1. Introduction
- Zero-Shot Text-to-Speech (TTS)는 추가적인 학습 없이 unseen speaker의 characteristic을 반영하는 text-conditioned speech를 합성하는 것을 목표로 함
- 이때 speaker characteristic은 reference audio segment로 주어지고, 3초 이하의 length를 가질 수 있음
- 최근의 large-scale language model은 대규모 dataset, quantization, pre-training 등을 활용하여 우수한 zero-shot TTS 성능을 달성했음
- 한편으로 flow matching과 같은 ODE-based generative modeling을 활용하여 추론 latency를 개선할 수 있음
- 이는 더 simple하고 straight 한 trajectory를 제공하여 추론 시에 function evaluation을 크게 줄임
-> 그래서 language model의 prompting과 flow matching을 결합한 효율적인 zero-shot TTS 모델인 P-Flow를 제안
- P-Flow
- Non-autoregressive TTS 모델을 기반으로 speech-prompted text encoder를 도입
- Text input과 함께 3초의 random speech segment를 prompt로 incorporate 하고 해당 input으로부터 mel-spectrogram을 예측하는 방법을 학습 - Flow-matching generative decoder는 speech-prompted text encoder와 결합되어 고품질 mel-spectrogram을 효율적으로 sampling 함
- 이때 text encoder의 speaker-conditional ouptut에 따라 condition 된 mel-spectrogram의 확률 분포를 모델링하는 vector field를 예측하도록 학습됨 - 추가적으로 prompting approach는 random speech segment를 input으로 직접 활용하므로, random segment에 대한 identity function과 같은 trivial solution을 학습할 위험이 있음
- 따라서 학습 중에 random segment에 대한 loss를 masking 하여 해당 문제를 해결
- Non-autoregressive TTS 모델을 기반으로 speech-prompted text encoder를 도입
< Overall of P-Flow >
- Speaker adaptation을 위한 in-context learning capability를 제공하는 non-autoregressive zero-shot TTS 모델에 대한 speech prompting 방식을 제시
- 합성 속도와 sample 품질을 모두 향상하는 zero-shot TTS를 위한 flow matching generative model을 도입
- 결과적으로 기존 모델들보다 더 적은 data와 parameter size 만으로도 우수한 zero-shot TTS 성능을 달성
- 실제로 P-Flow는 평균 0.11초의 빠른 추론 latency를 보임
2. Method
- P-Flow는 빠르고 고품질의 non-autoregressive TTS 모델에서 zero-shot adaptation을 위한 in-context learning capability를 제공하는 것을 목표로 함
- Neural codec language model과 유사하게 reference speech를 speaker adaptation을 위한 prompt로 직접 활용하는 prompting approach를 도입
- 이 외에도 효율적인 sampling을 위해 decoder로 flow matching generative model을 채택함
- P-Flow
- P-Flow의 training은 masked-autoencoder의 training과 유사함
paired data가 주어졌을 때, 음성의 mel-spectrogram을<text,speech><text,speech> 로, text를xx 라 하자cc
- 이후 를 sequencempmp 의 indicator mask로 설정하여xx 에서 randomly positioned 3초 segment를 masking 함xx
- 이때 라고 하면xp=(1−mp)⋅xxp=(1−mp)⋅x 는 zero-shot 추론 중에 variable이 arbitrary한 3초의 prompt로 대체됨을 의미pp - P-Flow의 training objective는 주어진
와 segmentcc 를 통해xpxp 를 reconstruct 하는 것xx
- 여기서 P-Flow가 학습 중에 제공된 를 포함하여xpxp 전체를 reconstruct 할 것으로 예상되더라도, 모델은xx 내에서xx 의 exact positioning을 수행함xpxp - 결과적으로 P-Flow는 음성
의 conditional 확률 분포를 모델링하는 법을 학습함p(x|c,xp)p(x|c,xp) - 이를 위해 text
와 random segmentcc 를 speech prompt로 사용하여 speaker-conditioned text representation을 생성하는 speech-prompted text encoderxpxp 를 도입fencfenc - 이후 text encoder의 output은 flow-matching generative model을 사용하여 mel-spectrogram에 mapping 되고, vocoder를 통해 waveform으로 얻어짐
- 이를 위해 text
- Speech-Prompted Text Encoder
- Text input
와 함께 speech prompt로써 random segmentcc 의 mel-spectrogram을 input 함xpxp
- 이후 text encoder에 대한 input으로 사용하기 위해 두 가지 input 모두를 동일한 dimension으로 project 함 - Speech prompt text encoder의 역할은 prompt
에서 추출된 speaker information을 활용하여 speaker-conditional text representationxpxp 를 생성하는 것hc=fenc(xp,c)hc=fenc(xp,c)
- 이때 large-scale codec language model과 마찬가지로 arbitrary text position에서 speech prompt를 처리하는 non-autoregressive transformer architecture를 채택 - Speech prompt에서 speaker information을 효과적으로 추출하도록 speech-prompted text encoder를 training 하기 위해, text encoder representation과 mel-spectrogram 간의 distance를 최소화하는 encoder loss를 사용
- 이때 Grad-TTS와 같이 sampling step을 줄이는 것 외에도 encoder가 speaker-related detail을 생성된 text representation에 incorporate 하도록 함 - Speech-prompted encoder output
와 mel-spectrogramhchc 의 length가 다르기 때문에, Glow-TTS의 Monotonic Alignment Search (MAS)를 채택함xx - MAS를 적용하여 aligned text encoder output과 mel-spectrogram 간의
distance를 최소화하는 alignmentL2L2 를 유도A=MAS(hc,x)A=MAS(hc,x) - 이후 alignment
를 기반으로 각 text token의 durationAA 를 결정하고, 그에 따라 encoder representation을 duplicating 하여 encoder outputdd 를 expandhchc - 해당 alignment process를 통해 mel-spectrogram
와 align 되는 text encoder outputxx 를 얻을 수 있음hh
- 이때 reconstruction loss는Lenc=MSE(h,x)Lenc=MSE(h,x)
- MAS를 적용하여 aligned text encoder output과 mel-spectrogram 간의
- 실제로는 모델이 training 중에
내에서xx 의 exact positioning을 제공하지 않았음에도 불구하고xpxp 의 trivial copy-pasting으로 collapse 되는 경향이 있음xpxp - 이를 방지하기 위해
에 해당하는 segment에 대한 reconstruction loss를 masking 함xpxp - 따라서 mel-spectrogram
에서 random segmentxx 에 대해xpxp 를 사용하여 maksed encoer lossmpmp 를 정의:LpencLpenc
(Eq. 1)Lpenc=MSE(h⋅mp,x⋅mp)Lpenc=MSE(h⋅mp,x⋅mp) - 해당 loss를 최소화함으로써 encoder는 주어진 speech
와 유사한 aligned outputxx 를 생성하기 위해, speech prompt에서 speaker information을 최대한 추출하도록 학습됨hh
- 결과적으로 speaker adaptation을 위한 in-context capability가 향상됨
- 이를 방지하기 위해
- Text input
- Flow Matching Decoders
- 빠르고 고품질의 zero-shot TTS를 수행하기 위해, 확률 분포
를 모델링하는 decoder로써 flow matching generative model을 도입p(x|c,xp)=p(x|h)p(x|c,xp)=p(x|h) - Flow matching decoder는 standard normal 분포에서 data 분포로의 conditional mapping을 나타내는 Continuous Normalizing Flow (CNF)의 conditional vector field
를 모델링함vt(⋅|h)vt(⋅|h) - 이때 decoder는
와 같이 random segment에 대한 maskLpencLpenc 를 적용한 flow matching lossmpmp 를 사용하여 학습됨LpcfmLpcfm
- 빠르고 고품질의 zero-shot TTS를 수행하기 위해, 확률 분포
- Duration Predictor
- 추론 시에는 MAS를 사용할 수 없으므로, duration predictor를 도입함
- 이때 주어지는 representation에는 이미 speaker information이 포함되어 있으므로, 추가적인 speaker conditioning 없이 speech-prompted text encoder의 hidden representation을 input으로 사용
- Text encoder 학습에 영향을 주지 않기 위해, detached input을 사용하여 나머지 모델과 simultaneously trian 됨 - Duration predictor는 각 text token에 대한 log-scale duration
를 추정함logˆdlog^d
- Duration predictor의 training objective 는 MAS를 통해 얻은 log-scale durationLdurLdur 에 대한 mean squared error를 최소화하는 것logdlogd
- 추론 시에는 MAS를 사용할 수 없으므로, duration predictor를 도입함
- 따라서 P-Flow의 final loss는,
L=Lpenc+Lpcfm+LdurL=Lpenc+Lpcfm+Ldur - Zero-shot 추론 시에
를 얻기 위해, speech-prompted text encoder에 대한 input으로 desired transcript와 reference sample의 random chunk를 사용함hchc
- 이때 speech prompt에 해당하는 transcript는 제공되지 않음 - 이후 duration predictor에서 예측된 duration
를 사용하여 encoder outputˆd^d 를 expand 하고, flow matching decoder를 사용하여 음성을 생성함hchc
- Zero-shot 추론 시에

- Flow Matching Decoder
- P-Flow는 mel-spectrogram decoder의 conditional 분포
를 모델링하기 위해 Flow Matching을 도입p(x|h)p(x|h) - Flow Matching Overview
- Flow Matching은 data density
와 simpler sampling densityp1(x)p1(x) (standard normal) 간의 time-dependent probability path를 fitting 하는 방법p0(x)p0(x)
- 이는 Continuous Normalizing Flow와 관련하여, diffusion/score matching과 마찬가지로 simulation-free 하게 효율적으로 train 될 수 있도록 함 - 따라서 P-Flow는 source와 target 분포 사이의 simple, straight trajectory를 얻을 수 있고 추가적인 distillation 없이 더 적은 step 수로 test-time sampling이 가능한 Conditional Flow Matching을 채택
- 먼저 다음의 ODE를 사용하여 두 density function 간의 mapping으로 flow
를 정의하자:ϕ:[0,1]×Rd→Rd
(Eq. 2)ddtϕt(x)=vt(ϕt(x));ϕ0(x)=x
- : time-dependent vector field로 time에 따른 probability flow의 trajectory를 specifying 함vt(x)
- 이때 는 learnable 하고, 이후vt(x) 와 같이 나타냄vt(ϕ(x);θ) - 분포에서 sample을 얻기 위해,
의 initial condition으로 분포t=0 에서 sampling을 수행하고 (Eq. 2)의 ODE를 solve 함p0
- 해당 formulation은 straighter trajectory를 encourage 하기 때문에, 품질 손실을 최소화하면서 10 Euler step 만으로도 ODE solution을 효율적으로 근사할 수 있음 - 이때 marginal flow
를 결정하는 것은 어렵기 때문에, 아래와 같이 multiple conditional flowϕt(x) 에 대해 marginalizing 하는 것으로 formulate 하면:ϕt,x1(x)
(Eq. 3)ϕt,x1(x)=σt(x1)x+μt(x1)
- : Gaussian 분포σt(x1),μt(x1) 간의 변환을 parameterization 하는 time-conditional affine 변환p1,p0 - 마지막으로
은 true이지만 data에 대해 non-Gaussian일 수 있음q(x1)
- 따라서 을p1 을 통해 소량의 white noise로 개별 sample을 perturbing 함으로써σmin 의 mixture-of-Gaussian 근사로 정의q
- 먼저 다음의 ODE를 사용하여 두 density function 간의 mapping으로 flow
- 이를 통해 SDE와 같이 stochasticity로 인한 complication 없이 trajectory를 specify 할 수 있음
- 따라서 해당 simple linear trajectory를 기반으로
에 대해 다음의 parameterization을 얻을 수 있음:ϕt
(Eq. 4)μt(x)=tx1,σt(x)=1−(1−σmin)t - Vector field training은 objective function과 matching 되는 conditional flow를 사용하여 수행됨:
(Eq. 5)LCFM(θ)=Et∼U[0,1],x1∼q(x1),x0∼p(x0)||vt(ϕt,x1(x0);θ)−ddtϕt,x1(x0)||2 - (Eq. 4)를 (Eq. 3), (Eq. 5)에 대입하면, 다음의 final CFM objective를 얻을 수 있음:
(Eq. 6)LCFM(θ)=Et,q(x1),p(x0)||vt(ϕt,x1(x0);θ)−(x1−(1−σmin)x0)||2
- 따라서 해당 simple linear trajectory를 기반으로
- Flow Matching은 data density
- Masked Flow Matching Loss
- P-Flow의 flow matching decoder는 분포
를 모델링함p(x|h) - 이때
는 sub-segmenth 에 의해 제공되는 text encoder output이기 때문에 trivial solution을 방지하기 위해xp∈x 에 해당하는 output 부분에 대한 loss를 mask 하는 것이 필요함xp - 이를 위해 generic
를vt(xt;θ) 로 parameterize 하여 Masked CFM objective를 얻음:ˆvθ(xt,h,t)
(Eq. 7)LpCFM(θ)=Et,q(x1),p(x0)||mp⋅(ˆvθ(ϕt,x1(x0),h,t)−(x1−(1−σmin)x0))||2
- 여기서 는 continuous sinusoidal embedding으로 represent 됨t
- P-Flow의 flow matching decoder는 분포
- Sampling
- Conditional flow matching loss는 conditional vector field를 marginalize 하여 marginal vector field를 얻고, 이를 sampling에 사용함
- (Eq. 4)의 linearly interpolated conditional trajectory는 resulting marginal에서 동일한 degree of straightness를 보장하지는 않지만, 그에 근사한 결과를 얻을 수 있음
- 실제로 conditional flow matching formulation은 추론 중에 10 step first-order Euler's method를 사용하는 것만으로도 충분히 simple한 trajectory를 생성하는 것으로 나타남 - 여기서
Euler step을 사용한 sampling은 다음과 같은 recurrence relation으로 수행될 수 있음:N
(Eq. 8)x0∼N(0,I);xt+1N=xt+1Nˆvθ(xt,h,t)
- Guided Sampling
- Classifier-free guidance를 사용하여 pronunciation clarity를 개선할 수 있음
- 이를 위해
에서 계산된 average feature vectorh 로부터 sampling trajectory를 guiding 하도록 함ˉh
- 는 fixed-size vector를 얻기 위해 time axis를 따라 expand 된 representationˉh 를 averaging 한 다음, time axis를 따라 duplicating 함으로써 계산됨h - 결과적으로 P-Flow의 guidance-amplified Euler formulation은:
(Eq. 9)xt+1N=xt+1N(ˆvθ(xt,h,t)+γ(ˆvθ(xt,h,t)−ˆvθ(xt,ˉh,t)))

- Model Details
- P-Flow는 3가지 주요 component로 구성됨
- Prompt-based Text Encoder
- Linear projection layer, 3개의 convolution layer를 가진 pre-network, 192 hidden dimension과 2개 attention head를 가진 6-layer transformer로 구성
- Speech-prompted text encoder의 input을 위해, speech prompt와 text embedding을 동일한 dimensiondp project 하고 동일한 pre-network에 input 함
- 이때 Resulting representation은 prompt part와 text part로 split 되고, positional encoding이 추가됨 - 이후 transformer가 learnable embedding을 통해 speech prompt와 text를 differentiate 할 수 있도록 각 positional encoding을 absolute positional encoding과 learnable fixed-size embedding의 합으로 정의
- Duration Predictor
- Glow-TTS에서 사용된 shallow convolution-based model을 채택
- 이때 text encoder output은 speaker-conditional hidden representation을 나타내므로,
에 대한 linear projection 이전의 hidden representation을 duration predictor의 input으로 사용hc
- WaveNet-based Flow Matching Decoder
- 512 hidden dimension을 가지는 WaveNet-like architecture를 사용
를 conditioning 하기 위해 WaveNet의 global conditioning method를 활용하고,t - Speaker-conditional text representation을 conditioning 하기 위해 channel axis를 따라 aligned encoder output
와 inputh 를 concatenate 함xt
- Prompt-based Text Encoder

3. Experiments
- Settings
- Results
- Prompting v.s. Separate Speaker Encoder
- Speaker prompting을 통한 speaker conditioning의 효과를 확인해 보면, prompting을 도입하면 SECS가 크게 향상되는 것으로 나타남
- 즉, speech prompt를 사용하는 것이 모든 speaker information을 fixed-size vector로 encoding 하는 기존 zero-shot TTS 보다 더 효과적임

- Pronunciation Accuracy and Sample Quality
- P-Flow가 ground-truth 수준의 WER을 달성하기 위해 기존 모델들보다 2배 더 적은 data 만을 필요로 함
- 즉, P-Flow는 더 적은 data로도 고품질의 합성이 가능함
- Inference Latency
- Latency 측면에서도 P-Flow는 VALL-E 보다 20배 빠른 0.1초의 latency를 보임
- 특히 P-Flow는 non-autoregressive 모델이므로 length에 관계없이 거의 일정한 latency를 가짐
- 실제로 20초의 audio sample에 대해 0.12초의 latency가 소요됨

- Speaker Similarity Metrics
- 기존의 speaker embedding-based zero-shot TTS 모델에 비해 P-Flow는 speech prompting을 통해 더 효과적인 adaptation 성능을 보여줄 수 있음
- 특히 text encoder가 3M의 parameter 만을 가진다는 것을 고려하면, P-Flow는 높은 similarity를 달성하기 위해 neural codec, quantization, 대규모 data 등을 사용할 필요가 없음 - 결과적으로 ground-truth에 대한 similarity 비교에서 P-Flow의 결과가 가장 높은 SMOS를 보임
- Speech-prompted text encoder가 in-context learning capability를 향상하기 때문
- 기존의 speaker embedding-based zero-shot TTS 모델에 비해 P-Flow는 speech prompting을 통해 더 효과적인 adaptation 성능을 보여줄 수 있음
- CMOS
- CMOS를 통해 품질을 비교해 보면, P-Flow가 VALL-E 보다 더 나은 sample을 합성하는 것으로 나타남
- 즉, continuous representation을 사용하는 것이 discrete token 보다 더 우수한 품질을 얻을 수 있음

- Effect of Guidance Scale and Euler Steps
- Guidance scale
와 Euler stepγ 의 영향력을 확인해 보면N - 기본적으로 P-Flow는 guidance 없이도 YourTTS 보다 우수한 성능을 보이지만, guidance를 추가적으로 적용하면 pronunciation accuracy가 향상됨
- 즉, guidance는 speech prompting의 효과를 더욱 향상할 수 있음 - 한편으로 P-Flow는 적은 Euler step으로도 우수한 WER을 달성함
- 이는 flow matching model이 audio 품질에 관계없이 정확한 음성을 생성할 수 있다는 것을 의미
- SECS는 5 Euler step 이후에 안정화되고 대략 10 step에서 좋은 품질을 보임
- Guidance scale

- Effects of Euler Steps for Acoustic Quality
- Euler step이 증가하면 acoustic sample 품질이 향상되는 것으로 나타남
- 이때 추론 latency와 sample 품질 간의 trade-off를 만족하기 위해 논문은 Euler step
으로 설정N=10

반응형