本文簡要介紹python語言中 torchaudio.pipelines.Wav2Vec2ASRBundle
的用法。
用法:
class torchaudio.pipelines.Wav2Vec2ASRBundle
捆綁相關信息以使用預訓練的 Wav2Vec2Model 的數據類。
該類提供了用於實例化預訓練模型的接口以及檢索預訓練權重所需的信息以及與模型一起使用的附加數據。
Torchaudio 庫實例化了這個類的對象,每個對象代表一個不同的預訓練模型。客戶端代碼應通過這些實例訪問預訓練模型。
請參閱下麵的用法和可用值。
- 示例 - ASR
>>> import torchaudio >>> >>> bundle = torchaudio.pipelines.HUBERT_ASR_LARGE >>> >>> # Build the model and load pretrained weight. >>> model = bundle.get_model() Downloading: 100%|███████████████████████████████| 1.18G/1.18G [00:17<00:00, 73.8MB/s] >>> >>> # Check the corresponding labels of the output. >>> labels = bundle.get_labels() >>> print(labels) ('<s>', '<pad>', '</s>', '<unk>', '|', 'E', 'T', 'A', 'O', 'N', 'I', 'H', 'S', 'R', 'D', 'L', 'U', 'M', 'W', 'C', 'F', 'G', 'Y', 'P', 'B', 'V', 'K', "'", 'X', 'J', 'Q', 'Z') >>> >>> # Resample audio to the expected sampling rate >>> waveform = torchaudio.functional.resample(waveform, sample_rate, bundle.sample_rate) >>> >>> # Infer the label probability distribution >>> emissions, _ = model(waveform) >>> >>> # Pass emission to decoder >>> # `ctc_decode` is for illustration purpose only >>> transcripts = ctc_decode(emissions, labels)
相關用法
- Python PyTorch Wav2Vec2ASRBundle.get_labels用法及代碼示例
- Python PyTorch Wav2Vec2Bundle用法及代碼示例
- Python PyTorch WaveRNN用法及代碼示例
- Python PyTorch WeightedRandomSampler用法及代碼示例
- Python PyTorch WorkerState用法及代碼示例
- Python PyTorch WIDERFace用法及代碼示例
- Python PyTorch Weibull用法及代碼示例
- Python PyTorch frexp用法及代碼示例
- Python PyTorch jvp用法及代碼示例
- Python PyTorch cholesky用法及代碼示例
- Python PyTorch vdot用法及代碼示例
- Python PyTorch ELU用法及代碼示例
- Python PyTorch ScaledDotProduct.__init__用法及代碼示例
- Python PyTorch gumbel_softmax用法及代碼示例
- Python PyTorch get_tokenizer用法及代碼示例
- Python PyTorch saved_tensors_hooks用法及代碼示例
- Python PyTorch positive用法及代碼示例
- Python PyTorch renorm用法及代碼示例
- Python PyTorch AvgPool2d用法及代碼示例
- Python PyTorch MaxUnpool3d用法及代碼示例
- Python PyTorch Bernoulli用法及代碼示例
- Python PyTorch Tensor.unflatten用法及代碼示例
- Python PyTorch Sigmoid用法及代碼示例
- Python PyTorch Tensor.register_hook用法及代碼示例
- Python PyTorch ShardedEmbeddingBagCollection.named_parameters用法及代碼示例
注:本文由純淨天空篩選整理自pytorch.org大神的英文原創作品 torchaudio.pipelines.Wav2Vec2ASRBundle。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。