espnet2.asr.transducer.error_calculator.ErrorCalculatorTransducer
Less than 1 minute
espnet2.asr.transducer.error_calculator.ErrorCalculatorTransducer
class espnet2.asr.transducer.error_calculator.ErrorCalculatorTransducer(decoder: AbsDecoder, joint_network: Module, token_list: List[int], sym_space: str, sym_blank: str, report_cer: bool = False, report_wer: bool = False)
Bases: object
Calculate CER and WER for transducer models.
- Parameters:
- decoder – Decoder module.
- token_list – List of tokens.
- sym_space – Space symbol.
- sym_blank – Blank symbol.
- report_cer – Whether to compute CER.
- report_wer – Whether to compute WER.
Construct an ErrorCalculatorTransducer.
calculate_cer(char_pred: Tensor, char_target: Tensor) → float
Calculate sentence-level CER score.
- Parameters:
- char_pred – Prediction character sequences. (B, ?)
- char_target – Target character sequences. (B, ?)
- Returns: Average sentence-level CER score.
calculate_wer(char_pred: Tensor, char_target: Tensor) → float
Calculate sentence-level WER score.
- Parameters:
- char_pred – Prediction character sequences. (B, ?)
- char_target – Target character sequences. (B, ?)
- Returns: Average sentence-level WER score
convert_to_char(pred: Tensor, target: Tensor) → Tuple[List, List]
Convert label ID sequences to character sequences.
- Parameters:
- pred – Prediction label ID sequences. (B, U)
- target – Target label ID sequences. (B, L)
- Returns: Prediction character sequences. (B, ?) char_target: Target character sequences. (B, ?)
- Return type: char_pred