hezar.preprocessors.audio_feature_extractor module¶
- class hezar.preprocessors.audio_feature_extractor.AudioFeatureExtractor(config: AudioFeatureExtractorConfig, **kwargs)[source]¶
Bases:
Preprocessor
Base class for all audio feature extractors.
- config_filename = 'feature_extractor_config.yaml'¶
- classmethod load(hub_or_local_path, subfolder: str | None = None, config_filename: str | None = None, cache_dir: str | None = None, **kwargs)[source]¶
Load a feature extractor from Hub or local path.
- Parameters:
hub_or_local_path – Hub repo id or local path
subfolder – Preprocessor subfolder path
config_filename – Config file name
cache_dir – Path to cache directory
**kwargs
- Returns:
A AudioFeatureExtractor object
- model_input_name = 'input_features'¶
- pad(processed_features, padding: bool | str | PaddingType = True, max_length=None, truncation=None, pad_to_multiple_of=None, return_attention_mask=None, return_tensors=None)[source]¶
Pad input values / input vectors or a batch of input values / input vectors up to predefined length or to the max sequence length in the batch.
- Parameters:
processed_features – Processed inputs to add padding to
padding – Padding strategy which can be longest, max_length, False
max_length – Max input length (Only effective if padding is max_length too, ignored otherwise)
truncation – Whether to truncate long inputs or not
pad_to_multiple_of – If set will pad the sequence to a multiple of the provided value.
return_attention_mask – Whether to return the attention mask.
return_tensors – Tensors return type among pt, np, list
- push_to_hub(repo_id, subfolder=None, commit_message=None, private=None, config_filename=None)[source]¶
Push the feature extractor files to a repo on the Hub.
- Parameters:
repo_id – Hub repo id
subfolder – Subfolder to save, defaults to self.preprocessor_subfolder (preprocessor)
commit_message – Commit message for the push
private – If the repo does not exist already, specify whether the created repo must be private or not
config_filename – Config filename, defaults to self.config_filename (feature_extractor_config.yaml)
- save(path, subfolder=None, config_filename=None)[source]¶
Save the feature extractor to the path. This normally is equal to only saving the feature_extractor_config.yaml file.
- Parameters:
path – Main path to save the feature extractor files
subfolder – Optional subfolder, defaults to preprocessor
config_filename – Optional config file name, defaults to feature_extractor_config.yaml
- class hezar.preprocessors.audio_feature_extractor.AudioFeatureExtractorConfig(feature_size: 'int' = None, sampling_rate: 'int' = 16000, padding: 'str' = None, padding_value: 'float' = 0.0, padding_side: 'str' = None)[source]¶
Bases:
PreprocessorConfig
- feature_size: int = None¶
- padding: str = None¶
- padding_side: str = None¶
- padding_value: float = 0.0¶
- sampling_rate: int = 16000¶