vocoder_util
VocoderWrapper
Bases: object
A wrapper class for the vocoder forward function.
This wrapper is not implemented as a Module because we don't want it to be in the computational graph of a TTS model.
Before wrapping
feat -> vocoder -> wav
After wrapping: feat, feat_len -> VocoderWrapper(vocoder) -> wav, wav_len
Source code in speechain/utilbox/vocoder_util.py
get_hifigan_vocoder(device, sample_rate=22050, use_multi_speaker=True)
Initialize the built-in HiFiGAN vocoder with pretrained weights.
The pretrained checkpoints hosted on the HuggingFace hub (under the
speechbrain/ namespace) are automatically downloaded on the first call
and loaded into SpeeChain's own HiFiGAN implementation
(:class:speechain.module.vocoder.HiFiGAN) — no third-party vocoder
toolkit is required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
device
|
Union[int, str, device]
|
The device to run the vocoder on (GPU index, 'cuda:x', or 'cpu'). |
required |
sample_rate
|
int
|
The sampling rate of the generated waveforms (16000 or 22050). |
22050
|
use_multi_speaker
|
bool
|
Whether to use the multi-speaker (LibriTTS) vocoder. If False, the single-speaker (LJSpeech) vocoder is used. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
VocoderWrapper |
VocoderWrapper
|
The wrapped HiFiGAN vocoder ready for |
VocoderWrapper
|
|