torchaudio.models.wav2vec2.utils.import_huggingface_model¶
- torchaudio.models.wav2vec2.utils.import_huggingface_model(original: Module) Wav2Vec2Model [source]¶
从 Transformers 的相应模型对象构建
Wav2Vec2Model
。- 参数:
original (torch.nn.Module) – 来自
transformers
的Wav2Vec2ForCTC
实例。- 返回值:
导入的模型。
- 返回类型:
- 示例
>>> from torchaudio.models.wav2vec2.utils import import_huggingface_model >>> >>> original = Wav2Vec2ForCTC.from_pretrained("facebook/wav2vec2-base-960h") >>> model = import_huggingface_model(original) >>> >>> waveforms, _ = torchaudio.load("audio.wav") >>> logits, _ = model(waveforms)