Commit c7736283 authored by Owen Campbell's avatar Owen Campbell

getting up to date

parents eb58c7aa bbfdda7b
{
"metadata": {
"name": "",
"signature": "sha256:c2091c83f372205a4ebcdce326aec16d3effc143ec24d63e1026df692ec4f383"
"signature": "sha256:5c2d491824e04ce0a7278e04803f3c8f56c68362ad164e1fa1330afd9cc674f6"
},
"nbformat": 3,
"nbformat_minor": 0,
......@@ -66,19 +66,16 @@
"level": 2,
"metadata": {},
"source": [
"Feature Extraction (work in progress)"
"Spectral Feature Extraction and Classification"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. [Feature Extraction](notebooks/feature_extraction.ipynb)\n",
"1. [Spectral Features](notebooks/spectral_features.ipynb)\n",
"1. [Tonal Descriptors: Pitch and Chroma](notebooks/)\n",
"1. [Beat Tracking](notebooks/beat_tracking.ipynb)\n",
"1. [Tempo Estimation](notebooks/tempo_estimation.ipynb)\n",
"1. [Mel-Frequency Ceptral Coefficients](notebooks/mfcc.ipynb)\n",
"1. [K-Nearest Neighbor](notebooks/knn.ipynb)\n",
"1. [Exercise: Instrument Classification using K-NN](exercises/knn_instrument_classification.ipynb)"
]
},
......@@ -87,20 +84,31 @@
"level": 2,
"metadata": {},
"source": [
"Machine Learning (work in progress)"
"More (work in progress)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. [K-Nearest Neighbor](notebooks/knn.ipynb)\n",
"1. [Tonal Descriptors: Pitch and Chroma](notebooks/)\n",
"1. [Feature Extraction](notebooks/feature_extraction.ipynb)\n",
"1. [Beat Tracking](notebooks/beat_tracking.ipynb)\n",
"1. [Tempo Estimation](notebooks/tempo_estimation.ipynb)\n",
"1. [K-Means Clustering](notebooks/kmeans.ipynb)\n",
"1. [Nonnegative Matrix Factorization](notebooks/nmf.ipynb)\n",
"1. [Cross Validation](notebooks/cross_validation.ipynb)\n",
"1. [Exercise: Unsupervised Instrument Classification using K-Means](exercises/)\n",
"1. [Exercise: Source Separation using NMF](exercises/nmf_source_separation.ipynb)"
]
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
......
......@@ -78,7 +78,7 @@
"source": [
"- 2009 [[full list](https://ccrma.stanford.edu/wiki/MIR_workshop_2009/Participants)]: Luke Dahl, Mike Gao, Craig Hanson, Jorge Herrera, Denis Lebel, Sang Won Lee, Gautham Mysore, Jeremy Sawruk, Hwan Shim, Diana Siwiak, Steve Tjoa, Elie Noune, James Hughes, Stefan Tomic, Lisa Lim, Fred Barrett\n",
"- 2011: Chris Colatos, Jeff Albert, Kamlesh Lakshminarayanan, Sean Zhang, Eli Stine, David Bird, Gina Collecchia, Dekun Zou, Bill Paseman, John Amuedo\n",
"- 2014: Owen Campbell, (Add your name here! Fork this repo on GitHub, and send a pull request.)"
"- 2014: (Krishna Kumar, ... Add your name here! Fork this repo on GitHub, and send a pull request.)"
]
}
],
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -9,6 +9,9 @@ from sklearn import cross_validation
from sklearn.neighbors import KNeighborsClassifier
from sklearn import preprocessing
import urllib2 # the lib that handles the url stuff
import urllib
from essentia.standard import MonoLoader
from essentia.standard import ZeroCrossingRate, CentralMoments, Spectrum, Windowing, Centroid
# Here are examples of how scaling functions would be written, however nowdays SciKit
# Learn will do it for you with the MinMaxScaler!
......@@ -86,9 +89,10 @@ def crossValidateKNN(features, labels):
errors[foldIndex] = matches.mean()
print('cross validation error: %f' % errors.mean())
print('cross validation accuracy: %f' % (1.0 - errors.mean()))
return errors
def processCorpus(corpusURL):
def process_corpus(corpusURL):
"""Read a list of files to process from the text file at corpusURL. Return a list of URLs"""
# Open and read each line
urlListTextData = urllib2.urlopen(corpusURL) # it's a file like object and works just like a file
......@@ -96,6 +100,39 @@ def processCorpus(corpusURL):
yield fileURL.rstrip()
# return [fileURL.rstrip() for fileURL in urlListTextData]
# audioFileURLs = processCorpus("https://ccrma.stanford.edu/workshops/mir2014/SmallCorpus.txt")
# for audioFileURL in processCorpus("https://ccrma.stanford.edu/workshops/mir2014/SmallCorpus.txt"):
# audioFileURLs = process_corpus("https://ccrma.stanford.edu/workshops/mir2014/SmallCorpus.txt")
# for audioFileURL in process_corpus("https://ccrma.stanford.edu/workshops/mir2014/SmallCorpus.txt"):
# print audioFileURL
def spectral_features(filelist):
"""
Given a list of files, retrieve them, analyse the first 100mS of each file and return
a feature table.
"""
number_of_files = len(filelist)
number_of_features = 5
features = np.zeros([number_of_files, number_of_features])
sample_rate = 44100
for file_index, url in enumerate(filelist):
print url
urllib.urlretrieve(url, filename='/tmp/localfile.wav')
audio = MonoLoader(filename = '/tmp/localfile.wav', sampleRate = sample_rate)()
zcr = ZeroCrossingRate()
hamming_window = Windowing(type = 'hamming') # we need to window the frame to avoid FFT artifacts.
spectrum = Spectrum()
central_moments = CentralMoments()
spectral_centroid = Centroid()
frame_size = int(round(0.100 * sample_rate)) # 100ms
# Only do the first frame for now.
# TODO we should generate values for the entire file, probably by averaging the features.
current_frame = audio[0 : frame_size]
features[file_index, 0] = zcr(current_frame)
spectral_magnitude = spectrum(hamming_window(current_frame))
centroid = spectral_centroid(spectral_magnitude)
spectral_moments = central_moments(spectral_magnitude)
features[file_index, 1] = centroid
features[file_index, 2:5] = spectral_moments[2:5]
return features
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment