Views
No views yet
pip install espnet espnet_model_zoo parallel_wavegan typeguard==2.13.3 scipy==1.11.41import torch
2import soundfile as sf
3import yaml
4import zipfile
5import os
6from huggingface_hub import hf_hub_download
7from espnet2.bin.tts_inference import Text2Speech
8from IPython.display import Audio, display
9
10# 1. Download artifacts
11repo_id = "Professor/kinyarwanda-tacotron2-espnet"
12model_zip = hf_hub_download(repo_id=repo_id, filename="model.zip")
13config_path = hf_hub_download(repo_id=repo_id, filename="config.yaml")
14stats_path = hf_hub_download(repo_id=repo_id, filename="feats_stats.npz")
15
16# 2. Extract weights
17with zipfile.ZipFile(model_zip, 'r') as zip_ref:
18 zip_ref.extractall("model_weights")
19
20# Search for the .pth file (since names can vary)
21pth_file = None
22for root, dirs, files in os.walk("model_weights"):
23 for file in files:
24 if file.endswith(".pth"):
25 pth_file = os.path.join(root, file)
26 break
27
28# 3. Patch config
29with open(config_path, 'r') as f:
30 config = yaml.safe_load(f)
31config['normalize_conf']['stats_file'] = stats_path
32with open("config_patched.yaml", 'w') as f:
33 yaml.dump(config, f)
34
35# 4. Initialize
36text2speech = Text2Speech.from_pretrained(
37 model_file=pth_file,
38 train_config="config_patched.yaml",
39 vocoder_tag="parallel_wavegan/ljspeech_parallel_wavegan.v1",
40 device="cuda" if torch.cuda.is_available() else "cpu"
41)
42
43# 5. Synthesize
44text = "Muraho neza, amakuru yanyu? Kinyarwanda ni ururimi rwiza cyane."
45with torch.no_grad():
46 output = text2speech(text)
47 wav = output["wav"].cpu().numpy()
48
49sf.write("output.wav", wav, text2speech.fs)
50
51# 6. Show
52print(f"✅ Synthesis complete: output.wav")
53display(Audio("output.wav", autoplay=True))| Metric | Value | Model Used for Evaluation |
|---|---|---|
| UTMOSv2 | 2.2103 | Average of 400 test samples |
| WER | 46.64% | jq/whisper-large-v3-kin-track-b |
| CER | 12.5% | jq/whisper-large-v3-kin-track-b |
1@inproceedings{watanabe2018espnet,
2 author={Shinji Watanabe and Takaaki Hori and Shigeki Karita and Tomoki Hayashi and Jiro Nishitoba and Yuya Unno and Nelson Yalta and Jahn Heymann and Matthew Wiesner and Nanxin Chen and Adithya Renduchintala and Tsubasa Ochiai},
3 title={{ESPnet}: End-to-End Speech Processing Toolkit},
4 year={2018},
5 booktitle={Proceedings of Interspeech},
6 pages={2207--2211},
7 doi={10.21437/Interspeech.2018-1456},
8 url={http://dx.doi.org/10.21437/Interspeech.2018-1456}
9}
10@inproceedings{hayashi2020espnet,
11 title={{Espnet-TTS}: Unified, reproducible, and integratable open source end-to-end text-to-speech toolkit},
12 author={Hayashi, Tomoki and Yamamoto, Ryuichi and Inoue, Katsuki and Yoshimura, Takenori and Watanabe, Shinji and Toda, Tomoki and Takeda, Kazuya and Zhang, Yu and Tan, Xu},
13 booktitle={Proceedings of IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP)},
14 pages={7654--7658},
15 year={2020},
16 organization={IEEE}
17}1@misc{watanabe2018espnet,
2 title={ESPnet: End-to-End Speech Processing Toolkit},
3 author={Shinji Watanabe and Takaaki Hori and Shigeki Karita and Tomoki Hayashi and Jiro Nishitoba and Yuya Unno and Nelson Yalta and Jahn Heymann and Matthew Wiesner and Nanxin Chen and Adithya Renduchintala and Tsubasa Ochiai},
4 year={2018},
5 eprint={1804.00015},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}