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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user