Text-to-Speech
speechbrain
English
TTS
speech-synthesis
Tacotron2
Mirco commited on
Commit
54c83e5
1 Parent(s): 0b1d6f2

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +14 -1
README.md CHANGED
@@ -48,9 +48,22 @@ Please notice that we encourage you to read our tutorials and learn more about
48
  ### Perform Text-to-Speech (TTS)
49
 
50
  ```
 
51
  from speechbrain.pretrained import Tacotron2
52
- tacotron2 = Tacotron2.from_hparams(source="speechbrain/TTS_Tacotron2", savedir="tmpdir")
 
 
 
 
 
 
53
  mel_output, mel_length, alignment = tacotron2.encode_text("Mary had a little lamb")
 
 
 
 
 
 
54
  ```
55
 
56
  If you want to generate multiple sentences in one-shot, you can do in this way:
 
48
  ### Perform Text-to-Speech (TTS)
49
 
50
  ```
51
+ import torchaudio
52
  from speechbrain.pretrained import Tacotron2
53
+ from speechbrain.pretrained import HIFIGAN
54
+
55
+ # Intialize TTS (tacotron2) and Vocoder (HiFIGAN)
56
+ tacotron2 = Tacotron2.from_hparams(source="speechbrain/TTS_Tacotron2", savedir="tmpdir_tts")
57
+ hifi_gan = HIFIGAN.from_hparams(source="speechbrain/Vocoder_HiFIGAN", savedir="tmpdir_vocoder")
58
+
59
+ # Running the TTS
60
  mel_output, mel_length, alignment = tacotron2.encode_text("Mary had a little lamb")
61
+
62
+ # Running Vocoder (spectrogram-to-waveform)
63
+ waveforms = hifi_gan.decode_batch(mel_output)
64
+
65
+ # Save the waverform
66
+ torchaudio.save('example_TTS.wav',waveforms.squeeze(1), 22050)
67
  ```
68
 
69
  If you want to generate multiple sentences in one-shot, you can do in this way: