espnet2.s2st.espnet_model.ESPnetS2STModel
espnet2.s2st.espnet_model.ESPnetS2STModel
class espnet2.s2st.espnet_model.ESPnetS2STModel(s2st_type: str, frontend: AbsFrontend | None, tgt_feats_extract: AbsTgtFeatsExtract | None, specaug: AbsSpecAug | None, src_normalize: AbsNormalize | None, tgt_normalize: AbsNormalize | None, preencoder: AbsPreEncoder | None, encoder: AbsEncoder, postencoder: AbsPostEncoder | None, asr_decoder: AbsDecoder | None, st_decoder: AbsDecoder | None, aux_attention: AbsS2STAuxAttention | None, unit_encoder: AbsEncoder | None, synthesizer: AbsSynthesizer | None, asr_ctc: CTC | None, st_ctc: CTC | None, losses: Dict[str, AbsS2STLoss], tgt_vocab_size: int | None, tgt_token_list: Tuple[str, ...] | List[str] | None, src_vocab_size: int | None, src_token_list: Tuple[str, ...] | List[str] | None, unit_vocab_size: int | None, unit_token_list: Tuple[str, ...] | List[str] | None, ignore_id: int = -1, report_cer: bool = True, report_wer: bool = True, report_bleu: bool = True, sym_space: str = '<space>', sym_blank: str = '<blank>', extract_feats_in_collect_stats: bool = True)
Bases: AbsESPnetModel
ESPnet speech-to-speech translation model
Initialize internal Module state, shared by both nn.Module and ScriptModule.
collect_feats(src_speech: Tensor, src_speech_lengths: Tensor, tgt_speech: Tensor, tgt_speech_lengths: Tensor, **kwargs) → Dict[str, Tensor]
encode(speech: Tensor, speech_lengths: Tensor, return_all_hs: bool = False, **kwargs) → Tuple[Tensor, Tensor]
Frontend + Encoder. Note that this method is used by st_inference.py
- Parameters:
- speech – (Batch, Length, …)
- speech_lengths – (Batch, )
forward(src_speech: Tensor, src_speech_lengths: Tensor, tgt_speech: Tensor, tgt_speech_lengths: Tensor, tgt_text: Tensor | None = None, tgt_text_lengths: Tensor | None = None, src_text: Tensor | None = None, src_text_lengths: Tensor | None = None, spembs: Tensor | None = None, sids: Tensor | None = None, lids: Tensor | None = None, **kwargs) → Tuple[Tensor, Dict[str, Tensor], Tensor]
Define the computation performed at every call.
Should be overridden by all subclasses.
NOTE
Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
inference(src_speech: Tensor, src_speech_lengths: Tensor | None = None, tgt_speech: Tensor | None = None, tgt_speech_lengths: Tensor | None = None, spembs: Tensor | None = None, sids: Tensor | None = None, lids: Tensor | None = None, threshold: float = 0.5, minlenratio: float = 0.0, maxlenratio: float = 10.0, use_att_constraint: bool = False, backward_window: int = 1, forward_window: int = 3, use_teacher_forcing: bool = False) → Dict[str, Tensor]
property require_vocoder
Return whether or not vocoder is required.
