espnet2.asr.encoder.wav2vec2_encoder.FairSeqWav2Vec2Encoder
Less than 1 minute
espnet2.asr.encoder.wav2vec2_encoder.FairSeqWav2Vec2Encoder
class espnet2.asr.encoder.wav2vec2_encoder.FairSeqWav2Vec2Encoder(input_size: int, w2v_url: str, w2v_dir_path: str = './', output_size: int = 256, normalize_before: bool = False, freeze_finetune_updates: int = 0)
Bases: AbsEncoder
FairSeq Wav2Vec2 encoder module.
- Parameters:
- input_size – input dim
- output_size – dimension of attention
- w2v_url – url to Wav2Vec2.0 pretrained model
- w2v_dir_path – directory to download the Wav2Vec2.0 pretrained model.
- normalize_before – whether to use layer_norm before the first block
- finetune_last_n_layers – last n layers to be finetuned in Wav2Vec2.0 0 means to finetune every layer if freeze_w2v=False.
Initializes internal Module state, shared by both nn.Module and ScriptModule.
forward(xs_pad: Tensor, ilens: Tensor, prev_states: Tensor | None = None) → Tuple[Tensor, Tensor, Tensor | None]
Forward FairSeqWav2Vec2 Encoder.
- Parameters:
- xs_pad – input tensor (B, L, D)
- ilens – input length (B)
- prev_states – Not to be used now.
- Returns: position embedded tensor and mask
output_size() → int
reload_pretrained_parameters()