speechbrain / tts-diffwave-ljspeech

huggingface.co
Total runs: 41
24-hour runs: 0
7-day runs: 4
30-day runs: 28
Model's Last Updated: February 26 2024
text-to-speech

Introduction of tts-diffwave-ljspeech

Model Details of tts-diffwave-ljspeech

Vocoder with DiffWave trained on LJSpeech

This repository provides all the necessary tools for using a DiffWave vocoder trained with LJSpeech .

The pre-trained model takes as input a spectrogram and generates a waveform as output. Typically, a vocoder is used after a TTS model that converts an input text into a spectrogram.

The sampling frequency is 22050 Hz.

Install SpeechBrain
pip install speechbrain

Please notice that we encourage you to read our tutorials and learn more about SpeechBrain .

Using the Vocoder as reconstructor
import torch
import torchaudio
import speechbrain as sb
from speechbrain.inference.vocoders import DiffWaveVocoder
from speechbrain.lobes.models.HifiGAN import mel_spectogram
from speechbrain.utils.fetching import fetch
from speechbrain.utils.data_utils import split_path

diffwave = DiffWaveVocoder.from_hparams(source="speechbrain/tts-diffwave-ljspeech", savedir="pretrained_models/tts-diffwave-ljspeech")

source, fl = split_path("speechbrain/tts-diffwave-ljspeech/LJ050-0075.wav")
path = fetch(fl, source=source, savedir="tmpdir")
audio, fs_file = torchaudio.load(path)
audio = torch.FloatTensor(audio)

mel = mel_spectogram(
    sample_rate=22050,
    hop_length=256,
    win_length=1024,
    n_fft=1024,
    n_mels=80,
    f_min=0,
    f_max=8000,
    power=1.0,
    normalized=False,
    norm="slaney",
    mel_scale="slaney",
    compression=True,
    audio=audio,
)

# Running Vocoder (spectrogram-to-waveform), a fast sampling can be realized by passing user-defined variance schedules. According to the paper, high-quality audios can be generated with only 6 steps (instead of a total of 50).
waveforms = diffwave.decode_batch(
    mel,
    hop_len=256,  # upsample factor, should be the same as "hop_len" during the extraction of mel-spectrogram
    fast_sampling=True,  # fast sampling is highly recommanded
    fast_sampling_noise_schedule=[0.0001, 0.001, 0.01, 0.05, 0.2, 0.5],  # customized noise schedule 
)

torchaudio.save('reconstructed.wav', waveforms.squeeze(1), 22050)
Using the Vocoder with TTS
import torchaudio
from speechbrain.pretrained import FastSpeech2
from speechbrain.pretrained import DiffWaveVocoder

# Intialize TTS (FastSpeech2) and Vocoder (DiffWave)
fastspeech2 = FastSpeech2.from_hparams(source="speechbrain/tts-fastspeech2-ljspeech", savedir="pretrained_models/tts-fastspeech2-ljspeech")
diffwave = DiffWaveVocoder.from_hparams(source="speechbrain/tts-diffwave-ljspeech", savedir="pretrained_models/tts-diffwave-ljspeech")

input_text = "This is a test run with FastSpeech and DiffWave."

# Running the TTS
mel_output, durations, pitch, energy = fastspeech2.encode_text(
  [input_text],
  pace=1.0,        # scale up/down the speed
  pitch_rate=1.0,  # scale up/down the pitch
  energy_rate=1.0, # scale up/down the energy
)

# Running Vocoder (spectrogram-to-waveform), a fast sampling can be realized by passing user-defined variance schedules. According to the paper, high-quality audios can be generated with only 6 steps (instead of a total of 50).
waveforms = diffwave.decode_batch(
    mel_output,
    hop_len=256,  # upsample factor, should be the same as "hop_len" during the extraction of mel-spectrogram
    fast_sampling=True,  # fast sampling is highly recommanded
    fast_sampling_noise_schedule=[0.0001, 0.001, 0.01, 0.05, 0.2, 0.5],  # customized noise schedule 
)

# Save the waverform
torchaudio.save('example_TTS.wav',waveforms.squeeze(1), 22050)
Inference on GPU

To perform inference on the GPU, add run_opts={"device":"cuda"} when calling the from_hparams method.

Training

The model was trained with SpeechBrain. To train it from scratch follow these steps:

  1. Clone SpeechBrain:
git clone https://github.com/speechbrain/speechbrain/
  1. Install it:
cd speechbrain
pip install -r requirements.txt
pip install -e .
  1. Run Training:
cd recipes/LJSpeech/TTS/vocoder/diffwave/
python train.py hparams/train.yaml --data_folder /path/to/LJspeech

You can find our training results (models, logs, etc) here .

Limitations

The SpeechBrain team does not provide any warranty on the performance achieved by this model when used on other datasets.

About SpeechBrain

Citing SpeechBrain

Please, cite SpeechBrain if you use it for your research or business.

@misc{speechbrain,
  title={{SpeechBrain}: A General-Purpose Speech Toolkit},
  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},
  year={2021},
  eprint={2106.04624},
  archivePrefix={arXiv},
  primaryClass={eess.AS},
  note={arXiv:2106.04624}
}

Runs of speechbrain tts-diffwave-ljspeech on huggingface.co

41
Total runs
0
24-hour runs
0
3-day runs
4
7-day runs
28
30-day runs

More Information About tts-diffwave-ljspeech huggingface.co Model

More tts-diffwave-ljspeech license Visit here:

https://choosealicense.com/licenses/apache-2.0

tts-diffwave-ljspeech huggingface.co

tts-diffwave-ljspeech huggingface.co is an AI model on huggingface.co that provides tts-diffwave-ljspeech's model effect (), which can be used instantly with this speechbrain tts-diffwave-ljspeech model. huggingface.co supports a free trial of the tts-diffwave-ljspeech model, and also provides paid use of the tts-diffwave-ljspeech. Support call tts-diffwave-ljspeech model through api, including Node.js, Python, http.

tts-diffwave-ljspeech huggingface.co Url

https://huggingface.co/speechbrain/tts-diffwave-ljspeech

speechbrain tts-diffwave-ljspeech online free

tts-diffwave-ljspeech huggingface.co is an online trial and call api platform, which integrates tts-diffwave-ljspeech's modeling effects, including api services, and provides a free online trial of tts-diffwave-ljspeech, you can try tts-diffwave-ljspeech online for free by clicking the link below.

speechbrain tts-diffwave-ljspeech online free url in huggingface.co:

https://huggingface.co/speechbrain/tts-diffwave-ljspeech

tts-diffwave-ljspeech install

tts-diffwave-ljspeech is an open source model from GitHub that offers a free installation service, and any user can find tts-diffwave-ljspeech on GitHub to install. At the same time, huggingface.co provides the effect of tts-diffwave-ljspeech install, users can directly use tts-diffwave-ljspeech installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

tts-diffwave-ljspeech install url in huggingface.co:

https://huggingface.co/speechbrain/tts-diffwave-ljspeech

Url of tts-diffwave-ljspeech

tts-diffwave-ljspeech huggingface.co Url

Provider of tts-diffwave-ljspeech huggingface.co

speechbrain
ORGANIZATIONS

Other API from speechbrain

huggingface.co

Total runs: 120
Run Growth: -15
Growth Rate: -12.50%
Updated:February 26 2024