upload model
Browse files- .gitattributes +1 -0
- README.md +114 -1
- config.json +5 -0
- hyperparams.yaml +120 -0
- lexicon +1 -0
- model.ckpt +3 -0
.gitattributes
CHANGED
@@ -32,3 +32,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
32 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
33 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
34 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
35 |
+
model.ckpt filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,116 @@
|
|
1 |
---
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
language: "en"
|
3 |
+
tags:
|
4 |
+
- text-to-speech
|
5 |
+
- TTS
|
6 |
+
- speech-synthesis
|
7 |
+
- fastspeech2
|
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 Fastspeech2 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) with Fastspeech2
|
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 |
+
fastspeech2 = Tacotron2.from_hparams(source="speechbrain/tts-fastspeech2-ljspeech", 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 = fastspeech2.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 |
+
If you want to generate multiple sentences in one-shot, you can do in this way:
|
58 |
+
|
59 |
+
```
|
60 |
+
from speechbrain.pretrained import fastspeech2
|
61 |
+
tacotron2 = Tacotron2.from_hparams(source="speechbrain/TTS_fastspeech2", 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/fastspeech2/
|
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/1Yb8CDCrW7JF1_jg8Xc4U15z3W37VjrY5?usp=share_link).
|
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 |
+
```
|
config.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"speechbrain_interface": "Tacotron2",
|
3 |
+
"vocoder_interface": "HiFIGAN",
|
4 |
+
"vocoder_model_id": "speechbrain/tts-hifigan-ljspeech"
|
5 |
+
}
|
hyperparams.yaml
ADDED
@@ -0,0 +1,120 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ################################
|
2 |
+
# Model: Fastspeech2 for TTS
|
3 |
+
# Authors: Sathvik Udupa, Yingzhi Wang
|
4 |
+
# ################################
|
5 |
+
n_symbols: 62 #fixed deppending on symbols in textToSequence
|
6 |
+
n_mel_channels: 80
|
7 |
+
padding_idx: 0
|
8 |
+
|
9 |
+
# Encoder parameters
|
10 |
+
enc_num_layers: 4
|
11 |
+
enc_num_head: 2
|
12 |
+
enc_d_model: 384
|
13 |
+
enc_ffn_dim: 1024
|
14 |
+
enc_k_dim: 384
|
15 |
+
enc_v_dim: 384
|
16 |
+
enc_dropout: 0.1
|
17 |
+
|
18 |
+
# Decoder parameters
|
19 |
+
dec_num_layers: 4
|
20 |
+
dec_num_head: 2
|
21 |
+
dec_d_model: 384
|
22 |
+
dec_ffn_dim: 1024
|
23 |
+
dec_k_dim: 384
|
24 |
+
dec_v_dim: 384
|
25 |
+
dec_dropout: 0.1
|
26 |
+
|
27 |
+
# common
|
28 |
+
normalize_before: True
|
29 |
+
ffn_type: 1dcnn #1dcnn or ffn
|
30 |
+
dur_pred_kernel_size: 3
|
31 |
+
pitch_pred_kernel_size: 3
|
32 |
+
energy_pred_kernel_size: 3
|
33 |
+
|
34 |
+
model: !new:speechbrain.lobes.models.FastSpeech2.FastSpeech2
|
35 |
+
enc_num_layers: !ref <enc_num_layers>
|
36 |
+
enc_num_head: !ref <enc_num_head>
|
37 |
+
enc_d_model: !ref <enc_d_model>
|
38 |
+
enc_ffn_dim: !ref <enc_ffn_dim>
|
39 |
+
enc_k_dim: !ref <enc_k_dim>
|
40 |
+
enc_v_dim: !ref <enc_v_dim>
|
41 |
+
enc_dropout: !ref <enc_dropout>
|
42 |
+
dec_num_layers: !ref <dec_num_layers>
|
43 |
+
dec_num_head: !ref <dec_num_head>
|
44 |
+
dec_d_model: !ref <dec_d_model>
|
45 |
+
dec_ffn_dim: !ref <dec_ffn_dim>
|
46 |
+
dec_k_dim: !ref <dec_k_dim>
|
47 |
+
dec_v_dim: !ref <dec_v_dim>
|
48 |
+
dec_dropout: !ref <dec_dropout>
|
49 |
+
normalize_before: !ref <normalize_before>
|
50 |
+
ffn_type: !ref <ffn_type>
|
51 |
+
n_char: !ref <n_symbols>
|
52 |
+
n_mels: !ref <n_mel_channels>
|
53 |
+
padding_idx: !ref <padding_idx>
|
54 |
+
dur_pred_kernel_size: !ref <dur_pred_kernel_size>
|
55 |
+
pitch_pred_kernel_size: !ref <pitch_pred_kernel_size>
|
56 |
+
energy_pred_kernel_size: !ref <energy_pred_kernel_size>
|
57 |
+
|
58 |
+
# The lexicon file must be the same used for training
|
59 |
+
lexicon:
|
60 |
+
- "t"
|
61 |
+
- "?"
|
62 |
+
- "q"
|
63 |
+
- "j"
|
64 |
+
- "g"
|
65 |
+
- "p"
|
66 |
+
- "x"
|
67 |
+
- "("
|
68 |
+
- "é"
|
69 |
+
- "e"
|
70 |
+
- "z"
|
71 |
+
- ","
|
72 |
+
- "o"
|
73 |
+
- "a"
|
74 |
+
- "m"
|
75 |
+
- "n"
|
76 |
+
- "u"
|
77 |
+
- "d"
|
78 |
+
- ":"
|
79 |
+
- "w"
|
80 |
+
- "à"
|
81 |
+
- "“"
|
82 |
+
- "."
|
83 |
+
- "”"
|
84 |
+
- "’"
|
85 |
+
- "["
|
86 |
+
- "v"
|
87 |
+
- "h"
|
88 |
+
- " "
|
89 |
+
- "ê"
|
90 |
+
- "b"
|
91 |
+
- "'"
|
92 |
+
- "\""
|
93 |
+
- "f"
|
94 |
+
- "â"
|
95 |
+
- "!"
|
96 |
+
- ";"
|
97 |
+
- "l"
|
98 |
+
- "r"
|
99 |
+
- "è"
|
100 |
+
- "i"
|
101 |
+
- "]"
|
102 |
+
- "s"
|
103 |
+
- "k"
|
104 |
+
- "y"
|
105 |
+
- ")"
|
106 |
+
- "c"
|
107 |
+
- "ü"
|
108 |
+
- "-"
|
109 |
+
|
110 |
+
|
111 |
+
input_encoder: !new:speechbrain.dataio.encoder.TextEncoder
|
112 |
+
|
113 |
+
|
114 |
+
modules:
|
115 |
+
model: !ref <model>
|
116 |
+
|
117 |
+
pretrainer: !new:speechbrain.utils.parameter_transfer.Pretrainer
|
118 |
+
loadables:
|
119 |
+
model: !ref <model>
|
120 |
+
|
lexicon
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
t ? q j g p x ( é e z , o a m n u d : w à “ . ” ’ [ v h ê b ' " f â ! ; l r è i ] s k y ) c ü -
|
model.ckpt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f865742e35bece5d31c8de1986f0b2a5470d80fdceabe8bb9107d36f96f2714
|
3 |
+
size 105446353
|