Skip to content

Training your own custom audio classification models

Jyotika Singh edited this page May 11, 2022 · 2 revisions

Training and Classifying Audio files

Audio data can be trained, tested and classified using pyAudioProcessing. Please see feature options and classifier model options for more information.

Sample spoken location name dataset for spoken instances of "london" and "boston" can be found here.

Examples

Code example of using gfcc,spectral,chroma feature and svm classifier. Sample data can be found here. Please refer to the section on Training and Testing Data structuring to use your own data instead.

from pyAudioProcessing.run_classification import train_and_classify
# Training
train_and_classify("data_samples/training", "train", ["gfcc", "spectral", "chroma"], "svm", "svm_clf")

The above logs files analyzed, hyperparameter tuning results for recall, precision and F1 score, along with the final confusion matrix.

To classify audio samples with the classifier you created above,

# Classify data
classifications = train_and_classify("data_samples/testing", "classify", ["gfcc", "spectral", "chroma"], "svm", "svm_clf")

The above logs the filename where the classification results are saved along with the details about testing files and the classifier used if you pass in logfile=True into the function call.

If you cloned the project via git, the following command line example of training and classification with gfcc,spectral,chroma features and svm classifier can be used as well. Sample data can be found here. Please refer to the section on Training and Testing Data structuring to use your own data instead.

Training:

python pyAudioProcessing/run_classification.py -f "data_samples/training" -clf "svm" -clfname "svm_clf" -t "train" -feats "gfcc,spectral,chroma"

Classifying:

python pyAudioProcessing/run_classification.py -f "data_samples/testing" -clf "svm" -clfname "svm_clf" -t "classify" -feats "gfcc,spectral,chroma" -logfile "../classifier_results"

Classification results get saved in ../classifier_results_svm_clf.json.

Clone this wiki locally