annotate README.md @ 35:f094fc50ff04 tip master

update readme, fix py3 note
author danstowell <danstowell@users.sourceforge.net>
date Wed, 15 Mar 2023 07:18:09 +0000
parents 469e69bdc354
children
rev   line source
danstowell@5 1
danstowell@5 2 smacpy - simple-minded audio classifier in python
danstowell@5 3 =================================================
danstowell@5 4
danstowell@5 5 Copyright (c) 2012 Dan Stowell and Queen Mary University of London
danstowell@5 6 (incorporating code Copyright (c) 2009 Gyorgy Fazekas and Queen Mary University of London)
danstowell@6 7 - for licence information see the file named COPYING.
danstowell@5 8
danstowell@5 9 This is a classifier that you can train on a set of labelled audio files, and then it predicts a label for further audio files.
danstowell@5 10 It is designed with two main aims:
danstowell@6 11
danstowell@6 12 1. to provide a baseline against which to test more advanced audio classifiers;
danstowell@6 13 2. to provide a simple code example of a classifier which people are free to build on.
danstowell@5 14
danstowell@33 15 It uses a workflow which was very common before the age of deep learning, and might still be useful for low-complexity audio tasks: take an audio clip as input, converting it frame-by-frame into MFCCs, and modelling the MFCC "bag of frames" with a GMM.
danstowell@5 16
danstowell@5 17 Requirements
danstowell@5 18 ------------
danstowell@33 19 * Python 2.7 or later, or Python 3
danstowell@5 20 * Python modules:
danstowell@5 21 * numpy
danstowell@33 22 * [librosa](http://librosa.org/)
danstowell@20 23 * [sckikit-learn](http://scikit-learn.sourceforge.net/)
danstowell@5 24
danstowell@35 25 It has been tested on python 2.7 and 3.8 (on Ubuntu).
danstowell@7 26
danstowell@5 27
danstowell@5 28 Usage example 1: commandline
danstowell@5 29 -------------
danstowell@5 30 If you invoke the script from the commandline (e.g. "python smacpy.py") it will assume there is a folder called "wavs"
danstowell@5 31 and inside that folder are multiple WAV files, each of which has an underscore in the filename,
danstowell@5 32 and the class label is the text BEFORE the underscore.
danstowell@19 33 It will train a model using the wavs, and then test it on the same wavs (dividing the collection up so it can do a "crossvalidated" test).
danstowell@5 34
danstowell@7 35 To train and test on different folders, you can run it like this:
danstowell@7 36
danstowell@7 37 python smacpy.py -t trainwavs -T testwavs
danstowell@7 38
danstowell@7 39
danstowell@5 40 Usage example 2: from your own code
danstowell@5 41 -------------
danstowell@5 42 In this hypothetical example we train on four audio files, labelled as either 'usa' or 'uk', and then test on a separate audio file of someone called hubert:
danstowell@5 43
danstowell@5 44 from smacpy import Smacpy
danstowell@5 45 model = Smacpy("wavs/training", {'karen01.wav':'usa', 'john01.wav':'uk', 'steve02.wav':'usa', 'joe03.wav':'uk'})
danstowell@5 46 model.classify('wavs/testing/hubert01.wav')
danstowell@5 47