Views
No views yet
1from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
2from fairseq.models.text_to_speech.hub_interface import S2THubInterface
3from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
4import IPython.display as ipd
5import torchaudio
6
7
8models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
9 "facebook/xm_transformer_600m-es_en-multi_domain",
10 arg_overrides={"config_yaml": "config.yaml"},
11)
12model = models[0]
13generator = task.build_generator(model, cfg)
14
15
16# requires 16000Hz mono channel audio
17audio, _ = torchaudio.load("/path/to/an/audio/file")
18
19sample = S2THubInterface.get_model_input(task, audio)
20text = S2THubInterface.get_prediction(task, model, generator, sample)
21
22# speech synthesis
23tts_models, tts_cfg, tts_task = load_model_ensemble_and_task_from_hf_hub(
24 f"facebook/fastspeech2-en-ljspeech",
25 arg_overrides={"vocoder": "griffin_lim", "fp16": False},
26)
27tts_model = tts_models[0]
28TTSHubInterface.update_cfg_with_data_cfg(tts_cfg, tts_task.data_cfg)
29tts_generator = tts_task.build_generator([tts_model], tts_cfg)
30
31tts_sample = TTSHubInterface.get_model_input(tts_task, text)
32wav, sr = TTSHubInterface.get_prediction(
33 tts_task, tts_model, tts_generator, tts_sample
34)
35
36ipd.Audio(wav, rate=rate)1@inproceedings{li-etal-2021-multilingual,
2 title = "Multilingual Speech Translation from Efficient Finetuning of Pretrained Models",
3 author = "Li, Xian and
4 Wang, Changhan and
5 Tang, Yun and
6 Tran, Chau and
7 Tang, Yuqing and
8 Pino, Juan and
9 Baevski, Alexei and
10 Conneau, Alexis and
11 Auli, Michael",
12 booktitle = "Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers)",
13 month = aug,
14 year = "2021",
15 address = "Online",
16 publisher = "Association for Computational Linguistics",
17 url = "https://aclanthology.org/2021.acl-long.68",
18 doi = "10.18653/v1/2021.acl-long.68",
19 pages = "827--838",
20}
21
22@inproceedings{wang-etal-2020-fairseq,
23 title = "Fairseq {S}2{T}: Fast Speech-to-Text Modeling with Fairseq",
24 author = "Wang, Changhan and
25 Tang, Yun and
26 Ma, Xutai and
27 Wu, Anne and
28 Okhonko, Dmytro and
29 Pino, Juan",
30 booktitle = "Proceedings of the 1st Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 10th International Joint Conference on Natural Language Processing: System Demonstrations",
31 month = dec,
32 year = "2020",
33 address = "Suzhou, China",
34 publisher = "Association for Computational Linguistics",
35 url = "https://aclanthology.org/2020.aacl-demo.6",
36 pages = "33--39",
37}
38
39@inproceedings{wang-etal-2021-fairseq,
40 title = "fairseq S{\^{}}2: A Scalable and Integrable Speech Synthesis Toolkit",
41 author = "Wang, Changhan and
42 Hsu, Wei-Ning and
43 Adi, Yossi and
44 Polyak, Adam and
45 Lee, Ann and
46 Chen, Peng-Jen and
47 Gu, Jiatao and
48 Pino, Juan",
49 booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing: System Demonstrations",
50 month = nov,
51 year = "2021",
52 address = "Online and Punta Cana, Dominican Republic",
53 publisher = "Association for Computational Linguistics",
54 url = "https://aclanthology.org/2021.emnlp-demo.17",
55 doi = "10.18653/v1/2021.emnlp-demo.17",
56 pages = "143--152",
57}