本文简要介绍python语言中 torchaudio.pipelines.Tacotron2TTSBundle
的用法。
用法:
class torchaudio.pipelines.Tacotron2TTSBundle
捆绑相关信息以使用预训练 Tacotron2 和声码器的数据类。
该类提供了用于实例化预训练模型的接口以及检索预训练权重所需的信息以及与模型一起使用的附加数据。
Torchaudio 库实例化了这个类的对象,每个对象代表一个不同的预训练模型。客户端代码应通过这些实例访问预训练模型。
请参阅下面的用法和可用值。
- 示例 - 使用 Tacotron2 和 WaveRNN 的基于字符的 TTS 管道
>>> import torchaudio >>> >>> text = "Hello, T T S !" >>> bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_CHAR_LJSPEECH >>> >>> # Build processor, Tacotron2 and WaveRNN model >>> processor = bundle.get_text_processor() >>> tacotron2 = bundle.get_tacotron2() Downloading: 100%|███████████████████████████████| 107M/107M [00:01<00:00, 87.9MB/s] >>> vocoder = bundle.get_vocoder() Downloading: 100%|███████████████████████████████| 16.7M/16.7M [00:00<00:00, 78.1MB/s] >>> >>> # Encode text >>> input, lengths = processor(text) >>> >>> # Generate (mel-scale) spectrogram >>> specgram, lengths, _ = tacotron2.infer(input, lengths) >>> >>> # Convert spectrogram to waveform >>> waveforms, lengths = vocoder(specgram, lengths) >>> >>> torchaudio.save('hello-tts.wav', waveforms[0], vocoder.sample_rate)
- 示例 - 使用 Tacotron2 和 WaveRNN 的基于音素的 TTS 管道
>>> >>> # Note: >>> # This bundle uses pre-trained DeepPhonemizer as >>> # the text pre-processor. >>> # Please install deep-phonemizer. >>> # See https://github.com/as-ideas/DeepPhonemizer >>> # The pretrained weight is automatically downloaded. >>> >>> import torchaudio >>> >>> text = "Hello, TTS!" >>> bundle = torchaudio.pipelines.TACOTRON2_WAVERNN_PHONEME_LJSPEECH >>> >>> # Build processor, Tacotron2 and WaveRNN model >>> processor = bundle.get_text_processor() Downloading: 100%|███████████████████████████████| 63.6M/63.6M [00:04<00:00, 15.3MB/s] >>> tacotron2 = bundle.get_tacotron2() Downloading: 100%|███████████████████████████████| 107M/107M [00:01<00:00, 87.9MB/s] >>> vocoder = bundle.get_vocoder() Downloading: 100%|███████████████████████████████| 16.7M/16.7M [00:00<00:00, 78.1MB/s] >>> >>> # Encode text >>> input, lengths = processor(text) >>> >>> # Generate (mel-scale) spectrogram >>> specgram, lengths, _ = tacotron2.infer(input, lengths) >>> >>> # Convert spectrogram to waveform >>> waveforms, lengths = vocoder(specgram, lengths) >>> >>> torchaudio.save('hello-tts.wav', waveforms[0], vocoder.sample_rate)
相关用法
- Python PyTorch Tacotron2TTSBundle.get_text_processor用法及代码示例
- Python PyTorch TarArchiveLoader用法及代码示例
- Python PyTorch Tanh用法及代码示例
- Python PyTorch Tanhshrink用法及代码示例
- Python PyTorch Tensor.unflatten用法及代码示例
- Python PyTorch Tensor.register_hook用法及代码示例
- Python PyTorch TransformerEncoder用法及代码示例
- Python PyTorch Tensor.storage_offset用法及代码示例
- Python PyTorch Tensor.to用法及代码示例
- Python PyTorch Tensor.sparse_mask用法及代码示例
- Python PyTorch Timer用法及代码示例
- Python PyTorch TimeMasking用法及代码示例
- Python PyTorch TripletMarginLoss用法及代码示例
- Python PyTorch Tensor.is_leaf用法及代码示例
- Python PyTorch Tensor.imag用法及代码示例
- Python PyTorch Tensor.unfold用法及代码示例
- Python PyTorch TenCrop用法及代码示例
- Python PyTorch Tensor.real用法及代码示例
- Python PyTorch TwRwSparseFeaturesDist用法及代码示例
- Python PyTorch Tensor.refine_names用法及代码示例
- Python PyTorch Tensor.rename用法及代码示例
- Python PyTorch TransformedDistribution用法及代码示例
- Python PyTorch Tensor.view用法及代码示例
- Python PyTorch Tensor.new_empty用法及代码示例
- Python PyTorch Tensor.index_copy_用法及代码示例
注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torchaudio.pipelines.Tacotron2TTSBundle。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。