Skip to content

Commit c91fef0

Browse files
authored
Merge pull request #35 from jsingh811/add_models
Add models
2 parents 9e37d35 + c9100fa commit c91fef0

File tree

17 files changed

+1513
-36
lines changed

17 files changed

+1513
-36
lines changed

README.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![pyaudioprocessing](https://user-images.githubusercontent.com/16875926/63388515-8e66fe00-c35d-11e9-98f5-a7ad0478a353.png)
44

5-
A Python based library for processing audio data into features and building Machine Learning models.
5+
A Python based library for processing audio data into features (GFCC, MFCC, spectral, chroma) and building Machine Learning models.
66
This was written using `Python 3.7.6`, and has been tested to work with Python >= 3.6, <4.
77

88

@@ -35,7 +35,7 @@ If you are on Python 3.9 and experience any issues with the code samples regardi
3535
pip install -U numpy
3636
```
3737

38-
## Choices
38+
## Options
3939

4040
### Feature options
4141

@@ -88,6 +88,32 @@ If you want to classify audio samples without any known labels, structure the da
8888
│   ├── sample2.wav
8989
```
9090

91+
## Classifying with Pre-trained Models
92+
93+
There are three models that have been pre-trained and provided in this project under the /models directory. They are as follows.
94+
95+
`music genre`: Contains SVM classifier to classify audio into 10 music genres - blues, classical, country, disco, hiphop, jazz, metal, pop, reggae, rock. This classifier was trained using mfcc, gfcc, spectral and chroma features. In order to classify your audio files using this classifier, please follow the audio files structuring guidelines. The following commands in Python can be used to classify your data.
96+
97+
`musicVSspeech`: Contains SVM classifier that classifying audio into two possible classes - music and speech. This classifier was trained using mfcc, spectral and chroma features.
98+
99+
`musicVSspeechVSbirds`: Contains SVM classifier that classifying audio into three possible classes - music, speech and birds. This classifier was trained using mfcc, spectral and chroma features.
100+
101+
In order to classify your audio files using any of these classifier, please follow the audio files [structuring guidelines](https://github.com/jsingh811/pyAudioProcessing#training-and-testing-data-structuring). The following commands in Python can be used to classify your data.
102+
103+
```
104+
from pyAudioProcessing.run_classification import train_and_classify
105+
106+
# musicVSspeech classification
107+
train_and_classify("../test_data", "classify", ["spectral", "chroma", "mfcc"], "svm", "models/musicVSspeech/svm_clf")
108+
109+
# musicVSspeechVSbirds classification
110+
train_and_classify("../test_data", "classify", ["spectral", "chroma", "mfcc"], "svm", "models/musicVSspeechVSbirds/svm_clf")
111+
112+
# music genre classification
113+
train_and_classify("../test_data", "classify", ["gfcc", "spectral", "chroma", "mfcc"], "svm", "models/music genre/svm_clf")
114+
```
115+
116+
91117
## Training and Classifying Audio files
92118

93119
Audio data can be trained, tested and classified using pyAudioProcessing. Please see [feature options](https://github.com/jsingh811/pyAudioProcessing#feature-options) and [classifier model options](https://github.com/jsingh811/pyAudioProcessing#classifier-options) for more information.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Confusion Matrix:
2+
```
3+
Confusion Matrix:
4+
pop met dis blu reg cla rock hip cou jazz
5+
pop 7.25 0.00 0.74 0.38 0.09 0.09 0.33 0.60 0.50 0.04
6+
met 0.03 8.74 0.66 0.09 0.00 0.00 0.45 0.00 0.04 0.00
7+
dis 0.69 0.08 6.29 0.00 0.74 0.11 0.90 0.51 0.69 0.00
8+
blu 0.00 0.20 0.00 8.31 0.25 0.08 0.44 0.09 0.30 0.34
9+
reg 0.11 0.00 0.26 0.58 7.99 0.00 0.28 0.59 0.09 0.11
10+
cla 0.00 0.00 0.00 0.00 0.00 9.07 0.23 0.00 0.23 0.48
11+
rock 0.14 0.90 1.10 0.80 0.35 0.29 5.31 0.01 1.09 0.01
12+
hip 0.71 0.14 0.56 0.18 1.96 0.00 0.19 6.10 0.03 0.14
13+
cou 0.25 0.15 0.84 0.64 0.08 0.10 1.87 0.00 5.84 0.24
14+
jazz 0.04 0.01 0.13 0.41 0.00 0.76 0.31 0.00 0.53 7.81
15+
```
16+
17+
Selected params: 0.01000
18+
19+
Classifier: SVM

models/music genre/svm_clf

620 KB
Binary file not shown.

models/music genre/svm_clf.arff

Lines changed: 916 additions & 0 deletions
Large diffs are not rendered by default.

models/music genre/svm_clfMEANS

2.18 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Confusion Matrix:
2+
```
3+
mus spe
4+
mus 48.80 1.20
5+
spe 0.60 49.40
6+
```
7+
8+
Selected params: 0.01000
9+
10+
Classifier: SVM

models/speechVSmusic/svm_clf

20.7 KB
Binary file not shown.

models/speechVSmusic/svm_clf.arff

Lines changed: 172 additions & 0 deletions
Large diffs are not rendered by default.

models/speechVSmusic/svm_clfMEANS

1.34 KB
Binary file not shown.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Confusion Matrix:
2+
```
3+
mus spe bir
4+
mus 31.53 0.73 1.07
5+
spe 1.00 32.33 0.00
6+
bir 0.00 0.00 33.33
7+
```
8+
9+
Selected params: 0.01000
10+
11+
Classifier: SVM

0 commit comments

Comments
 (0)