espnet3.systems.esp2_codec.src.preprocessor.CodecPreprocessor
espnet3.systems.esp2_codec.src.preprocessor.CodecPreprocessor
class espnet3.systems.esp2_codec.src.preprocessor.CodecPreprocessor(train: bool, model_input_name: str = 'audio', **kwargs)
Bases: CommonPreprocessor
CommonPreprocessor that renames the waveform for the codec model.
ESPnet3 codec datasets declare their waveform as speech, the field name the other systems use. The ESPnet2 codec stack takes it as audio: ESPnetGANCodecModel.forward(audio, ...), collect_feats(audio, ...) and GANCodecTask.required_data_names(). The batch reaches the model as model(**batch), so the key has to be audio by the time the collate function sees it. This preprocessor applies the usual CommonPreprocessor processing to speech_name and then stores the result under model_input_name. DataOrganizer runs it on every training, validation and collect_stats item.
- Parameters:
- train – Whether this is the training split’s preprocessor;
DataOrganizersets it. - model_input_name – The keyword the codec model takes the waveform under. Defaults to
audio. - **kwargs – Forwarded to
CommonPreprocessor(speech_name,force_single_channel,audio_pad_value, …).
- train – Whether this is the training split’s preprocessor;
Examples
Declared in egs3/TEMPLATE/esp2_codec/conf/training.yaml:
dataset:
preprocessor:
_target_: espnet3.systems.esp2_codec.src.preprocessor.CodecPreprocessor
token_type: null
speech_name: speech
force_single_channel: true
audio_pad_value: 0.0>>> import numpy as np
>>> preprocessor = CodecPreprocessor(train=False, token_type=None)
>>> out = preprocessor("utt1", {"speech": np.zeros(4, dtype=np.float32)})
>>> sorted(out)
['audio']Build the CommonPreprocessor and keep the model’s input name.
