這是官方代碼實施? Matcha-TTS [ICASSP 2024]。
我們建議? Matcha-TTS是一種非自動回憶神經TTS的新方法,它使用條件流量匹配(類似於整流流)來加快基於ODE的語音綜合。我們的方法:
查看我們的演示頁面,並閱讀我們的ICASSP 2024紙,以獲取更多詳細信息。
預訓練的模型將自動下載使用CLI或Gradio接口。
你也可以嘗試嗎?在瀏覽器中,抹茶在擁抱面上?空間。
conda create -n matcha-tts python=3.10 -y
conda activate matcha-tts
pip install matcha-tts來自來源
pip install git+https://github.com/shivammehta25/Matcha-TTS.git
cd Matcha-TTS
pip install -e . # This will download the required models
matcha-tts --text " <INPUT TEXT> "或者
matcha-tts-app或打開synthesis.ipynb在jupyter筆記本上
matcha-tts --text " <INPUT TEXT> "matcha-tts --file < PATH TO FILE >matcha-tts --file < PATH TO FILE > --batched其他參數
matcha-tts --text " <INPUT TEXT> " --speaking_rate 1.0matcha-tts --text " <INPUT TEXT> " --temperature 0.667matcha-tts --text " <INPUT TEXT> " --steps 10假設我們正在接受LJ演講的培訓
從這裡下載數據集,將其提取到data/LJSpeech-1.1 ,然後準備文件列表以指向提取的數據,例如NVIDIA TACOTRON 2 REPO的設置中的項目5。
克隆並輸入Matcha-TTS存儲庫
git clone https://github.com/shivammehta25/Matcha-TTS.git
cd Matcha-TTSpip install -e .configs/data/ljspeech.yaml並更改 train_filelist_path : data/filelists/ljs_audio_text_train_filelist.txt
valid_filelist_path : data/filelists/ljs_audio_text_val_filelist.txtmatcha-data-stats -i ljspeech.yaml
# Output:
#{ ' mel_mean ' : -5.53662231756592, ' mel_std ' : 2.1161014277038574}在data_statistics密鑰下,在configs/data/ljspeech.yaml中更新這些值。
data_statistics: # Computed for ljspeech dataset
mel_mean: -5.536622
mel_std: 2.116101到您的火車和驗證材料的道路。
make train-ljspeech或者
python matcha/train.py experiment=ljspeechpython matcha/train.py experiment=ljspeech_min_memorypython matcha/train.py experiment=ljspeech trainer.devices=[0,1]matcha-tts --text " <INPUT TEXT> " --checkpoint_path < PATH TO CHECKPOINT > 特別感謝 @Mush42實現ONNX導出和推理支持。
可以將Matcha檢查點導出到ONNX,並在導出的ONNX圖上運行推斷。
要將檢查站導出到ONNX,請首先安裝onnx
pip install onnx然後運行以下內容:
python3 -m matcha.onnx.export matcha.ckpt model.onnx --n-timesteps 5可選地,ONNX出口商接受Vocoder-Name和Vocoder-Checkpoint參數。這使您可以將Vocoder嵌入導出的圖表中,並在單個運行中生成波形(類似於端到端TTS系統)。
請注意, n_timesteps被視為高參數,而不是模型輸入。這意味著您應該在導出期間(而不是在推理期間)指定它。如果未指定,則將n_timesteps設置為5 。
重要:目前,導出需要火炬> = 2.1.0,因為scaled_product_attention oterator在較舊版本中不可導出。在發布最終版本之前,那些想要導出模型的人必須安裝TORCH> = 2.1.0作為預釋放。
要在導出的模型上進行推斷, onnxruntime首先使用
pip install onnxruntime
pip install onnxruntime-gpu # for GPU inference然後使用以下內容:
python3 -m matcha.onnx.infer model.onnx --text " hey " --output-dir ./outputs您還可以控制合成參數:
python3 -m matcha.onnx.infer model.onnx --text " hey " --output-dir ./outputs --temperature 0.4 --speaking_rate 0.9 --spk 0要在GPU上運行推斷,請確保安裝OnnxRuntime-GPU軟件包,然後將--gpu傳遞到推理命令:
python3 -m matcha.onnx.infer model.onnx --text " hey " --output-dir ./outputs --gpu如果您僅導出抹茶到ONNX,則將MEL-SPECTROGRAM和numpy數組寫入輸出目錄。如果將VOCODER嵌入導出圖中,則將.wav音頻文件寫入輸出目錄。
如果您僅導出抹茶到ONNX,並且要運行完整的TTS管道,則可以以ONNX格式通往Vocoder模型的路徑:
python3 -m matcha.onnx.infer model.onnx --text " hey " --output-dir ./outputs --vocoder hifigan.small.onnx這將將.wav音頻文件寫入輸出目錄。
如果數據集的結構為
data/
└── LJSpeech-1.1
├── metadata.csv
├── README
├── test.txt
├── train.txt
├── val.txt
└── wavs然後,您可以使用:
python matcha/utils/get_durations_from_trained_model.py -i dataset_yaml -c < checkpoint >例子:
python matcha/utils/get_durations_from_trained_model.py -i ljspeech.yaml -c matcha_ljspeech.ckpt或簡單:
matcha-tts-get-durations -i ljspeech.yaml -c matcha_ljspeech.ckpt在DataSetConfig中,打開加載持續時間。示例: ljspeech.yaml
load_durations: True
或查看configs/lassiment/ljspeech_from_durations.yaml中的示例
如果您使用我們的代碼或以其他方式覺得這項工作有用,請引用我們的論文:
@inproceedings{mehta2024matcha,
title={Matcha-{TTS}: A fast {TTS} architecture with conditional flow matching},
author={Mehta, Shivam and Tu, Ruibo and Beskow, Jonas and Sz{'e}kely, {'E}va and Henter, Gustav Eje},
booktitle={Proc. ICASSP},
year={2024}
}
由於此代碼使用Lightning-Hydra-Template,因此您擁有所有功能。
我們要確認的其他源代碼: