Text-to-Speech
speechbrain
Swahili
TTS
speech-synthesis
Tacotron2
nairaxo commited on
Commit
da1fd38
1 Parent(s): 8637091

Create new file

Browse files
Files changed (1) hide show
  1. README.md +116 -0
README.md ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: "sw"
3
+ tags:
4
+ - text-to-speech
5
+ - TTS
6
+ - speech-synthesis
7
+ - Tacotron2
8
+ - speechbrain
9
+ license: "apache-2.0"
10
+ datasets:
11
+ - LJSpeech
12
+ metrics:
13
+ - mos
14
+ ---
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
+
20
+ # Text-to-Speech (TTS) with Tacotron2 trained on LJSpeech
21
+
22
+ 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/).
23
+
24
+ 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.
25
+
26
+
27
+ ## Install SpeechBrain
28
+
29
+ ```
30
+ pip install speechbrain
31
+ ```
32
+
33
+ Please notice that we encourage you to read our tutorials and learn more about
34
+ [SpeechBrain](https://speechbrain.github.io).
35
+
36
+ ### Perform Text-to-Speech (TTS)
37
+
38
+ ```
39
+ import torchaudio
40
+ from speechbrain.pretrained import Tacotron2
41
+ from speechbrain.pretrained import HIFIGAN
42
+
43
+ # Intialize TTS (tacotron2) and Vocoder (HiFIGAN)
44
+ tacotron2 = Tacotron2.from_hparams(source="nairaxo/tacotron-swahili", savedir="tmpdir_tts")
45
+ hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="tmpdir_vocoder")
46
+
47
+ # Running the TTS
48
+ mel_output, mel_length, alignment = tacotron2.encode_text("Hakuna matata")
49
+
50
+ # Running Vocoder (spectrogram-to-waveform)
51
+ waveforms = hifi_gan.decode_batch(mel_output)
52
+
53
+ # Save the waverform
54
+ torchaudio.save('example_TTS.wav',waveforms.squeeze(1), 22050)
55
+ ```
56
+
57
+ If you want to generate multiple sentences in one-shot, you can do in this way:
58
+
59
+ ```
60
+ from speechbrain.pretrained import Tacotron2
61
+ tacotron2 = Tacotron2.from_hparams(source="speechbrain/TTS_Tacotron2", savedir="tmpdir")
62
+ items = [
63
+ "A quick brown fox jumped over the lazy dog",
64
+ "How much wood would a woodchuck chuck?",
65
+ "Never odd or even"
66
+ ]
67
+ mel_outputs, mel_lengths, alignments = tacotron2.encode_batch(items)
68
+
69
+ ```
70
+
71
+ ### Inference on GPU
72
+ To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
73
+
74
+ ### Training
75
+ The model was trained with SpeechBrain.
76
+ To train it from scratch follow these steps:
77
+ 1. Clone SpeechBrain:
78
+ ```bash
79
+ git clone https://github.com/speechbrain/speechbrain/
80
+ ```
81
+ 2. Install it:
82
+ ```bash
83
+ cd speechbrain
84
+ pip install -r requirements.txt
85
+ pip install -e .
86
+ ```
87
+ 3. Run Training:
88
+ ```bash
89
+ cd recipes/LJSpeech/TTS/tacotron2/
90
+ python train.py --device=cuda:0 --max_grad_norm=1.0 --data_folder=/your_folder/LJSpeech-1.1 hparams/train.yaml
91
+ ```
92
+ You can find our training results (models, logs, etc) [here](https://drive.google.com/drive/folders/1PKju-_Nal3DQqd-n0PsaHK-bVIOlbf26?usp=sharing).
93
+
94
+ ### Limitations
95
+ The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.
96
+
97
+ # **About SpeechBrain**
98
+ - Website: https://speechbrain.github.io/
99
+ - Code: https://github.com/speechbrain/speechbrain/
100
+ - HuggingFace: https://huggingface.co/speechbrain/
101
+
102
+
103
+ # **Citing SpeechBrain**
104
+ Please, cite SpeechBrain if you use it for your research or business.
105
+
106
+ ```bibtex
107
+ @misc{speechbrain,
108
+ title={{SpeechBrain}: A General-Purpose Speech Toolkit},
109
+ 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},
110
+ year={2021},
111
+ eprint={2106.04624},
112
+ archivePrefix={arXiv},
113
+ primaryClass={eess.AS},
114
+ note={arXiv:2106.04624}
115
+ }
116
+ ```