espnet2.asr.frontend.huggingface.HuggingFaceFrontend
Less than 1 minute
espnet2.asr.frontend.huggingface.HuggingFaceFrontend
class espnet2.asr.frontend.huggingface.HuggingFaceFrontend(model, fs: int | str = 16000, download_dir: str | None = None, load_pretrained: bool = True)
Bases: AbsFrontend
Use pretrained models from Hugging Face Transformers for ASR
Initializes internal Module state, shared by both nn.Module and ScriptModule.
forward(inputs: Tensor, input_lengths: Tensor) → Tuple[Tensor, Tensor]
Wrapper for the transformers forward pass. Inputs are converted to numpy and re-encoded with the transformers processor.
Parameters:
- input – Input (B, L) single channel waveform.
- input_lengths – Input lengths within batch.
Returns: Output with dimensions (B, T, D), T is the processed length, : D is the feature dimension.
Tensor: Output lengths within batch.
Return type: Tensor
output_size() → int
reload_pretrained_parameters()