본문 바로가기

연구실 공부

[논문] CLAPSpeech: Learning Prosody from Text Context with Contrastive Language-Audio Pre-training

728x90

https://arxiv.org/abs/2305.10763

 

CLAPSpeech: Learning Prosody from Text Context with Contrastive Language-Audio Pre-training

Improving text representation has attracted much attention to achieve expressive text-to-speech (TTS). However, existing works only implicitly learn the prosody with masked token reconstruction tasks, which leads to low training efficiency and difficulty i

arxiv.org

해당 논문을 보고 작성했습니다.

 

Abstract

text representation을 향상시키는 것은 expressive TTS을 도달하는데 큰 도움을 줍니다. 하지만 존재하는 연구들은 masked token reconstruction task를 이용하여 prosody를 암시적으로 학습하는데, 이는 학습 효율성을 저하시키고 prosody modelling이 어려워집니다. 그래서 저자들은 CLAPSpeech를 제안하는데, 이는 cross modal contrastive pre-training framework입니다. 다양한 context에서 같은 text token에 대한 prosody variacne를 명시적으로 학습하는 framework입니다.

구체적으로 1) 저자들은 세심한 design과 contrastive loss를 통해 model이 multi-modal space에서 text context와 그에 대응하는 prosody pattern을 connect하도록 만들어줍니다. 2) 저자들은 multi-scale pre-training pipeline을 제안하는데, multiple level에서 prosody pattern을 capture합니다. 저자들은 현재 존재하는 TTS model에 더 나은 prosody를 위해 CLAPSpeech를 적용합니다. 3가지 dataset에 대해 실험을 진행하여 CLAPSpeech가 TTS method의 prosody prediction 성능을 향상시킨다는 것을 보였습니다.

 

Introduction

deep learning의 발전에 따라, 현대 TTS system의 audio는 향상되고 있지만 여전히 prosody modelling은 문제로 남아있습니다. 이전 expressive TTS은 external variation predictor (prediction-based, PB), variational generative models (variation-based, VB)를 이용하여 prosody variance를 TTS model로 inject했습니다.

하지만 이러한 text representation learning method들은 masked language model task (BERT와 같은 large language model을 text corpus로 학습시키기)또는 masked acoustic model task (input text를 기반으로 masked mel-spectrogram을 reconstruct)기반이며, 이는 단점이 존재합니다. reconstruction loss를 기반으로 암시적으로 prosody를 학습하는데, 이는 prosody modeling 성능을 개선하는 것을 방해합니다. 그리고 pronunication space (발음 공간)와 prosody space (운율 / 음조 공간)를 분리하지 않기 때문에 학습 효율성이 떨어지고 model의 성능을 낭비하게 됩니다. TTS에서 사용된 이전 text representation이 다른 text context에서 prosody variance를 capture하지 못합니다.

기술적으로, prosody는 동일한 token이 다른 condition에 있어서 생기는 pitchvariance, duration variance으로 여길 수 있습니다. 이 논문에서는 text context에 연관 있는 prosody에 대한 연구를 진행합니다. "higher"이라는 동일한 단어가 있는데, "higher up"과 "slightly higher"는 서로 다른 prosody가 가능합니다. text-to-image task에 대한 cross-modal contrastive learning work에 영감을 받아, 저자들은 text-speech joint multi-modal space에서 text context와 hugh-level prosody pattern을 connect하는 contrastive learning method를 제안합니다. 이름은 Contrastive Language-Audio Pre-training for Text-to-Speech (CLAPSpeech)입니다. 구체적으로, 저자들은 text encoder가 text context로부터 prosody를 predict하도록 학습시킵니다. 그리고 prosody encoder는 선택된 token의 speech segment로부터 ground-truth (GT) prosody를 추출합니다. training할 때 N개의 text-speech pair를 선택하는데, 이 pair에는 같은 발음으로 발음 가능한 토큰을 포함합니다. text token을 대응하는 prosody (extracted from GT speech)로 align하고 서로 다른 text context로부터 얻어지는 prosody representation은 서로 떨어지게 함으로써, text encoder는 text context로부터 prosody를 추출하도록 학습됩니다. pre-training CLAPSpeech의 직관적 예시는 다음과 같습니다. 

 

저자들은 prosody pattern이 multiple level에서 표현될 수 있다는 것도 알아냈습니다. 그래서 저자들은 phoneme에서 prosody information을 capture하는 CLAPSpeech model과 word level에서 prosody information을 capture하는 CLAPSpeech model을 학습시키는 multi-scale pre-training framework를 제안합니다. pre-training 이후에, 저자들의 CLAPSpeech는 모든 TTS model의 text encoder로 사용될 수 있으며, 세밀한 prosody representation을 제공해 줄 수 있습니다. 

효율성과 일반화 성능을 입증하기 위해, 저자들은 2가지 large-scale automatic speech recognition (ASR) dataset (LibriSpeech, WenetSpeech)를 사용하여 CLAPSpeech model을 pre-train합니다. CLAPSpeech의 pre-trained text encoder는 prediction/variation-based TTS baseline에 적용되며, 이를 통해 expressive TTS system의 성능 향상을 보여줍니다.

요약하자면, CLAPSpeech는 3가지 이점이 있습니다. 1) 이전에 등장한 representation learning method보다 훨씬 더 나은 prosody representation을 제공하는데, 더 작은 model scale로도 가능합니다. 그리고 이는 contrastive loss를 사용했으며 명시적으로 prosody를 학습할 수 있게 되었습니다. 2) CLAPSpeech의 text representation은 아주 작은 수정만으로도 존재하는 TTS system에 적용될 수 있습니다. 3) 저자들은 model의 세밀한 prosody transfer와 같은 potential application을 보였습니다.

 

Related Work

Expressive TTS

지난 몇 년 동안, 현대 neural TTS는 실용성과 audio quality 측면에서 상당한 발전을 이루었습니다. 하지만, 평범한 input text가 주어진 상태에서 expressive prosody를 modeling하는 것은 여전히 도전적인 과제로 남아있습니다. expressive TTS를 개발하기 위해, 가장 일반적인 방법 중 하나는 reference encoder랑 style token을 사용하는 것입니다. 하지만 inference할 때 적절한 reference audio를 선택하는 것은 어렵습니다. 다른 연구들은 발전된 network design을 가지고 prosody modeling을 향상시키는 방법인데, 이는 2가지 class로 categorize할 수 있습니다. 1) prediction-based (PB) TTS system은 pitch contour, duration, energy와 같은 prosody attribution을 예측하기 위해 여러 predictor를 학습합니다. 2) variation-based (VB) TTS system은 variational auto-encoder (VAE) 또는 normalizing flow를 이용하여 latent space에서 prosody를 modeling합니다.

prosody prediction을 돕기 위해 풍부한 prior knowledge를 이용하여 더 나은 text presentation을 제공하는 연구들도 진행되고 있습니다. 예를 들어 graph network와 같은 전용 modeling 방법을 통해 syntax information을 통합하는 연구가 있습니다. text pre-training과 speech pre-training을 위한 representation learninig method들은 TTS의 prosody에 도움을 줍니다.

 

Representation Learning for TTS

self-supervised pre-training method는 TTS에서도 사용되었으며, 이를 통해 text processing 또는 speech generation capability를 향상시킬 수 있었습니다. 최근에는 pre-trained large masked language model (MLMs)를 이용해 web-scale text corpus로 학습된 풍부한 semantic information을 사용하는 연구들도 등장했습니다. 하지만 MLM을 사용하는 경우 text space에만 focus되어 있으며, model이 speech space에서 변동성이 높은 prosody pattern을 인식하지 못하기 때문에 expressive prosody를 modelling하는 것은 여전히 challenge입니다.

그 이후, ASR에 존재하는 speech representation learning에서 영감을 받은 여러 방법들이 등장했습니다. masked continuous speech feature를 이용하여 사전 정의된 clsuter assignment를 예측하는 연구가 있습니다. TTS에서는 ProsoSpeech라는 연구가 있는데, 해당 논문은 word-level vector quantization bottleneck을 design하여 speech로부터 discrete prosody representation을 추출하기도 합니다. Masked acoustic model (MAM)은 speech encoder가 continuous speech (prosody) representation을 생성하도록 학습시킵니다. 구체적으로 training할 때 speech spectrogram의 일부를 mask token으로 대체하고 masked spectrogram을 text condition 없이 recover하도록 학습합니다.

CLAPSpeech와 이전 representation TTS 연구들과의 차이점은 다음과 같습니다. 이전 연구들은 prosody information을 masked token reconstruction task로 암시적으로 학습시켰는데, CLAPSpeech는 cross-modal contrastive learning을 사용하여 context-correlated prosody를 명시적으로 학습하는 첫 연구이며, 이를 통해 더 나은 prosody prediction을 진행할 수 있고 더 효율적으로 model capacity를 사용할 수 있습니다.

 

CLAPSpeech

저자들은 CLAPSpeech를 제안하는데, 이는 cross-modal contrastive learning approach이며, TTS에서 prosody prediction을 위한 더 나은 text representation을 제공해 줍니다. CLAPSpeech는 text encoder와 prosody encoder를 사용하는데, training objective는 prosody space에서 text token과 speech segment를 connect하도록 만들어줍니다.

 

Text Encoder and Prosody Encoder

동일하게 발음될 수 있는 token의 prosody는 text context에 따라 다양합니다. CLAPSpeech는 text context와 high-level prosody pattern 사이의 correlation을 model하는 것을 목표로 합니다. 저자들은 text encoder와 prosody encoder를 design하여 text-speech multi-modal prosody embedding space를 construct합니다. 

 

위 그림의 (a)와 같이, text encoder는 phoneme과 input text의 byte pair encoding (BPE)를 input으로 사용합니다. phoneme과 BPE sequence는 model이 phonological habit (such as linking phenomenon in English)와 semantic information (서로 다른 감정을 암시하는)과 연관된 prosody pattern을 추출할 수 있도록 도움을 줍니다. text encoder의 network 구조는 여러 개의 Feed Forward Transformer (FFT)로 구성되는데, FFT는 TTS model이 long text sequence를 처리하는 데 robust하다는 것이 입증되었습니다. 구체적으로 저자들은 2개의 독립적인 FFT block을 학습하는데, 각 block은 phoneme sequence를 처리하거나 BPE sequence를 처리합니다. phoneme FFT block은 phonetic space에서 phonological habit을 model할 수 있으며 BPE FFT block은 semantic information을 추출할 수 있습니다. phoneme sequence와 BPE sequence의 길이가 맞지 않는 경우 융합하는 것이 어렵다는 문제가 존재합니다. 두 sequence를 시간 축에 따라 concatenate 하는 대신, 저자들은 word-level pooling (WP)를 사용하여 BPE encoding을 word level로 처리한 다음 phoneme level로 확장합니다.

 

구체적으로 위 그림의 (a)와 같이 Word Pooling (WP) operation은 각 단어에 있는 phoneme hidden state를 word boundary에 따라 평균을 구합니다. 그다음 word2ph operation은 각 word boundary에 있는 각 phoneme마다 반복적으로 word hidden state를 구합니다. 위 그림의 (b)와 같습니다.

phoneme sequence와 BPE sequence가 융합되면, 저자들은 additional FFT block을 사용하여 aligned phoneme과 BPE를 encoding하며, 최종 phoneme-level text encoding을 얻습니다. pre-training 과정에서 선택된 token만 분석되기 때문에, 저자들은 선택된 token의 encoding (Fig2 (a)에 있는 token encoding 부분)을 얻기 위해 phoneme-level text encoding을 index합니다. 그다음 multi-modal embedding space로 linear하게 project합니다. TTS 과정에서는 text encoder의 phoneme-level output은 TTS system의 보조 feature로 사용될 수 있습니다.

prosody encoder는 선택된 token의 GT speech segment로부터 prosody pattern을 추출하는 것을 목표로 합니다. 그러므로 저자들은 mel-spectrogram을 word boundary에 따라 clip한 다음 input speech feature로 사용합니다. prosody encoder는 input mel-spectrogram을 global encoding으로 처리하여 token encoding과 연결시킵니다. clipped speech segment는 선택된 token의 local prosody information만 포함하고 있으며 contextual information은 존재하지 않습니다.

contrastive learning setting이기 때문에, 추출된 global prosody encoding은 phonetic space와 speaker space로 나눠질 수 있습니다. 1) positive sample과 negative sample은 동일한 발음을 가진 token에 속하기 때문에, phonetic information (음성 정보)은 제거되게 됩니다. 2) speaker information은 text encoder에 제공되지 않기 때문에(저자들은 speaker와 text는 독립적이라고 가정), training 과정에서 prosody encoder는 output feature의 speaker information을 filtering하여 prosody information을 maximize합니다. context arware text encoding을 context unaware mel encoding으로 연결함으로써, prosody encoder는 speech segment로부터 high-level prosody information도 추출할 수 있도록 학습됩니다. text encoder는 text context를 이용하여 prosody encoder로부터 추출된 prosody를 predict하도로 학습됩니다. prosody encoder의 backbone으로 ResNet-50을 사용했는데, ResNet-50이 robustness하기 때문에 사용했다고 합니다. 저자들은 original version을 수정했다고 합니다. 1) mel-spectrogram을 더 잘 처리하기 위해, 저자들은 1D convolution과 normalization layer를 사용했다고 합니다. 2) 다양한 길이의 speech segment를 다루기 위해 저자들은 attentive pooling layer를 사용했으며, 이를 통해 ResNet의 output feature를 집계할 수 있었다고 합니다.

 

Multi-scale Contrastive Pre-training

CLAPSpeech의 key idea는 다른 context에 존재하는 동일한 text token의 prosody variance를 modeling하는 것입니다. 그러므로 contrastive pre-training을 위해 mini-batch를 구성해야 하며, 저자들은 random하게 text token을 고른 후 해당 token이 포함된 N개의 text-speech pair로 구성된 batch를 sample했습니다. 위 그림의 경우"higher"이라는 token을 선택한 예시입니다. phoneme과 word level에서 prosody variance를 더 잘 extract하기 위해, 저자들은 multi-scale contrastive training framework를 제안했습니다. 구체적으로 저자들은 2개 CLAPSpeech model을 사용하여 phoneme-lelvel에 대해, word-level에 대해 contrsative learning을 진행했습니다.

먼저 phoneme-level CLAPSpeech training 과정을 보겠습니다. 선택된 phoneme token ("AE0")를 포함하고 있는 text context를 X_text라 하겠습니다. phoneme token의 처리된 speech segment는 X_speech라 하겠습니다. X_speech ∈ R^(FxT)이고 F는 mel bin 수를 의미하고 T는 time bin을 의미합니다. 앞으로 X_text와 X_speech를 N개 text-speech pair의 batch로 표현하겠습니다. 

text와 speech는 text encoder f_text()와 prosody encoder f_speech()로 pass됩니다. text encoder의 output f_text(X_text)는 input text의 phoneme level encoding입니다. f_text(X_text)은 phoneme level encoding이므로, 이로부터 prosody token의 encoding f_text(X_text)i_ph를 얻기 위해 index합니다. 여기서 i_ph는 phoneme-level text sequence에 phoneme token의 index를 의미합니다. speech encoding의 output인 f_speech(X_speech)는 input speech segment의 global representation입니다. output representation은 normalize 된 후 multi-modal embedding space로 linear하게 투영됩니다. 식으로 나타내면 다음과 같습니다.

여기서 T_ph ∈ R^(NxC)는 phoneme token representation이고 S ∈ R^(NxC)는 speech representation입니다. 그리고 C는 channel size를 의미하고, LN은 layer normalization을 의미하며, L_text와 L_speech는 linear projection을 의미합니다.

text와 speech embedding은 비교 가능해지며 CLAPSpeech는 NxN text-speech pairing을 예측하도록 학습됩니다. 구체적으로, text encoder와 prosody encoder는 N개의 real text encoding과 speech encoding pair의 cosine similarity를 maximize하면서 N^2 - N개의 fake pair의 cosine similarity는 minimize하도록 학습됩니다. symmetric cross-entropy loss를 이용한 similarity score는 다음과 같습니다.

 

여기서 C_ph ∈ R^(NxN)은 phoneme token encoding T_ph와 speech encoding S 사이의 cosine similarity matrix을 의미합니다. 

word-level CLAPSpeech는 similarity를 가지고 학습될 수 있습니다. 저자들은 word-level CLAPSpeech를 위해, phoneme-level text를 word level로 encoding 하기 위해 word pooling을 진행하며, word token encoding T_word를 얻기 위해 index합니다. phoneme level CLAPSpeech와 유사하게 world-level CLAPSpeech의 loss는 다음과 같습니다.

 

여기서 C_word는 word token embedding T_word와 speech encoding S 사이의 cosine similarity matrix을 의미합니다.

 

CLAPSpeech Pulgged in TTS system

TTS task에서 CLAPSpeech의 text encoder는 rich prosody information을 담고 있는 text represenetation을 제공해야 합니다. 생성된 text representation은 phoneme level이며, 최근에 주로 사용되는 TTS model 또한 phoneme sequence를 text input으로 사용하고 있기 때문에 CLAPSpeech가 TTS system에 편하게 잘 적용될 수 있으며 prosody prediction 성능을 향상시켜 줄 수 있습니다. 구체적으로 저자들은 최신 variation-based TTS system인 PortaSpeech를 예시로 들었습니다. 

 

구조는 위와 같습니다. CLAPSpeech의 pre-trained text encoder (위 그림에서 빨간 점선 직사각형 부분)를 PortaSpeech의 original phonetic encoder의 보조 encoder로 사용했습니다. phonetic encoder의 phoneme level output과 CLAPSpeech text encoder의 phoneme level output은 혼합된 후에 encoder를 통해 처리됩니다. 

TTS system을 학습할 때는 CLAPSpeech text encoder의 parameter는 고정시켜 overfitting을 방지했다고 합니다. CLAPSpeech는 위와 같은 방법을 통해 다른 TTS system에 쉽게 적용될 수 있다고 합니다.

 

저자들은 다양한 실험을 진행했습니다.

 

Conclusion

이 논문에서는 CLAPSpeech라는 cross-modal contrastive pre-training framework를 제안합니다. 풍부한 prosody information을 담고 있는 text representation을 더 잘 제공해 줄 수 있으며, TTS에 사용될 수 있습니다. text encoder와 prosody encoder를 design하여 CLAPSpeech는 text context와 그에 대응하는 prosody pattern을 연결시키도록 학습되었습니다. 또한 저자들은 multi-scale pre-training 을 제안하며, 이를 통해 여러 level에서 prosody pattern을 추출할 수 있다고 합니다. 3가지 TTS dataset에서 CLAPSpeech의 performance와 일반화 성능을 입증했습니다. 

하지만 이 논문에서는 current-sentence text와 context-related prosody만 고려합니다. 앞으로는 inter-sentence prosody에 대한 발전을 기대한다고 합니다. 그리고 contrastive pre-training 과정에서 다른 variable에 대한 고려는 불가능합니다. 오직 prosody에 대한 pre-train만 가능하며, 앞으로는 prosody를 speaker, emotion과 같은 다른 variable과 connect 할 예정이라 합니다.