ParakeetExtractor performance and UX enhancements (#39423)
Signed-off-by: Netanel Haber <58652339+netanel-haber@users.noreply.github.com>
This commit is contained in:
@@ -49,15 +49,24 @@ class ExtractorConfig:
|
||||
clip_duration_s: int = 30
|
||||
clip_min_duration_s: float = 0.1
|
||||
|
||||
@staticmethod
|
||||
def from_hf_config(config: PretrainedConfig) -> "ExtractorConfig":
|
||||
win_length: int = 400
|
||||
preemphasis: float = 0.97
|
||||
n_fft: int = 512
|
||||
padding_value: float = 0.0
|
||||
|
||||
@classmethod
|
||||
def from_hf_config(cls, config: PretrainedConfig) -> "ExtractorConfig":
|
||||
assert isinstance(config, PretrainedConfig)
|
||||
hop_length = int(getattr(config, "hop_length", ExtractorConfig.hop_length))
|
||||
return ExtractorConfig(
|
||||
defaults = ("hop_length", "win_length", "preemphasis", "n_fft", "padding_value")
|
||||
optional_kwargs = {
|
||||
name: getattr(config, name) for name in defaults if hasattr(config, name)
|
||||
}
|
||||
|
||||
return cls(
|
||||
feature_size=config.num_mel_bins,
|
||||
sampling_rate=config.sampling_rate,
|
||||
hop_length=hop_length,
|
||||
subsampling_factor=config.subsampling_factor,
|
||||
subsampling_conv_kernel_size=config.subsampling_conv_kernel_size,
|
||||
subsampling_conv_stride=config.subsampling_conv_stride,
|
||||
**optional_kwargs,
|
||||
)
|
||||
|
||||
@@ -992,17 +992,7 @@ class NanoNemotronVLProcessor(BaseNanoNemotronVLProcessor):
|
||||
parts[idx] = audio_repl.full
|
||||
audio_index += 1
|
||||
text = ["".join(parts)]
|
||||
audio_inputs = extractor(
|
||||
audios,
|
||||
sampling_rate=extractor.sampling_rate,
|
||||
return_tensors="pt",
|
||||
)
|
||||
audio_inputs = {
|
||||
"input_audio_features": audio_inputs.input_features,
|
||||
"feature_attention_mask": audio_inputs.attention_mask,
|
||||
"audio_num_clips": audio_inputs.audio_num_clips,
|
||||
}
|
||||
|
||||
audio_inputs = extractor(audios)
|
||||
return text, audio_inputs
|
||||
|
||||
def __call__(
|
||||
|
||||
Reference in New Issue
Block a user