espnet2.asr_transducer.error_calculator.ErrorCalculator
Less than 1 minute
espnet2.asr_transducer.error_calculator.ErrorCalculator
class espnet2.asr_transducer.error_calculator.ErrorCalculator(decoder: AbsDecoder, joint_network: JointNetwork, token_list: List[int], sym_space: str, sym_blank: str, nstep: int = 2, report_cer: bool = False, report_wer: bool = False)
Bases: object
Calculate CER and WER for transducer models.
- Parameters:
- decoder – Decoder module.
- joint_network – Joint Network module.
- token_list – List of token units.
- sym_space – Space symbol.
- sym_blank – Blank symbol.
- nstep – Maximum number of symbol expansions at each time step w/ mAES.
- report_cer – Whether to compute CER.
- report_wer – Whether to compute WER.
Construct an ErrorCalculatorTransducer object.
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