티스토리 뷰

반응형

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 성능을 달성했음
      1. BUT, 많은 계산 비용이 필요하고, large scale representation learning이 기존의 mel-spectrogram에 비해 큰 이점이 있는지는 불명확
      2. 대표적으로 VALL-E는 pre-trained quantized neural audio codec인 EnCodec을 사용하는데, 여기에는 autoregressive component가 포함되어 있어 추론 latency가 상당히 느려짐
        - 이러한 추론 속도 문제를 개선하기 위해서는 autoregressive formulation에 대한 의존도를 줄여야 함
    • 한편으로 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 하여 해당 문제를 해결

< 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과 유사함
    • <text,speech><text,speech> paired data가 주어졌을 때, 음성의 mel-spectrogram을 xx로, text를 cc라 하자
      - 이후 mpmp를 sequence xx의 indicator mask로 설정하여 xx에서 randomly positioned 3초 segment를 masking 함

      - 이때 xp=(1mp)xxp=(1mp)x라고 하면 pp는 zero-shot 추론 중에 variable이 arbitrary한 3초의 prompt로 대체됨을 의미
    • P-Flow의 training objective는 주어진 cc와 segment xpxp를 통해 xx를 reconstruct 하는 것
      - 여기서 P-Flow가 학습 중에 제공된 xpxp를 포함하여 xx 전체를 reconstruct 할 것으로 예상되더라도, 모델은 xx 내에서 xpxp의 exact positioning을 수행함
    • 결과적으로 P-Flow는 음성 p(x|c,xp)p(x|c,xp)의 conditional 확률 분포를 모델링하는 법을 학습함
      1. 이를 위해 text cc와 random segment xpxp를 speech prompt로 사용하여 speaker-conditioned text representation을 생성하는 speech-prompted text encoder fencfenc를 도입
      2. 이후 text encoder의 output은 flow-matching generative model을 사용하여 mel-spectrogram에 mapping 되고, vocoder를 통해 waveform으로 얻어짐
  • Speech-Prompted Text Encoder
    • Text input cc와 함께 speech prompt로써 random segment xpxp의 mel-spectrogram을 input 함
      - 이후 text encoder에 대한 input으로 사용하기 위해 두 가지 input 모두를 동일한 dimension으로 project 함
    • Speech prompt text encoder의 역할은 prompt xpxp에서 추출된 speaker information을 활용하여 speaker-conditional text representation 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 hchc와 mel-spectrogram xx의 length가 다르기 때문에, Glow-TTSMonotonic Alignment Search (MAS)를 채택
      1. MAS를 적용하여 aligned text encoder output과 mel-spectrogram 간의 L2L2 distance를 최소화하는 alignment A=MAS(hc,x)A=MAS(hc,x)를 유도
      2. 이후 alignment AA를 기반으로 각 text token의 duration dd를 결정하고, 그에 따라 encoder representation을 duplicating 하여 encoder output hchc를 expand
      3. 해당 alignment process를 통해 mel-spectrogram xx와 align 되는 text encoder output hh를 얻을 수 있음
        - 이때 reconstruction lossLenc=MSE(h,x)Lenc=MSE(h,x)
    • 실제로는 모델이 training 중에 xx내에서 xpxp의 exact positioning을 제공하지 않았음에도 불구하고 xpxp trivial copy-pasting으로 collapse 되는 경향이 있음
      1. 이를 방지하기 위해 xpxp에 해당하는 segment에 대한 reconstruction loss를 masking 함
      2. 따라서 mel-spectrogram xx에서 random segment xpxp에 대해 mpmp를 사용하여 maksed encoer loss LpencLpenc를 정의:
        (Eq. 1) Lpenc=MSE(hmp,xmp)Lpenc=MSE(hmp,xmp)
      3. 해당 loss를 최소화함으로써 encoder는 주어진 speech xx와 유사한 aligned output hh를 생성하기 위해, speech prompt에서 speaker information을 최대한 추출하도록 학습됨
        - 결과적으로 speaker adaptation을 위한 in-context capability가 향상됨
  • Flow Matching Decoders
    • 빠르고 고품질의 zero-shot TTS를 수행하기 위해, 확률 분포 p(x|c,xp)=p(x|h)p(x|c,xp)=p(x|h)를 모델링하는 decoder로써 flow matching generative model을 도입
    • Flow matching decoder는 standard normal 분포에서 data 분포로의 conditional mapping을 나타내는 Continuous Normalizing Flow (CNF)의 conditional vector field vt(|h)vt(|h)를 모델링
    • 이때 decoder는 LpencLpenc와 같이 random segment에 대한 mask mpmp를 적용한 flow matching loss LpcfmLpcfm를 사용하여 학습
  • 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 LdurLdur는 MAS를 통해 얻은 log-scale duration logdlogd에 대한 mean squared error를 최소화하는 것
  • 따라서 P-Flow의 final loss는, L=Lpenc+Lpcfm+LdurL=Lpenc+Lpcfm+Ldur
    • Zero-shot 추론 시에 hchc를 얻기 위해, speech-prompted text encoder에 대한 input으로 desired transcript와 reference sample의 random chunk를 사용함
      - 이때 speech prompt에 해당하는 transcript는 제공되지 않음
    • 이후 duration predictor에서 예측된 duration ˆd^d를 사용하여 encoder output hchc를 expand 하고, flow matching decoder를 사용하여 음성을 생성함

Overall of P-Flow

- Flow Matching Decoder

  • P-Flow는 mel-spectrogram decoder의 conditional 분포 p(x|h)p(x|h)를 모델링하기 위해 Flow Matching을 도입
  • Flow Matching Overview
    • Flow Matching은 data density p1(x)p1(x)와 simpler sampling density p0(x)p0(x) (standard normal) 간의 time-dependent probability path를 fitting 하는 방법
      - 이는 Continuous Normalizing Flow와 관련하여, diffusion/score matching과 마찬가지로 simulation-free 하게 효율적으로 train 될 수 있도록 함
    • 따라서 P-Flow는 source와 target 분포 사이의 simple, straight trajectory를 얻을 수 있고 추가적인 distillation 없이 더 적은 step 수로 test-time sampling이 가능한 Conditional Flow Matching을 채택
      1. 먼저 다음의 ODE를 사용하여 두 density function 간의 mapping으로 flow ϕ:[0,1]×RdRd를 정의하자:
        (Eq. 2) ddtϕt(x)=vt(ϕt(x));ϕ0(x)=x
        - vt(x) : time-dependent vector field로 time에 따른 probability flow의 trajectory를 specifying 함

        - 이때 vt(x)는 learnable 하고, 이후 vt(ϕ(x);θ)와 같이 나타냄
      2. 분포에서 sample을 얻기 위해, t=0의 initial condition으로 분포 p0에서 sampling을 수행하고 (Eq. 2)의 ODE를 solve 함
        - 해당 formulation은 straighter trajectory를 encourage 하기 때문에, 품질 손실을 최소화하면서 10 Euler step 만으로도 ODE solution을 효율적으로 근사할 수 있음
      3. 이때 marginal flow ϕt(x)를 결정하는 것은 어렵기 때문에, 아래와 같이 multiple conditional flow ϕt,x1(x)에 대해 marginalizing 하는 것으로 formulate 하면:
        (Eq. 3) ϕt,x1(x)=σt(x1)x+μt(x1)
        - σt(x1),μt(x1) : Gaussian 분포 p1,p0 간의 변환을 parameterization 하는 time-conditional affine 변환
      4. 마지막으로 q(x1)은 true이지만 data에 대해 non-Gaussian일 수 있음
        - 따라서 p1σmin을 통해 소량의 white noise로 개별 sample을 perturbing 함으로써 q의 mixture-of-Gaussian 근사로 정의
    • 이를 통해 SDE와 같이 stochasticity로 인한 complication 없이 trajectory를 specify 할 수 있음
      1. 따라서 해당 simple linear trajectory를 기반으로 ϕt에 대해 다음의 parameterization을 얻을 수 있음:
        (Eq. 4) μt(x)=tx1,σt(x)=1(1σmin)t 
      2. Vector field training은 objective function과 matching 되는 conditional flow를 사용하여 수행됨:
        (Eq. 5) LCFM(θ)=EtU[0,1],x1q(x1),x0p(x0)||vt(ϕt,x1(x0);θ)ddtϕt,x1(x0)||2
      3. (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
  • Masked Flow Matching Loss
    • P-Flow의 flow matching decoder는 분포 p(x|h)를 모델링함
    • 이때 h는 sub-segment xpx에 의해 제공되는 text encoder output이기 때문에 trivial solution을 방지하기 위해 xp에 해당하는 output 부분에 대한 loss를 mask 하는 것이 필요함
    • 이를 위해 generic vt(xt;θ)ˆvθ(xt,h,t)로 parameterize 하여 Masked CFM objective를 얻음:
      (Eq. 7) LpCFM(θ)=Et,q(x1),p(x0)||mp(ˆvθ(ϕt,x1(x0),h,t)(x1(1σmin)x0))||2
      - 여기서 t는 continuous sinusoidal embedding으로 represent 됨
  • 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를 생성하는 것으로 나타남
    • 여기서 N Euler step을 사용한 sampling은 다음과 같은 recurrence relation으로 수행될 수 있음:
      (Eq. 8) x0N(0,I);xt+1N=xt+1Nˆvθ(xt,h,t)
  • Guided Sampling
    • Classifier-free guidance를 사용하여 pronunciation clarity를 개선할 수 있음
    • 이를 위해 h에서 계산된 average feature vector ˉh로부터 sampling trajectory를 guiding 하도록 함
      - ˉh는 fixed-size vector를 얻기 위해 time axis를 따라 expand 된 representation h를 averaging 한 다음, time axis를 따라 duplicating 함으로써 계산됨
    • 결과적으로 P-Flow의 guidance-amplified Euler formulation은:
      (Eq. 9) xt+1N=xt+1N(ˆvθ(xt,h,t)+γ(ˆvθ(xt,h,t)ˆvθ(xt,ˉh,t)))

Conditional Flow Matching

- Model Details

  • P-Flow는 3가지 주요 component로 구성됨
    1. 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의 합으로 정의
    2. Duration Predictor
      • Glow-TTS에서 사용된 shallow convolution-based model을 채택
      • 이때 text encoder output은 speaker-conditional hidden representation을 나타내므로, hc에 대한 linear projection 이전의 hidden representation을 duration predictor의 input으로 사용
    3. WaveNet-based Flow Matching Decoder
      • 512 hidden dimension을 가지는 WaveNet-like architecture를 사용
      • t를 conditioning 하기 위해 WaveNet의 global conditioning method를 활용하고,
      • Speaker-conditional text representation을 conditioning 하기 위해 channel axis를 따라 aligned encoder output h와 input xt를 concatenate 함

P-Flow의 Hyperparameter

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 보다 더 효과적임

Speech Prompting의 효과 비교

  • 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를 향상하기 때문
  • CMOS
    • CMOS를 통해 품질을 비교해 보면, P-Flow가 VALL-E 보다 더 나은 sample을 합성하는 것으로 나타남
    • 즉, continuous representation을 사용하는 것이 discrete token 보다 더 우수한 품질을 얻을 수 있음

P-Flow와 VALL-E의 비교

  • 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, Euler Step에 따른 성능 비교

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

Euler Step에 따른 품질 비교

 

반응형
최근에 올라온 글
최근에 달린 댓글
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Total
Today
Yesterday