torchaudio.models.wav2vec2.utils.import_huggingface_model¶
- torchaudio.models.wav2vec2.utils.import_huggingface_model(original: Module) Wav2Vec2Model [source]¶
Builds
Wav2Vec2Model
from the corresponding model object of Transformers.- Parameters:
original (torch.nn.Module) – An instance of
Wav2Vec2ForCTC
fromtransformers
.- Returns:
Imported model.
- Return type:
- Example
>>> 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)