espnet2.asr_transducer.encoder.encoder.Encoder
Less than 1 minute
espnet2.asr_transducer.encoder.encoder.Encoder
class espnet2.asr_transducer.encoder.encoder.Encoder(input_size: int, body_conf: List[Dict[str, Any]], input_conf: Dict[str, Any] = {}, main_conf: Dict[str, Any] = {})
Bases: Module
Encoder module definition.
- Parameters:
- input_size – Input size.
- body_conf – Encoder body configuration.
- input_conf – Encoder input configuration.
- main_conf – Encoder main configuration.
Construct an Encoder object.
chunk_forward(x: Tensor, x_len: Tensor, processed_frames: tensor, left_context: int = 32) → Tensor
Encode input sequences as chunks.
- Parameters:
- x – Encoder input features. (1, T_in, F)
- x_len – Encoder input features lengths. (1,)
- processed_frames – Number of frames already seen.
- left_context – Number of previous frames (AFTER subsampling) the attention module can see in current chunk.
- Returns: Encoder outputs. (B, T_out, D_enc)
- Return type: x
forward(x: Tensor, x_len: Tensor) → Tuple[Tensor, Tensor]
Encode input sequences.
- Parameters:
- x – Encoder input features. (B, T_in, F)
- x_len – Encoder input features lengths. (B,)
- Returns: Encoder outputs. (B, T_out, D_enc) x_len: Encoder outputs lenghts. (B,)
- Return type: x
reset_cache(left_context: int, device: device) → None
Initialize/Reset encoder cache for streaming.
- Parameters:
- left_context – Number of previous frames (AFTER subsampling) the attention module can see in current chunk.
- device – Device ID.