Update README.md
Browse files
README.md
CHANGED
@@ -1,46 +1,78 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
```
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
```
|
|
|
|
1 |
+
# Vocoder with HiFIGAN trained on LJSpeech
|
2 |
+
|
3 |
+
This repository provides all the necessary tools for using a [HiFIGAN](https://arxiv.org/abs/2010.05646) vocoder trained with [LJSpeech](https://keithito.com/LJ-Speech-Dataset/).
|
4 |
+
|
5 |
+
The pre-trained model takes in input a spectrogram and produces a waveform in output. Typically, a vocoder is used after a TTS model that converts an input text into a spectrogram.
|
6 |
+
|
7 |
+
|
8 |
+
## Install SpeechBrain
|
9 |
+
|
10 |
+
First of all, currently, you need to install SpeechBrain from the source:
|
11 |
+
|
12 |
+
1. Clone SpeechBrain:
|
13 |
+
|
14 |
+
```bash
|
15 |
+
git clone https://github.com/speechbrain/speechbrain/
|
16 |
+
```
|
17 |
+
|
18 |
+
2. Install it:
|
19 |
+
|
20 |
+
```
|
21 |
+
cd speechbrain
|
22 |
+
pip install -r requirements.txt
|
23 |
+
pip install -e .
|
24 |
+
```
|
25 |
+
|
26 |
+
Please notice that we encourage you to read our tutorials and learn more about
|
27 |
+
[SpeechBrain](https://speechbrain.github.io).
|
28 |
+
|
29 |
+
### Using the Vocoder
|
30 |
+
|
31 |
+
```
|
32 |
+
from speechbrain.pretrained import HIFIGAN
|
33 |
+
hifi_gan = HIFIGAN.from_hparams(source="speechbrain/Vocoder_HiFIGAN", savedir="tmpdir")
|
34 |
+
mel_specs = torch.rand(2, 80,298)
|
35 |
+
waveforms = hifi_gan.decode_batch(mel_specs)
|
36 |
+
```
|
37 |
+
### Using the Vocoder with the TTS
|
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="speechbrain/TTS_Tacotron2", savedir="tmpdir_tts")
|
45 |
+
hifi_gan = HIFIGAN.from_hparams(source="speechbrain/Vocoder_HiFIGAN", savedir="tmpdir_vocoder")
|
46 |
+
|
47 |
+
# Running the TTS
|
48 |
+
mel_output, mel_length, alignment = tacotron2.encode_text("Mary had a little lamb")
|
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 |
+
### Inference on GPU
|
58 |
+
To perform inference on the GPU, add `run_opts={"device":"cuda"}` when calling the `from_hparams` method.
|
59 |
+
|
60 |
+
### Training
|
61 |
+
The model was trained with SpeechBrain.
|
62 |
+
To train it from scratch follow these steps:
|
63 |
+
1. Clone SpeechBrain:
|
64 |
+
```bash
|
65 |
+
git clone https://github.com/speechbrain/speechbrain/
|
66 |
+
```
|
67 |
+
2. Install it:
|
68 |
+
```bash
|
69 |
+
cd speechbrain
|
70 |
+
pip install -r requirements.txt
|
71 |
+
pip install -e .
|
72 |
+
```
|
73 |
+
3. Run Training:
|
74 |
+
```bash
|
75 |
+
cd recipes/LJSpeech/TTS/vocoder/hifi_gan/
|
76 |
+
python train.py hparams/train.yaml --data_folder /path/to/LJspeech
|
77 |
```
|
78 |
+
You can find our training results (models, logs, etc) [here](https://drive.google.com/drive/folders/19sLwV7nAsnUuLkoTu5vafURA9Fo2WZgG?usp=sharing).
|