-
Notifications
You must be signed in to change notification settings - Fork 41
Extract numerical features from audio
This feature lets the user extract aggregated data features calculated per audio file. See feature options for more information on choices of features available.
Code example for performing gfcc and mfcc feature extraction can be found below. To use your own audio data for feature extraction, pass the path to get_features in place of data_samples/testing. Please refer to the format of directory data_samples/testing or the section on Training and Testing Data structuring.
from pyAudioProcessing.extract_features import get_features
# Feature extraction
features = get_features("data_samples/testing", ["gfcc", "mfcc"])
# features is a dictionary that will hold data of the following format
"""
{
subdir1_name: {file1_path: {"features": <list>, "feature_names": <list>}, ...},
subdir2_name: {file1_path: {"features": <list>, "feature_names": <list>}, ...},
...
}
"""
To save features in a json file,
from pyAudioProcessing import utils
utils.write_to_json("audio_features.json", features)
If you cloned the project via git, the following command line example of for gfcc and mfcc feature extractions can be used as well. The features argument should be a comma separated string, example gfcc,mfcc.
To use your own audio files for feature extraction, pass in the directory path containing .wav files as the -f argument. Please refer to the format of directory data_samples/testing or the section on Training and Testing Data structuring.
python pyAudioProcessing/extract_features.py -f "data_samples/testing" -feats "gfcc,mfcc"
Features extracted get saved in audio_features.json.