espnet3.systems.esp2_lid.src.inference_runner.ESP2LIDInferenceRunner
About 1 min
espnet3.systems.esp2_lid.src.inference_runner.ESP2LIDInferenceRunner
class espnet3.systems.esp2_lid.src.inference_runner.ESP2LIDInferenceRunner(provider: EnvironmentProvider, idx_key: str = 'utt_id', hyp_key: str | Sequence[str] = 'hyp', ref_key: str | Sequence[str] = 'ref', **kwargs)
Bases: InferenceRunner
Run Speech2Language and return its prediction as language.
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)
Return the predicted language as the contracted language field.
Speech2Language returns a language code, or a hyp/embedding dictionary when built with extract_embd=True; only the language is an output.
- Parameters:
- result – What
Speech2Languagereturned (a list for a batch). - batched – Whether the call was a batch.
- result – What
- Returns:
{"language": ...}for one call, or a list of them for a batch.
####### Examples
>>> ESP2LIDInferenceRunner.format_output("jpn", batched=False)
{'language': 'jpn'}
>>> ESP2LIDInferenceRunner.format_output(
... [{"hyp": "eng", "embedding": None}], batched=True
... )
[{'language': 'eng'}]static prepare_model_inputs(inputs)
Pass the checked mono Audio to Speech2Language as samples.
- Parameters:inputs – The backend’s keyword arguments;
speechholds anAudio(a list of them for a batch). - Returns: A copy of
inputswhosespeechis a 1-D array (a list of them for a batch).
####### Examples
>>> import numpy as np
>>> from espnet3.contract.kinds.audio import Audio
>>> audio = Audio(np.zeros(16000, dtype=np.float32), 16000)
>>> out = ESP2LIDInferenceRunner.prepare_model_inputs({"speech": audio})
>>> out["speech"].shape
(16000,)