espnet3.systems.esp2_cls.src.inference_runner.ESP2CLSInferenceRunner
Less than 1 minute
espnet3.systems.esp2_cls.src.inference_runner.ESP2CLSInferenceRunner
class espnet3.systems.esp2_cls.src.inference_runner.ESP2CLSInferenceRunner(provider: EnvironmentProvider, idx_key: str = 'utt_id', hyp_key: str | Sequence[str] = 'hyp', ref_key: str | Sequence[str] = 'ref', **kwargs)
Bases: InferenceRunner
Convert ESPnet2 Classification results to hyp and score.
Initialize the inference runner with output key settings.
- Parameters:
- provider – Environment provider that supplies dataset/model/env.
- idx_key – Output dict key used as the sample identifier written in the first column of each SCP line. This ties each inference result back to its dataset sample. Defaults to
"utt_id". - hyp_key – Hypothesis key or keys expected in the output dict.
- ref_key – Reference key or keys expected in the output dict.
- **kwargs – Forwarded to
BaseRunner.
static format_output(result, , batched)
Name the predicted label and the per-class scores.
- Parameters:
- result – The
(prediction, scores, hyp)tuple ofClassification. - batched – Whether the call was a batch.
- result – The
- Returns:
{"hyp": <label>, "score": <space-separated class scores>}. - Raises:ValueError – If the call was a batch.
Examples
>>> import torch
>>> result = ([1], torch.tensor([0.25, 0.75]), "joy")
>>> ESP2CLSInferenceRunner.format_output(result, batched=False)
{'hyp': 'joy', 'score': '0.25 0.75'}static prepare_model_inputs(inputs)
Pass the checked audio to Classification as a plain array.
- Parameters:inputs – The backend’s keyword arguments;
speechholds anAudio. - Returns: A copy of
inputswhosespeechis theAudio’s samples.
