├── .gitignore ├── LICENSE ├── MANIFEST.in ├── README.md ├── bin └── feature_extraction ├── build ├── lib │ └── pyaudioclassification │ │ ├── __init__.py │ │ ├── feat_extract.py │ │ └── models.py ├── scripts-3.6 │ └── feature_extraction └── scripts-3.7 │ └── feature_extraction ├── example ├── cow_test.wav ├── data │ ├── 101 - Dog │ │ ├── 1-100032-A.ogg │ │ ├── 1-110389-A.ogg │ │ ├── 1-30226-A.ogg │ │ ├── 1-30344-A.ogg │ │ ├── 1-32318-A.ogg │ │ ├── 1-59513-A.ogg │ │ ├── 1-85362-A.ogg │ │ ├── 1-97392-A.ogg │ │ ├── 2-114280-A.ogg │ │ ├── 2-114587-A.ogg │ │ ├── 2-116400-A.ogg │ │ ├── 2-117271-A.ogg │ │ ├── 2-118072-A.ogg │ │ ├── 2-118964-A.ogg │ │ ├── 2-122104-A.ogg │ │ ├── 2-122104-B.ogg │ │ ├── 3-136288-A.ogg │ │ ├── 3-144028-A.ogg │ │ ├── 3-155312-A.ogg │ │ ├── 3-157695-A.ogg │ │ ├── 3-163459-A.ogg │ │ ├── 3-170015-A.ogg │ │ ├── 3-180256-A.ogg │ │ ├── 3-180977-A.ogg │ │ ├── 4-182395-A.ogg │ │ ├── 4-183992-A.ogg │ │ ├── 4-184575-A.ogg │ │ ├── 4-191687-A.ogg │ │ ├── 4-192236-A.ogg │ │ ├── 4-194754-A.ogg │ │ ├── 4-199261-A.ogg │ │ ├── 4-207124-A.ogg │ │ ├── 5-203128-A.ogg │ │ ├── 5-203128-B.ogg │ │ ├── 5-208030-A.ogg │ │ ├── 5-212454-A.ogg │ │ ├── 5-213855-A.ogg │ │ ├── 5-217158-A.ogg │ │ ├── 5-231762-A.ogg │ │ └── 5-9032-A.ogg │ ├── 102 - Rooster │ │ ├── 1-26806-A.ogg │ │ ├── 1-27724-A.ogg │ │ ├── 1-34119-A.ogg │ │ ├── 1-34119-B.ogg │ │ ├── 1-39923-A.ogg │ │ ├── 1-40730-A.ogg │ │ ├── 1-43382-A.ogg │ │ ├── 1-44831-A.ogg │ │ ├── 2-100786-A.ogg │ │ ├── 2-65750-A.ogg │ │ ├── 2-71162-A.ogg │ │ ├── 2-81270-A.ogg │ │ ├── 2-95035-A.ogg │ │ ├── 2-95258-A.ogg │ │ ├── 2-95258-B.ogg │ │ ├── 2-96460-A.ogg │ │ ├── 3-107219-A.ogg │ │ ├── 3-116135-A.ogg │ │ ├── 3-134049-A.ogg │ │ ├── 3-137152-A.ogg │ │ ├── 3-145382-A.ogg │ │ ├── 3-149189-A.ogg │ │ ├── 3-154957-A.ogg │ │ ├── 3-163288-A.ogg │ │ ├── 4-164021-A.ogg │ │ ├── 4-164064-A.ogg │ │ ├── 4-164064-B.ogg │ │ ├── 4-164064-C.ogg │ │ ├── 4-164859-A.ogg │ │ ├── 4-170078-A.ogg │ │ ├── 4-183487-A.ogg │ │ ├── 4-208021-A.ogg │ │ ├── 5-194930-A.ogg │ │ ├── 5-194930-B.ogg │ │ ├── 5-200334-A.ogg │ │ ├── 5-200334-B.ogg │ │ ├── 5-200339-A.ogg │ │ ├── 5-233160-A.ogg │ │ ├── 5-234879-A.ogg │ │ └── 5-234879-B.ogg │ ├── 103 - Pig │ │ ├── 1-208757-A.ogg │ │ ├── 1-208757-B.ogg │ │ ├── 1-208757-C.ogg │ │ ├── 1-208757-D.ogg │ │ ├── 1-208757-E.ogg │ │ ├── 1-260640-A.ogg │ │ ├── 1-260640-B.ogg │ │ ├── 1-260640-C.ogg │ │ ├── 2-158746-A.ogg │ │ ├── 2-158746-B.ogg │ │ ├── 2-158746-C.ogg │ │ ├── 2-158746-D.ogg │ │ ├── 2-166644-A.ogg │ │ ├── 2-166644-B.ogg │ │ ├── 2-166644-C.ogg │ │ ├── 2-37870-A.ogg │ │ ├── 3-233151-A.ogg │ │ ├── 3-253081-A.ogg │ │ ├── 3-253084-A.ogg │ │ ├── 3-253084-B.ogg │ │ ├── 3-253084-C.ogg │ │ ├── 3-253084-D.ogg │ │ ├── 3-253084-E.ogg │ │ ├── 3-257858-A.ogg │ │ ├── 4-132383-A.ogg │ │ ├── 4-132383-B.ogg │ │ ├── 4-147240-A.ogg │ │ ├── 4-147240-B.ogg │ │ ├── 4-234644-A.ogg │ │ ├── 4-250869-A.ogg │ │ ├── 4-250869-B.ogg │ │ ├── 4-250869-C.ogg │ │ ├── 5-103415-A.ogg │ │ ├── 5-103416-A.ogg │ │ ├── 5-103418-A.ogg │ │ ├── 5-103420-A.ogg │ │ ├── 5-103421-A.ogg │ │ ├── 5-103422-A.ogg │ │ ├── 5-117250-A.ogg │ │ └── 5-127990-A.ogg │ ├── 104 - Cow │ │ ├── 1-16568-A.ogg │ │ ├── 1-202111-A.ogg │ │ ├── 1-58277-A.ogg │ │ ├── 1-69422-A.ogg │ │ ├── 1-69641-A.ogg │ │ ├── 1-77160-A.ogg │ │ ├── 1-77241-A.ogg │ │ ├── 1-81269-A.ogg │ │ ├── 2-103423-A.ogg │ │ ├── 2-103424-A.ogg │ │ ├── 2-103426-A.ogg │ │ ├── 2-103427-A.ogg │ │ ├── 2-103428-A.ogg │ │ ├── 2-104877-A.ogg │ │ ├── 2-117795-A.ogg │ │ ├── 2-117795-B.ogg │ │ ├── 3-124376-A.ogg │ │ ├── 3-124376-B.ogg │ │ ├── 3-126358-A.ogg │ │ ├── 3-126358-B.ogg │ │ ├── 3-152039-A.ogg │ │ ├── 3-152039-B.ogg │ │ ├── 3-160993-A.ogg │ │ ├── 3-163727-A.ogg │ │ ├── 4-174860-A.ogg │ │ ├── 4-174860-B.ogg │ │ ├── 4-181955-A.ogg │ │ ├── 4-181955-B.ogg │ │ ├── 4-181955-C.ogg │ │ ├── 4-213915-A.ogg │ │ ├── 4-213915-B.ogg │ │ ├── 4-213915-C.ogg │ │ ├── 5-194899-A.ogg │ │ ├── 5-194899-B.ogg │ │ ├── 5-194899-C.ogg │ │ ├── 5-194899-D.ogg │ │ ├── 5-202795-A.ogg │ │ ├── 5-242492-A.ogg │ │ ├── 5-253085-A.ogg │ │ └── 5-253085-B.ogg │ └── 105 - Frog │ │ ├── 1-15689-A.ogg │ │ ├── 1-15689-B.ogg │ │ ├── 1-17970-A.ogg │ │ ├── 1-18755-A.ogg │ │ ├── 1-18755-B.ogg │ │ ├── 1-18757-A.ogg │ │ ├── 1-31836-A.ogg │ │ ├── 1-31836-B.ogg │ │ ├── 2-32515-A.ogg │ │ ├── 2-32515-B.ogg │ │ ├── 2-32515-C.ogg │ │ ├── 2-32515-D.ogg │ │ ├── 2-32834-A.ogg │ │ ├── 2-52085-A.ogg │ │ ├── 2-52085-B.ogg │ │ ├── 2-52789-A.ogg │ │ ├── 3-102908-A.ogg │ │ ├── 3-70962-A.ogg │ │ ├── 3-70962-B.ogg │ │ ├── 3-70962-C.ogg │ │ ├── 3-71964-A.ogg │ │ ├── 3-71964-B.ogg │ │ ├── 3-71964-C.ogg │ │ ├── 3-83527-A.ogg │ │ ├── 4-130584-A.ogg │ │ ├── 4-154793-A.ogg │ │ ├── 4-99193-A.ogg │ │ ├── 4-99193-B.ogg │ │ ├── 4-99644-A.ogg │ │ ├── 4-99644-B.ogg │ │ ├── 4-99644-C.ogg │ │ ├── 4-99644-D.ogg │ │ ├── 5-156026-A.ogg │ │ ├── 5-156026-B.ogg │ │ ├── 5-156026-C.ogg │ │ ├── 5-156026-D.ogg │ │ ├── 5-187201-A.ogg │ │ ├── 5-187201-B.ogg │ │ ├── 5-189795-A.ogg │ │ └── 5-237499-A.ogg ├── feat.npy ├── label.npy ├── model.h5 └── test.py ├── pyaudioclassification ├── __init__.py ├── feat_extract.py ├── models.py └── tests │ ├── __init__.py │ ├── data │ ├── cat │ │ ├── 1-34094-A.ogg │ │ └── 1-34094-B.ogg │ └── dog │ │ ├── 1-30226-A.ogg │ │ └── 1-30344-A.ogg │ ├── saved │ ├── feat.npy │ └── label.npy │ └── test.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled python modules. 2 | *.pyc 3 | 4 | # Setuptools distribution folder. 5 | /dist/ 6 | 7 | # Python egg metadata, regenerated from source files by setuptools. 8 | /*.egg-info 9 | /*.egg 10 | 11 | *.DS_Store 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Micah Price 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.md 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pyAudioClassification 2 | Dead simple audio classification 3 | 4 | ![PyPI - Python Version](https://img.shields.io/badge/python-3.1.0-blue.svg) 5 | [![PyPI](https://img.shields.io/badge/pypi-v0.1.3-blue.svg)](https://pypi.org/project/pyaudioclassification/) 6 | ## Who is this for? 👩‍💻 👨‍💻 7 | People who just want to classify some audio quickly, without having to dive into the world of audio analysis. 8 | If you need something a little more involved, check out [pyAudioAnalysis](https://github.com/tyiannak/pyAudioAnalysis) or [panotti](https://github.com/drscotthawley/panotti) 9 | 10 | ## Quick install 11 | ``` 12 | pip install pyaudioclassification 13 | ``` 14 | 15 | ### Requirements 16 | * __Python 3__ 17 | * Keras 18 | * Tensorflow 19 | * librosa 20 | * NumPy 21 | * Soundfile 22 | * tqdm 23 | * matplotlib 24 | 25 | ## Quick start 26 | ```python 27 | from pyaudioclassification import feature_extraction, train, predict 28 | features, labels = feature_extraction() 29 | model = train(features, labels) 30 | pred = predict(model, ) 31 | ``` 32 | 33 | Or, if you're feeling reckless, you could just string them together like so: 34 | ```python 35 | pred = predict(train(feature_extraction()), ) 36 | ``` 37 | 38 | A full example with saving, loading & some dummy data can be found [here](https://github.com/98mprice/pyAudioClassification/blob/master/example/test.py). 39 | 40 | --- 41 | 42 | Read below for a more detailed look at each of these calls. 43 | 44 | ## Detailed Guide 45 | ### Step 1: Preprocessing 🐶 🐱 46 | First, add all your audio files to a directory in the following structure 47 | ``` 48 | data/ 49 | ├── / 50 | │ ├── 51 | │ └── ... 52 | └── ... 53 | ``` 54 | 55 | For example, if you were trying to classify dog and cat sounds it might look like this 56 | ``` 57 | data/ 58 | ├── cat/ 59 | │ ├── cat1.ogg 60 | │ ├── cat2.ogg 61 | │ ├── cat3.wav 62 | │ └── cat4.wav 63 | └── dog/ 64 | ├── dog1.ogg 65 | ├── dog2.ogg 66 | ├── dog3.wav 67 | └── dog4.wav 68 | ``` 69 | 70 | Great, now we need to preprocess this data. Just call `feature_extraction()` and it'll return our input and target data. 71 | Something like this: 72 | ```python 73 | features, labels = feature_extraction('/Users/mac2015/data/') 74 | ``` 75 | 76 | (If you don't want to print to stdout, just pass `verbose=False` as a argument) 77 | 78 | --- 79 | Depending on how much data you have, this process could take a while... so it might be a good idea to save. You can save and load with [NumPy](https://www.numpy.org/) 80 | ```python 81 | np.save('%s.npy' % , features) 82 | features = np.load('%s.npy' % ) 83 | ``` 84 | 85 | ### Step 2: Training 💪 86 | Next step is to train your model on the data. You can just call... 87 | ```python 88 | model = train(features, labels) 89 | ``` 90 | ...but depending on your dataset, you might need to play around with some of the hyper-parameters to get the best results. 91 | 92 | #### Options 93 | * `epochs`: The number of iterations. Default is `50`. 94 | 95 | * `lr`: Learning rate. Increase to speed up training time, decrease to get more accurate results (if your loss is 'jumping'). Default is `0.01`. 96 | 97 | * `optimiser`: Choose any of [these](https://keras.io/optimizers/). Default is `'SGD'`. 98 | 99 | * `print_summary`: Prints a summary of the model you'll be training. Default is `False`. 100 | 101 | * `loss_type`: Classification type. Default is `categorical` for >2 classes, and `binary` otherwise. 102 | 103 | You can add any of these as optional arguments, for example `train(features, labels, lr=0.05)` 104 | 105 | --- 106 | Again, you probably want to save your model once it's done training. You can do this with Keras: 107 | ```python 108 | from keras.models import load_model 109 | 110 | model.save('my_model.h5') 111 | model = load_model('my_model.h5') 112 | ``` 113 | 114 | ### Step 3: Prediction 🙏 🙌 115 | Now the fun part- try your trained model on new data! 116 | 117 | ```python 118 | pred = predict(model, ) 119 | ``` 120 | 121 | Your `` should point to a new, untested audio file. 122 | 123 | #### Binary 124 | If you have 2 classes (or if you force selected `'binary'` as a type), `pred` will just be a single number for each file. 125 | 126 | The closer it is to 0, the closer the prediction is for the first class, and the closer it is to 1 the closer the prediction is to the second class. 127 | 128 | So for our cat/dog example, if it returns `0.2` it's 80% sure the sound is a cat, and if it returns `0.8` it's 80% sure it's a dog. 129 | 130 | #### Categorical 131 | If you have more than 2 classes (or if you force selected `'categorical'` as a type), `pred` will be an array for each sound file. 132 | 133 | It'll look something like this 134 | ``` 135 | [[1.6454633e-06 3.7017996e-11 9.9999821e-01 1.5900606e-07]] 136 | ``` 137 | 138 | The index of each item in the array will correspond to the prediction for that class. 139 | 140 | --- 141 | You can pretty print the predictions by showing them in a leaderboard, like so: 142 | 143 | ```python 144 | print_leaderboard(pred, ) 145 | ``` 146 | It looks like this: 147 | 148 | ``` 149 | 1. Cow 100.0% (index 2) 150 | 2. Rooster 0.0% (index 0) 151 | 3. Frog 0.0% (index 3) 152 | 4. Pig 0.0% (index 1) 153 | ``` 154 | 155 | ## References 156 | * Large parts of the code (particularly the feature extraction) are based on [mtobeiyf/audio-classification](https://github.com/mtobeiyf/audio-classification) 157 | * [panotti](https://github.com/drscotthawley/panotti) 158 | -------------------------------------------------------------------------------- /bin/feature_extraction: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | from argparse import ArgumentParser 4 | from pyaudioclassification import feat_extract 5 | 6 | parser = ArgumentParser() 7 | parser.add_argument("-i", "--input", dest="input", 8 | help="path to data directory") 9 | parser.add_argument("-m", "--mode", dest="mode", 10 | help="add to force either 'binary' or 'categorical' crossentropy") 11 | parser.add_argument("-t", "--t", dest="type", default="CNN", 12 | help="type of ML model to train. can be either 'SVM', 'NN', or 'CNN'. defaults to CNN") 13 | 14 | args = parser.parse_args() 15 | if (args.input == None): 16 | raise ValueError("No input directory provided. Use the -i flag to specifiy the directory where your data is stored.") 17 | 18 | feature_extraction(args.input) 19 | -------------------------------------------------------------------------------- /build/lib/pyaudioclassification/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | import os 3 | from pyaudioclassification.feat_extract import parse_audio_files, parse_audio_file 4 | import numpy as np 5 | import pyaudioclassification.models 6 | from keras.utils import to_categorical 7 | from keras.optimizers import SGD 8 | #from models import svm, nn, cnn 9 | 10 | def feature_extraction(data_path): 11 | """Parses audio files in supplied data path. 12 | -*- author: mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 13 | """ 14 | r = os.listdir(data_path) 15 | r.sort() 16 | features, labels = parse_audio_files(data_path, r) 17 | return features, labels 18 | 19 | def train(features, labels, type='cnn', num_classes=None, print_summary=False, 20 | save_model=False, lr=0.01, loss_type=None, epochs=50, optimizer='SGD', verbose=True): 21 | """Trains model based on provided feature & target data 22 | Options: 23 | - epochs: The number of iterations. Default is 50. 24 | - lr: Learning rate. Increase to speed up training time, decrease to get more accurate results (if your loss is 'jumping'). Default is 0.01. 25 | - optimiser: Default is 'SGD'. 26 | - print_summary: Prints a summary of the model you'll be training. Default is False. 27 | - loss_type: Classification type. Default is categorical for >2 classes, and binary otherwise. 28 | """ 29 | labels = labels.ravel() 30 | if num_classes == None: num_classes = np.max(labels, axis=0) 31 | 32 | model = getattr(models, type)(num_classes) 33 | if print_summary == True: model.summary() 34 | 35 | if loss_type == None: 36 | loss_type = 'binary' if num_classes <= 2 else 'categorical' 37 | model.compile(optimizer=SGD(lr=lr), 38 | loss='%s_crossentropy' % loss_type, 39 | metrics=['accuracy']) 40 | 41 | if loss_type == 'categorical': 42 | y = to_categorical(labels - 1, num_classes=num_classes) 43 | else: 44 | y = labels - 1 45 | 46 | x = np.expand_dims(features, axis=2) 47 | 48 | model.fit(x, y, batch_size=64, epochs=epochs, verbose=verbose) 49 | 50 | return model 51 | 52 | def predict(model, data_path): 53 | """Trains model based on provided feature & target data 54 | Options: 55 | - epochs: The number of iterations. Default is 50. 56 | - lr: Learning rate. Increase to speed up training time, decrease to get more accurate results (if your loss is 'jumping'). Default is 0.01. 57 | - optimiser: Default is 'SGD'. 58 | - print_summary: Prints a summary of the model you'll be training. Default is False. 59 | - type: Classification type. Default is categorical for >2 classes, and binary otherwise. 60 | """ 61 | x_data = parse_audio_file(data_path) 62 | X_train = np.expand_dims(x_data, axis=2) 63 | pred = model.predict(X_train) 64 | return pred 65 | 66 | def print_leaderboard(pred, data_path): 67 | """Pretty prints leaderboard of top matches 68 | """ 69 | r = os.listdir(data_path) 70 | r.sort() 71 | sorted = np.argsort(pred) 72 | count = 0 73 | for index in (-pred).argsort()[0]: 74 | print('%d.' % (count + 1), r[index + 1], str(round(pred[0][index]*100)) + '%', '(index %s)' % index) 75 | count += 1 76 | -------------------------------------------------------------------------------- /build/lib/pyaudioclassification/feat_extract.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | import librosa 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | from matplotlib.pyplot import specgram 7 | import soundfile as sf 8 | from tqdm import tqdm 9 | 10 | def extract_feature(file_name): 11 | """Generates feature input (mfccs, chroma, mel, contrast, tonnetz). 12 | -*- author: mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 13 | """ 14 | X, sample_rate = sf.read(file_name, dtype='float32') 15 | if X.ndim > 1: 16 | X = X[:,0] 17 | X = X.T 18 | 19 | stft = np.abs(librosa.stft(X)) 20 | mfccs = np.mean(librosa.feature.mfcc(y=X, sr=sample_rate, n_mfcc=40).T,axis=0) 21 | chroma = np.mean(librosa.feature.chroma_stft(S=stft, sr=sample_rate).T,axis=0) 22 | mel = np.mean(librosa.feature.melspectrogram(X, sr=sample_rate).T,axis=0) 23 | contrast = np.mean(librosa.feature.spectral_contrast(S=stft, sr=sample_rate).T,axis=0) 24 | tonnetz = np.mean(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=sample_rate).T,axis=0) 25 | return mfccs, chroma, mel, contrast, tonnetz 26 | 27 | def parse_audio_files(parent_dir, sub_dirs, file_ext=None, verbose=True): 28 | """Parses directory in search of specified file types, then compiles feature data from them. 29 | -*- adapted from code by mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 30 | """ 31 | # by default test for only these types 32 | if file_ext == None: 33 | file_types = ['*.ogg', '*.wav'] 34 | else: 35 | file_types = [] 36 | file_types.push(file_ext) 37 | features, labels = np.empty((0,193)), np.empty(0) 38 | for label, sub_dir in enumerate(sub_dirs): 39 | for file_ext in file_types: 40 | # file names 41 | iter = glob.glob(os.path.join(parent_dir, sub_dir, file_ext)) 42 | if len(iter) > 0: 43 | if verbose: print('Reading', os.path.join(parent_dir, sub_dir, file_ext), '...') 44 | for fn in tqdm(iter): 45 | ext_features = get_ext_features(fn) 46 | if type(ext_features) is np.ndarray: 47 | features = np.vstack([features, ext_features]) 48 | labels = np.append(labels, label) 49 | return np.array(features), np.array(labels, dtype = np.int) 50 | 51 | def get_ext_features(fn): 52 | """Returns features for individual audio file. 53 | -*- adapted from code by mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 54 | """ 55 | try: 56 | mfccs, chroma, mel, contrast, tonnetz = extract_feature(fn) 57 | ext_features = np.hstack([mfccs, chroma, mel, contrast, tonnetz]) 58 | return ext_features 59 | except Exception as e: 60 | print("[Error] extract feature error. %s" % (e)) 61 | return None 62 | 63 | def parse_audio_file(fn): 64 | """Returns features of single audio file 65 | -*- adapted from code by mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 66 | """ 67 | features = np.empty((0,193)) 68 | ext_features = get_ext_features(fn) 69 | features = np.vstack([features,ext_features]) 70 | return np.array(features) 71 | -------------------------------------------------------------------------------- /build/lib/pyaudioclassification/models.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from keras.models import Sequential 3 | from keras.layers import Dense, Dropout, Activation 4 | 5 | def svm(num_classes): 6 | """Support vector machine. 7 | -*- ref: mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 8 | """ 9 | from sklearn.svm import SVC 10 | 11 | return SVC(C=20.0, gamma=0.00001) 12 | 13 | def nn(num_classes): 14 | """Multi-layer perceptron. 15 | """ 16 | model = Sequential() 17 | model.add(Dense(256, input_dim=193)) 18 | model.add(Activation('relu')) 19 | model.add(Dropout(0.6)) 20 | model.add(Dense(512)) 21 | model.add(Activation('relu')) 22 | model.add(Dropout(0.6)) 23 | model.add(Dense(num_classes)) 24 | model.add(Activation('softmax')) 25 | 26 | return model 27 | 28 | def cnn(num_classes): 29 | """1D Convolutional Neural Network. 30 | -*- ref: panotti https://github.com/drscotthawley/panotti -*- 31 | """ 32 | from keras.layers import Embedding 33 | from keras.layers import Conv1D, GlobalAveragePooling1D, MaxPooling1D 34 | 35 | activation = 'softmax' if num_classes > 2 else 'sigmoid' 36 | model = Sequential() 37 | model.add(Conv1D(64, 3, input_shape=(193, 1))) 38 | model.add(Activation('relu')) 39 | model.add(Conv1D(64, 3)) 40 | model.add(Activation('relu')) 41 | model.add(MaxPooling1D(3)) 42 | model.add(Conv1D(128, 3)) 43 | model.add(Activation('relu')) 44 | model.add(Conv1D(128, 3)) 45 | model.add(Activation('relu')) 46 | model.add(GlobalAveragePooling1D()) 47 | model.add(Dropout(0.5)) 48 | model.add(Dense(num_classes)) 49 | model.add(Activation(activation)) 50 | 51 | return model 52 | 53 | def cnn2d(num_classes): 54 | """2D Convolutional Neural Network. 55 | -*- ref: panotti https://github.com/drscotthawley/panotti -*- 56 | """ 57 | model.add(Conv2D(32, (3, 3), padding='valid', input_shape=(193, 1))) 58 | model.add(BatchNormalization(axis=1)) 59 | model.add(Activation('relu')) 60 | 61 | for layer in range(3): 62 | model.add(Conv2D(32, (3, 3))) 63 | model.add(Activation('elu')) 64 | model.add(MaxPooling2D(pool_size=(2, 2))) 65 | model.add(Dropout(0.5)) 66 | 67 | model.add(Flatten()) 68 | model.add(Dense(128)) 69 | model.add(Activation('elu')) 70 | model.add(Dropout(0.5)) 71 | model.add(Dense(nb_classes)) 72 | model.add(Activation("softmax")) 73 | -------------------------------------------------------------------------------- /build/scripts-3.6/feature_extraction: -------------------------------------------------------------------------------- 1 | #!python 2 | 3 | from argparse import ArgumentParser 4 | from pyaudioclassification import feat_extract 5 | 6 | parser = ArgumentParser() 7 | parser.add_argument("-i", "--input", dest="input", 8 | help="path to data directory") 9 | parser.add_argument("-m", "--mode", dest="mode", 10 | help="add to force either 'binary' or 'categorical' crossentropy") 11 | parser.add_argument("-t", "--t", dest="type", default="CNN", 12 | help="type of ML model to train. can be either 'SVM', 'NN', or 'CNN'. defaults to CNN") 13 | 14 | args = parser.parse_args() 15 | if (args.input == None): 16 | raise ValueError("No input directory provided. Use the -i flag to specifiy the directory where your data is stored.") 17 | 18 | feature_extraction(args.input) 19 | -------------------------------------------------------------------------------- /build/scripts-3.7/feature_extraction: -------------------------------------------------------------------------------- 1 | #!python 2 | 3 | from argparse import ArgumentParser 4 | from pyaudioclassification import feat_extract 5 | 6 | parser = ArgumentParser() 7 | parser.add_argument("-i", "--input", dest="input", 8 | help="path to data directory") 9 | parser.add_argument("-m", "--mode", dest="mode", 10 | help="add to force either 'binary' or 'categorical' crossentropy") 11 | parser.add_argument("-t", "--t", dest="type", default="CNN", 12 | help="type of ML model to train. can be either 'SVM', 'NN', or 'CNN'. defaults to CNN") 13 | 14 | args = parser.parse_args() 15 | if (args.input == None): 16 | raise ValueError("No input directory provided. Use the -i flag to specifiy the directory where your data is stored.") 17 | 18 | feature_extraction(args.input) 19 | -------------------------------------------------------------------------------- /example/cow_test.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/cow_test.wav -------------------------------------------------------------------------------- /example/data/101 - Dog/1-100032-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-100032-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-110389-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-110389-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-30226-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-30226-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-30344-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-30344-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-32318-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-32318-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-59513-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-59513-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-85362-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-85362-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/1-97392-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/1-97392-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-114280-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-114280-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-114587-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-114587-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-116400-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-116400-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-117271-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-117271-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-118072-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-118072-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-118964-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-118964-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-122104-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-122104-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/2-122104-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/2-122104-B.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-136288-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-136288-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-144028-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-144028-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-155312-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-155312-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-157695-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-157695-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-163459-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-163459-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-170015-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-170015-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-180256-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-180256-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/3-180977-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/3-180977-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-182395-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-182395-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-183992-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-183992-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-184575-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-184575-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-191687-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-191687-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-192236-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-192236-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-194754-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-194754-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-199261-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-199261-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/4-207124-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/4-207124-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-203128-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-203128-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-203128-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-203128-B.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-208030-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-208030-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-212454-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-212454-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-213855-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-213855-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-217158-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-217158-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-231762-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-231762-A.ogg -------------------------------------------------------------------------------- /example/data/101 - Dog/5-9032-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/101 - Dog/5-9032-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-26806-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-26806-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-27724-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-27724-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-34119-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-34119-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-34119-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-34119-B.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-39923-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-39923-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-40730-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-40730-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-43382-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-43382-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/1-44831-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/1-44831-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-100786-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-100786-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-65750-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-65750-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-71162-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-71162-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-81270-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-81270-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-95035-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-95035-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-95258-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-95258-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-95258-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-95258-B.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/2-96460-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/2-96460-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-107219-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-107219-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-116135-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-116135-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-134049-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-134049-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-137152-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-137152-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-145382-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-145382-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-149189-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-149189-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-154957-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-154957-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/3-163288-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/3-163288-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-164021-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-164021-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-164064-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-164064-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-164064-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-164064-B.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-164064-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-164064-C.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-164859-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-164859-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-170078-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-170078-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-183487-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-183487-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/4-208021-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/4-208021-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-194930-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-194930-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-194930-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-194930-B.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-200334-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-200334-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-200334-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-200334-B.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-200339-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-200339-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-233160-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-233160-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-234879-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-234879-A.ogg -------------------------------------------------------------------------------- /example/data/102 - Rooster/5-234879-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/102 - Rooster/5-234879-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-208757-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-208757-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-208757-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-208757-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-208757-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-208757-C.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-208757-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-208757-D.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-208757-E.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-208757-E.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-260640-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-260640-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-260640-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-260640-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/1-260640-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/1-260640-C.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-158746-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-158746-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-158746-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-158746-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-158746-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-158746-C.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-158746-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-158746-D.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-166644-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-166644-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-166644-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-166644-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-166644-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-166644-C.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/2-37870-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/2-37870-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-233151-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-233151-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-253081-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-253081-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-253084-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-253084-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-253084-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-253084-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-253084-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-253084-C.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-253084-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-253084-D.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-253084-E.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-253084-E.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/3-257858-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/3-257858-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-132383-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-132383-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-132383-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-132383-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-147240-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-147240-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-147240-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-147240-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-234644-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-234644-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-250869-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-250869-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-250869-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-250869-B.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/4-250869-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/4-250869-C.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-103415-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-103415-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-103416-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-103416-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-103418-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-103418-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-103420-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-103420-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-103421-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-103421-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-103422-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-103422-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-117250-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-117250-A.ogg -------------------------------------------------------------------------------- /example/data/103 - Pig/5-127990-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/103 - Pig/5-127990-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-16568-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-16568-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-202111-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-202111-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-58277-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-58277-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-69422-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-69422-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-69641-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-69641-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-77160-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-77160-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-77241-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-77241-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/1-81269-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/1-81269-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-103423-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-103423-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-103424-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-103424-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-103426-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-103426-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-103427-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-103427-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-103428-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-103428-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-104877-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-104877-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-117795-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-117795-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/2-117795-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/2-117795-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-124376-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-124376-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-124376-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-124376-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-126358-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-126358-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-126358-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-126358-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-152039-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-152039-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-152039-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-152039-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-160993-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-160993-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/3-163727-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/3-163727-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-174860-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-174860-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-174860-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-174860-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-181955-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-181955-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-181955-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-181955-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-181955-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-181955-C.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-213915-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-213915-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-213915-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-213915-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/4-213915-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/4-213915-C.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-194899-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-194899-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-194899-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-194899-B.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-194899-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-194899-C.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-194899-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-194899-D.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-202795-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-202795-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-242492-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-242492-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-253085-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-253085-A.ogg -------------------------------------------------------------------------------- /example/data/104 - Cow/5-253085-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/104 - Cow/5-253085-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-15689-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-15689-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-15689-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-15689-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-17970-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-17970-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-18755-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-18755-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-18755-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-18755-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-18757-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-18757-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-31836-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-31836-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/1-31836-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/1-31836-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-32515-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-32515-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-32515-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-32515-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-32515-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-32515-C.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-32515-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-32515-D.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-32834-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-32834-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-52085-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-52085-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-52085-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-52085-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/2-52789-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/2-52789-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-102908-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-102908-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-70962-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-70962-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-70962-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-70962-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-70962-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-70962-C.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-71964-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-71964-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-71964-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-71964-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-71964-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-71964-C.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/3-83527-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/3-83527-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-130584-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-130584-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-154793-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-154793-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-99193-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-99193-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-99193-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-99193-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-99644-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-99644-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-99644-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-99644-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-99644-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-99644-C.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/4-99644-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/4-99644-D.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-156026-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-156026-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-156026-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-156026-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-156026-C.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-156026-C.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-156026-D.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-156026-D.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-187201-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-187201-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-187201-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-187201-B.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-189795-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-189795-A.ogg -------------------------------------------------------------------------------- /example/data/105 - Frog/5-237499-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/data/105 - Frog/5-237499-A.ogg -------------------------------------------------------------------------------- /example/feat.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/feat.npy -------------------------------------------------------------------------------- /example/label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/label.npy -------------------------------------------------------------------------------- /example/model.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/example/model.h5 -------------------------------------------------------------------------------- /example/test.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from pyaudioclassification import feature_extraction, train, predict, print_leaderboard 3 | 4 | parent_dir = '.' 5 | 6 | # step 1: preprocessing 7 | if np.DataSource().exists("./feat.npy") and np.DataSource().exists("./label.npy"): 8 | features, labels = np.load('./feat.npy'), np.load('./label.npy') 9 | else: 10 | features, labels = feature_extraction('./data/') 11 | np.save('./feat.npy', features) 12 | np.save('./label.npy', labels) 13 | 14 | # step 2: training 15 | if np.DataSource().exists("./model.h5"): 16 | from keras.models import load_model 17 | model = load_model('./model.h5') 18 | else: 19 | model = train(features, labels, epochs=100) 20 | model.save('./model.h5') 21 | 22 | # step 3: prediction 23 | pred = predict(model, './cow_test.wav') 24 | print_leaderboard(pred, './data/') 25 | -------------------------------------------------------------------------------- /pyaudioclassification/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | import os 3 | from pyaudioclassification.feat_extract import parse_audio_files, parse_audio_file 4 | import numpy as np 5 | import pyaudioclassification.models 6 | from keras.utils import to_categorical 7 | from keras.optimizers import SGD 8 | #from models import svm, nn, cnn 9 | 10 | def feature_extraction(data_path): 11 | """Parses audio files in supplied data path. 12 | -*- author: mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 13 | """ 14 | r = os.listdir(data_path) 15 | r.sort() 16 | features, labels = parse_audio_files(data_path, r) 17 | return features, labels 18 | 19 | def train(features, labels, type='cnn', num_classes=None, print_summary=False, 20 | save_model=False, lr=0.01, loss_type=None, epochs=50, optimizer='SGD', verbose=True): 21 | """Trains model based on provided feature & target data 22 | Options: 23 | - epochs: The number of iterations. Default is 50. 24 | - lr: Learning rate. Increase to speed up training time, decrease to get more accurate results (if your loss is 'jumping'). Default is 0.01. 25 | - optimiser: Default is 'SGD'. 26 | - print_summary: Prints a summary of the model you'll be training. Default is False. 27 | - loss_type: Classification type. Default is categorical for >2 classes, and binary otherwise. 28 | """ 29 | labels = labels.ravel() 30 | if num_classes == None: num_classes = np.max(labels, axis=0) 31 | 32 | model = getattr(models, type)(num_classes) 33 | if print_summary == True: model.summary() 34 | 35 | if loss_type == None: 36 | loss_type = 'binary' if num_classes <= 2 else 'categorical' 37 | model.compile(optimizer=SGD(lr=lr), 38 | loss='%s_crossentropy' % loss_type, 39 | metrics=['accuracy']) 40 | 41 | if loss_type == 'categorical': 42 | y = to_categorical(labels - 1, num_classes=num_classes) 43 | else: 44 | y = labels - 1 45 | 46 | x = np.expand_dims(features, axis=2) 47 | 48 | model.fit(x, y, batch_size=64, epochs=epochs, verbose=verbose) 49 | 50 | return model 51 | 52 | def predict(model, data_path): 53 | """Trains model based on provided feature & target data 54 | Options: 55 | - epochs: The number of iterations. Default is 50. 56 | - lr: Learning rate. Increase to speed up training time, decrease to get more accurate results (if your loss is 'jumping'). Default is 0.01. 57 | - optimiser: Default is 'SGD'. 58 | - print_summary: Prints a summary of the model you'll be training. Default is False. 59 | - type: Classification type. Default is categorical for >2 classes, and binary otherwise. 60 | """ 61 | x_data = parse_audio_file(data_path) 62 | X_train = np.expand_dims(x_data, axis=2) 63 | pred = model.predict(X_train) 64 | return pred 65 | 66 | def print_leaderboard(pred, data_path): 67 | """Pretty prints leaderboard of top matches 68 | """ 69 | r = os.listdir(data_path) 70 | r.sort() 71 | sorted = np.argsort(pred) 72 | count = 0 73 | for index in (-pred).argsort()[0]: 74 | print('%d.' % (count + 1), r[index + 1], str(round(pred[0][index]*100)) + '%', '(index %s)' % index) 75 | count += 1 76 | -------------------------------------------------------------------------------- /pyaudioclassification/feat_extract.py: -------------------------------------------------------------------------------- 1 | import glob 2 | import os 3 | import librosa 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | from matplotlib.pyplot import specgram 7 | import soundfile as sf 8 | from tqdm import tqdm 9 | 10 | def extract_feature(file_name): 11 | """Generates feature input (mfccs, chroma, mel, contrast, tonnetz). 12 | -*- author: mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 13 | """ 14 | X, sample_rate = sf.read(file_name, dtype='float32') 15 | if X.ndim > 1: 16 | X = X[:,0] 17 | X = X.T 18 | X = np.asfortranarray(X) 19 | stft = np.abs(librosa.stft(X)) 20 | mfccs = np.mean(librosa.feature.mfcc(y=X, sr=sample_rate, n_mfcc=40).T,axis=0) 21 | chroma = np.mean(librosa.feature.chroma_stft(S=stft, sr=sample_rate).T,axis=0) 22 | mel = np.mean(librosa.feature.melspectrogram(X, sr=sample_rate).T,axis=0) 23 | contrast = np.mean(librosa.feature.spectral_contrast(S=stft, sr=sample_rate).T,axis=0) 24 | tonnetz = np.mean(librosa.feature.tonnetz(y=librosa.effects.harmonic(X), sr=sample_rate).T,axis=0) 25 | return mfccs, chroma, mel, contrast, tonnetz 26 | 27 | def parse_audio_files(parent_dir, sub_dirs, file_ext=None, verbose=True): 28 | """Parses directory in search of specified file types, then compiles feature data from them. 29 | -*- adapted from code by mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 30 | """ 31 | # by default test for only these types 32 | if file_ext == None: 33 | file_types = ['*.ogg', '*.wav'] 34 | else: 35 | file_types = [] 36 | file_types.push(file_ext) 37 | features, labels = np.empty((0,193)), np.empty(0) 38 | for label, sub_dir in enumerate(sub_dirs): 39 | for file_ext in file_types: 40 | # file names 41 | iter = glob.glob(os.path.join(parent_dir, sub_dir, file_ext)) 42 | if len(iter) > 0: 43 | if verbose: print('Reading', os.path.join(parent_dir, sub_dir, file_ext), '...') 44 | for fn in tqdm(iter): 45 | ext_features = get_ext_features(fn) 46 | if type(ext_features) is np.ndarray: 47 | features = np.vstack([features, ext_features]) 48 | labels = np.append(labels, label) 49 | return np.array(features), np.array(labels, dtype = np.int) 50 | 51 | def get_ext_features(fn): 52 | """Returns features for individual audio file. 53 | -*- adapted from code by mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 54 | """ 55 | try: 56 | mfccs, chroma, mel, contrast, tonnetz = extract_feature(fn) 57 | ext_features = np.hstack([mfccs, chroma, mel, contrast, tonnetz]) 58 | return ext_features 59 | except Exception as e: 60 | print("[Error] extract feature error. %s" % (e)) 61 | return None 62 | 63 | def parse_audio_file(fn): 64 | """Returns features of single audio file 65 | -*- adapted from code by mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 66 | """ 67 | features = np.empty((0,193)) 68 | ext_features = get_ext_features(fn) 69 | features = np.vstack([features,ext_features]) 70 | return np.array(features) 71 | -------------------------------------------------------------------------------- /pyaudioclassification/models.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from keras.models import Sequential 3 | from keras.layers import Dense, Dropout, Activation 4 | 5 | def svm(num_classes): 6 | """Support vector machine. 7 | -*- ref: mtobeiyf https://github.com/mtobeiyf/audio-classification -*- 8 | """ 9 | from sklearn.svm import SVC 10 | 11 | return SVC(C=20.0, gamma=0.00001) 12 | 13 | def nn(num_classes): 14 | """Multi-layer perceptron. 15 | """ 16 | model = Sequential() 17 | model.add(Dense(256, input_dim=193)) 18 | model.add(Activation('relu')) 19 | model.add(Dropout(0.6)) 20 | model.add(Dense(512)) 21 | model.add(Activation('relu')) 22 | model.add(Dropout(0.6)) 23 | model.add(Dense(num_classes)) 24 | model.add(Activation('softmax')) 25 | 26 | return model 27 | 28 | def cnn(num_classes): 29 | """1D Convolutional Neural Network. 30 | -*- ref: panotti https://github.com/drscotthawley/panotti -*- 31 | """ 32 | from keras.layers import Embedding 33 | from keras.layers import Conv1D, GlobalAveragePooling1D, MaxPooling1D 34 | 35 | activation = 'softmax' if num_classes > 2 else 'sigmoid' 36 | model = Sequential() 37 | model.add(Conv1D(64, 3, input_shape=(193, 1))) 38 | model.add(Activation('relu')) 39 | model.add(Conv1D(64, 3)) 40 | model.add(Activation('relu')) 41 | model.add(MaxPooling1D(3)) 42 | model.add(Conv1D(128, 3)) 43 | model.add(Activation('relu')) 44 | model.add(Conv1D(128, 3)) 45 | model.add(Activation('relu')) 46 | model.add(GlobalAveragePooling1D()) 47 | model.add(Dropout(0.5)) 48 | model.add(Dense(num_classes)) 49 | model.add(Activation(activation)) 50 | 51 | return model 52 | 53 | def cnn2d(num_classes): 54 | """2D Convolutional Neural Network. 55 | -*- ref: panotti https://github.com/drscotthawley/panotti -*- 56 | """ 57 | model.add(Conv2D(32, (3, 3), padding='valid', input_shape=(193, 1))) 58 | model.add(BatchNormalization(axis=1)) 59 | model.add(Activation('relu')) 60 | 61 | for layer in range(3): 62 | model.add(Conv2D(32, (3, 3))) 63 | model.add(Activation('elu')) 64 | model.add(MaxPooling2D(pool_size=(2, 2))) 65 | model.add(Dropout(0.5)) 66 | 67 | model.add(Flatten()) 68 | model.add(Dense(128)) 69 | model.add(Activation('elu')) 70 | model.add(Dropout(0.5)) 71 | model.add(Dense(nb_classes)) 72 | model.add(Activation("softmax")) 73 | -------------------------------------------------------------------------------- /pyaudioclassification/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/__init__.py -------------------------------------------------------------------------------- /pyaudioclassification/tests/data/cat/1-34094-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/data/cat/1-34094-A.ogg -------------------------------------------------------------------------------- /pyaudioclassification/tests/data/cat/1-34094-B.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/data/cat/1-34094-B.ogg -------------------------------------------------------------------------------- /pyaudioclassification/tests/data/dog/1-30226-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/data/dog/1-30226-A.ogg -------------------------------------------------------------------------------- /pyaudioclassification/tests/data/dog/1-30344-A.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/data/dog/1-30344-A.ogg -------------------------------------------------------------------------------- /pyaudioclassification/tests/saved/feat.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/saved/feat.npy -------------------------------------------------------------------------------- /pyaudioclassification/tests/saved/label.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micah5/pyAudioClassification/54c6c0a0462a8272537092e4c5861c2ba88f5def/pyaudioclassification/tests/saved/label.npy -------------------------------------------------------------------------------- /pyaudioclassification/tests/test.py: -------------------------------------------------------------------------------- 1 | from unittest import TestCase 2 | import numpy as np 3 | 4 | from pyaudioclassification import feature_extraction, train, predict 5 | 6 | class Test(TestCase): 7 | def test_feat_extract(self): 8 | features = feature_extraction('pyaudioclassification/tests/data/') 9 | loaded_features = np.load('pyaudioclassification/tests/saved/feat.npy') 10 | self.assertTrue(np.array_equal(features, loaded_features)) 11 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | def readme(): 4 | with open('README.md') as f: 5 | return f.read() 6 | 7 | setup(name='pyaudioclassification', 8 | version='0.1.9', 9 | description='Dead simple audio classification', 10 | classifiers=[ 11 | 'Development Status :: 3 - Alpha', 12 | 'License :: OSI Approved :: MIT License', 13 | 'Programming Language :: Python :: 3.0' 14 | ], 15 | keywords='simple audio classification', 16 | url='https://github.com/98mprice/pyAudioClassification', 17 | author='98mprice', 18 | author_email='98mprice@gmail.com', 19 | license='MIT', 20 | packages=['pyaudioclassification'], 21 | install_requires=[ 22 | 'numpy', 23 | 'librosa', 24 | 'soundfile', 25 | 'tqdm', 26 | 'keras', 27 | 'matplotlib' 28 | ], 29 | scripts=['bin/feature_extraction'], 30 | test_suite='nose.collector', 31 | tests_require=['nose'], 32 | include_package_data=True, 33 | zip_safe=False) 34 | --------------------------------------------------------------------------------