Text-to-Speech
Fairseq
English
audio
Changhan commited on
Commit
1b56ecc
1 Parent(s): d672711

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -25
README.md CHANGED
@@ -9,40 +9,59 @@ language: en
9
  datasets:
10
  - ljspeech
11
  ---
12
- ## Example to download TTS Transformer from fairseq
13
 
14
- The following should work with fairseq's most up-to-date version in a google colab:
 
 
 
 
 
15
 
16
  ```python
17
  from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
 
18
  import IPython.display as ipd
19
- import torch
20
 
21
- model_ensemble, cfg, task = load_model_ensemble_and_task_from_hf_hub(
22
- "facebook/tts_transformer-en-ljspeech", arg_overrides={"vocoder": "griffin_lim", "fp16": False}
 
 
23
  )
 
 
 
24
 
25
- def tokenize(text):
26
- import g2p_en
27
- tokenized = g2p_en.G2p()(text)
28
- tokenized = [{",": "sp", ";": "sp"}.get(p, p) for p in tokenized]
29
- return " ".join(p for p in tokenized if p.isalnum())
30
-
31
  text = "Hello, this is a test run."
32
 
33
- tokenized = tokenize(text)
34
- sample = {
35
- "net_input": {
36
- "src_tokens": task.src_dict.encode_line(tokenized).view(1, -1),
37
- "src_lengths": torch.Tensor([len(tokenized.split())]).long(),
38
- "prev_output_tokens": None
39
- },
40
- "target_lengths": None,
41
- "speaker": None,
42
- }
43
- generator = task.build_generator(model_ensemble, cfg)
44
- generation = generator.generate(model_ensemble[0], sample)
45
- waveform = generation[0]["waveform"]
46
 
47
- ipd.Audio(waveform, rate=task.sr)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  ```
 
9
  datasets:
10
  - ljspeech
11
  ---
12
+ # tts_transformer-en-ljspeech
13
 
14
+ [Transformer](https://arxiv.org/abs/1809.08895) text-to-speech model from [fairseq S^2](https://github.com/pytorch/fairseq/tree/main/examples/speech_synthesis):
15
+ - English
16
+ - Single-speaker female voice
17
+ - Trained on [LJSpeech](https://keithito.com/LJ-Speech-Dataset/)
18
+
19
+ ## Usage
20
 
21
  ```python
22
  from fairseq.checkpoint_utils import load_model_ensemble_and_task_from_hf_hub
23
+ from fairseq.models.text_to_speech.hub_interface import TTSHubInterface
24
  import IPython.display as ipd
 
25
 
26
+
27
+ models, cfg, task = load_model_ensemble_and_task_from_hf_hub(
28
+ "facebook/tts_transformer-en-ljspeech",
29
+ arg_overrides={"vocoder": "hifigan", "fp16": False}
30
  )
31
+ model = models[0]
32
+ TTSHubInterface.update_cfg_with_data_cfg(cfg, task.data_cfg)
33
+ generator = task.build_generator(model, cfg)
34
 
 
 
 
 
 
 
35
  text = "Hello, this is a test run."
36
 
37
+ sample = TTSHubInterface.get_model_input(task, text)
38
+ wav, rate = TTSHubInterface.get_prediction(task, model, generator, sample)
39
+
40
+ ipd.Audio(wav, rate=rate)
41
+ ```
42
+
43
+ See also [fairseq S^2 example](https://github.com/pytorch/fairseq/blob/main/examples/speech_synthesis/docs/ljspeech_example.md).
 
 
 
 
 
 
44
 
45
+ ## Citation
46
+
47
+ ```bibtex
48
+ @inproceedings{wang-etal-2021-fairseq,
49
+ title = "fairseq S{\^{}}2: A Scalable and Integrable Speech Synthesis Toolkit",
50
+ author = "Wang, Changhan and
51
+ Hsu, Wei-Ning and
52
+ Adi, Yossi and
53
+ Polyak, Adam and
54
+ Lee, Ann and
55
+ Chen, Peng-Jen and
56
+ Gu, Jiatao and
57
+ Pino, Juan",
58
+ booktitle = "Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing: System Demonstrations",
59
+ month = nov,
60
+ year = "2021",
61
+ address = "Online and Punta Cana, Dominican Republic",
62
+ publisher = "Association for Computational Linguistics",
63
+ url = "https://aclanthology.org/2021.emnlp-demo.17",
64
+ doi = "10.18653/v1/2021.emnlp-demo.17",
65
+ pages = "143--152",
66
+ }
67
  ```