0

I am writing a chord-recognizer for a school project. I have to extract features from an mp3 file and use SVM with chord labels.

How can I extract frequencies from an audio file.

Is there any scipy package which could get me beat synchronous chroma.

Ada Xu
  • 953
  • 4
  • 14
  • 31

4 Answers4

0

The decoding becomes much easier even using a home-grown tool if to get some raw stream (including WAV file which is simply a raw stream and an envelope around it). Under a usual Unix-like, you can do it e.g. with mpg123 -s, mplayer -ao pcm:fast:file=$outfile and so on. But I doubt you can find a library which eventually supports all compressed audio formats.

(Also, SoX is good to convert between all uncompressed formats.)

Netch
  • 4,171
  • 1
  • 19
  • 31
  • How can I get features from a wav file? – Ada Xu Dec 21 '13 at 15:13
  • You can use any spectral analysis tool, there are quite many of them. I won't suggest any without knowing your circumstances, I've only deduced the task to combination of two simpler ones. – Netch Dec 21 '13 at 15:50
  • thanks for the help :) I want make a chromagram which is used to identify musical notes. I think there's a chroma toolbox for matlab but I can't seem to find anything like that for python. – Ada Xu Dec 22 '13 at 11:07
  • As already written [here](http://stackoverflow.com/a/20748186/2812618) the [Bregman Audio-Visual Information Toolbox](http://bregman.dartmouth.edu/bregman/) gives you a chromagram analyzer. – Frank Zalkow Dec 24 '13 at 10:03
0

You can read wave files with python's wave package. Probably the easiest way to get out frequencies is by taking the FFT (numpy.fft) and finding peaks in the output. You'll want to time-box your FFT calls to something that makes sense (windows where the pitches are consistent), or else you'll be looking at a bunch of frequency patterns on top of each other.

Have fun!

mattexx
  • 6,456
  • 3
  • 36
  • 47
0

You may consider computing a chromagram, which is just like a spectrogram but with the musical notes in the Y axis instead of frequencies. The Librosa python library has a built-in function to compute it. https://librosa.github.io/librosa/generated/librosa.feature.chroma_stft.html

Pablo
  • 312
  • 1
  • 3
  • 11
0

What you're looking for my friend, is Librosa. It's perfect for Audio feature extraction and manipulation. It has a separate submodule for features. You can extract features at the lowest levels and their documentation has some very easy to understand tutorials.

Here's the link to their website. Along with a sample code

https://librosa.github.io/librosa/index.html

import librosa
audio_file = 'your_audio_file.wav'
signal , sampling_rate = librosa.load(audio_file, sr=16000)
print(type(signal), type(sampling_rate)
len(signal), sampling_rate
Azfarrrr
  • 3
  • 3