Krisshvamsi commited on
Commit
7e4dbc8
1 Parent(s): aee8d40

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +96 -1
README.md CHANGED
@@ -14,4 +14,99 @@ metrics:
14
  pipeline_tag: text-to-speech
15
  ---
16
  <iframe src="https://ghbtns.com/github-btn.html?user=speechbrain&repo=speechbrain&type=star&count=true&size=large&v=2" frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe>
17
- <br/><br/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  pipeline_tag: text-to-speech
15
  ---
16
  <iframe src="https://ghbtns.com/github-btn.html?user=speechbrain&repo=speechbrain&type=star&count=true&size=large&v=2" frameborder="0" scrolling="0" width="170" height="30" title="GitHub"></iframe>
17
+ <br/><br/>
18
+
19
+ # Text-to-Speech (TTS) with Transformer trained on LJSpeech
20
+
21
+ This repository provides all the necessary tools for Text-to-Speech (TTS) with SpeechBrain using a [Tacotron2](https://arxiv.org/abs/1712.05884) pretrained on [LJSpeech](https://keithito.com/LJ-Speech-Dataset/).
22
+
23
+ The pre-trained model takes in input a short text and produces a spectrogram in output. One can get the final waveform by applying a vocoder (e.g., HiFIGAN) on top of the generated spectrogram.
24
+
25
+
26
+ ## Install SpeechBrain
27
+
28
+ ```
29
+ pip install speechbrain
30
+ ```
31
+ ### Perform Text-to-Speech (TTS)
32
+
33
+ ```python
34
+ import torchaudio
35
+ from speechbrain.inference.TTS import Tacotron2
36
+ from speechbrain.inference.vocoders import HIFIGAN
37
+
38
+ # Intialize TTS (tacotron2) and Vocoder (HiFIGAN)
39
+ tacotron2 = Tacotron2.from_hparams(source="speechbrain/tts-tacotron2-ljspeech", savedir="tmpdir_tts")
40
+ hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="tmpdir_vocoder")
41
+
42
+ # Running the TTS
43
+ mel_output, mel_length, alignment = tacotron2.encode_text("Mary had a little lamb")
44
+
45
+ # Running Vocoder (spectrogram-to-waveform)
46
+ waveforms = hifi_gan.decode_batch(mel_output)
47
+
48
+ # Save the waverform
49
+ torchaudio.save('example_TTS.wav',waveforms.squeeze(1), 22050)
50
+ ```
51
+
52
+ If you want to generate multiple sentences in one-shot, you can do in this way:
53
+
54
+ ```
55
+ from speechbrain.pretrained import Tacotron2
56
+ tacotron2 = Tacotron2.from_hparams(source="speechbrain/TTS_Tacotron2", savedir="tmpdir")
57
+ items = [
58
+ "A quick brown fox jumped over the lazy dog",
59
+ "How much wood would a woodchuck chuck?",
60
+ "Never odd or even"
61
+ ]
62
+ mel_outputs, mel_lengths, alignments = tacotron2.encode_batch(items)
63
+
64
+ ```
65
+
66
+ ### Inference on GPU
67
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
68
+
69
+
70
+ ### Training
71
+ The model was trained with SpeechBrain.
72
+ To train it from scratch follow these steps:
73
+ 1. Clone SpeechBrain:
74
+ ```bash
75
+ git clone https://github.com/speechbrain/speechbrain/
76
+ ```
77
+ 2. Install it:
78
+ ```bash
79
+ cd speechbrain
80
+ pip install -r requirements.txt
81
+ pip install -e .
82
+ ```
83
+ 3. Run Training:
84
+ ```bash
85
+ cd recipes/LJSpeech/TTS/tacotron2/
86
+ python train.py --device=cuda:0 --max_grad_norm=1.0 --data_folder=/your_folder/LJSpeech-1.1 hparams/train.yaml
87
+ ```
88
+
89
+
90
+ ### Limitations
91
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
92
+
93
+ # **About SpeechBrain**
94
+ - Website: https://speechbrain.github.io/
95
+ - Code: https://github.com/speechbrain/speechbrain/
96
+ - HuggingFace: https://huggingface.co/speechbrain/
97
+
98
+
99
+ # **Citing SpeechBrain**
100
+ Please, cite SpeechBrain if you use it for your research or business.
101
+
102
+ ```bibtex
103
+ @misc{speechbrain,
104
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
105
+ author={Mirco Ravanelli and Titouan Parcollet and Peter Plantinga and Aku Rouhe and Samuele Cornell and Loren Lugosch and Cem Subakan and Nauman Dawalatabad and Abdelwahab Heba and Jianyuan Zhong and Ju-Chieh Chou and Sung-Lin Yeh and Szu-Wei Fu and Chien-Feng Liao and Elena Rastorgueva and François Grondin and William Aris and Hwidong Na and Yan Gao and Renato De Mori and Yoshua Bengio},
106
+ year={2021},
107
+ eprint={2106.04624},
108
+ archivePrefix={arXiv},
109
+ primaryClass={eess.AS},
110
+ note={arXiv:2106.04624}
111
+ }
112
+ ```