Views
No views yet

This is the official code implementation of 🍵 Matcha-TTS [ICASSP 2024].
conda create -n matcha-tts python=3.10 -y
conda activate matcha-ttspip install matcha-tts1pip install git+https://github.com/shivammehta25/Matcha-TTS.git
2cd Matcha-TTS
3pip install -e .1# This will download the required models
2matcha-tts --text "<INPUT TEXT>"matcha-tts-appsynthesis.ipynb on jupyter notebookmatcha-tts --text "<INPUT TEXT>"matcha-tts --file <PATH TO FILE>matcha-tts --file <PATH TO FILE> --batchedmatcha-tts --text "<INPUT TEXT>" --speaking_rate 1.0matcha-tts --text "<INPUT TEXT>" --temperature 0.667matcha-tts --text "<INPUT TEXT>" --steps 10data/LJSpeech-1.1, and prepare the file lists to point to the extracted data like for item 5 in the setup of the NVIDIA Tacotron 2 repo.1git clone https://github.com/shivammehta25/Matcha-TTS.git
2cd Matcha-TTSpip install -e .configs/data/ljspeech.yaml and change1train_filelist_path: data/filelists/ljs_audio_text_train_filelist.txt
2valid_filelist_path: data/filelists/ljs_audio_text_val_filelist.txt1matcha-data-stats -i ljspeech.yaml
2# Output:
3#{'mel_mean': -5.53662231756592, 'mel_std': 2.1161014277038574}configs/data/ljspeech.yaml under data_statistics key.1data_statistics: # Computed for ljspeech dataset
2 mel_mean: -5.536622
3 mel_std: 2.116101make train-ljspeechpython 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>Special thanks to @mush42 for implementing ONNX export and inference support.
pip install onnxpython3 -m matcha.onnx.export matcha.ckpt model.onnx --n-timesteps 5n_timesteps is treated as a hyper-parameter rather than a model input. This means you should specify it during export (not during inference). If not specified, n_timesteps is set to 5.scaled_product_attention operator is not exportable in older versions. Until the final version is released, those who want to export their models must install torch>=2.1.0 manually as a pre-release.onnxruntime using1pip install onnxruntime
2pip install onnxruntime-gpu # for GPU inferencepython3 -m matcha.onnx.infer model.onnx --text "hey" --output-dir ./outputspython3 -m matcha.onnx.infer model.onnx --text "hey" --output-dir ./outputs --temperature 0.4 --speaking_rate 0.9 --spk 0--gpu to the inference command:python3 -m matcha.onnx.infer model.onnx --text "hey" --output-dir ./outputs --gpunumpy arrays to the output directory.
If you embedded the vocoder in the exported graph, this will write .wav audio files to the output directory.ONNX format:python3 -m matcha.onnx.infer model.onnx --text "hey" --output-dir ./outputs --vocoder hifigan.small.onnx.wav audio files to the output directory.1data/
2└── LJSpeech-1.1
3 ├── metadata.csv
4 ├── README
5 ├── test.txt
6 ├── train.txt
7 ├── val.txt
8 └── wavspython 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.ckptmatcha-tts-get-durations -i ljspeech.yaml -c matcha_ljspeech.ckptljspeech.yamlload_durations: True1@inproceedings{mehta2024matcha,
2 title={Matcha-{TTS}: A fast {TTS} architecture with conditional flow matching},
3 author={Mehta, Shivam and Tu, Ruibo and Beskow, Jonas and Sz{\'e}kely, {\'E}va and Henter, Gustav Eje},
4 booktitle={Proc. ICASSP},
5 year={2024}
6}