Calculation of fft using python

1.7k views Asked by At

By using wave in Python we can read .wav audio format and can calculate the frequency and power of a signal. But I want to calculate the frequency of .mp3 audio format directly. I've heard a little bit about Pysox. Is Pysox capable of reading frames and can we calculate the fft and frequency using Pysox? Or is there any other software which can calculate the frequency of an MP3 file using Python?

1

There are 1 answers

0
Jiaaro On

your questions has a few parts, but I'll give it a shot: you can get the raw audio data using pydub (the same thing the wave module gives you)

import pydub

sound = pydub.AudioSegment.from_mp3("/path/to/file.mp3")
raw_data = sound._data

(note that you'll need ffmpeg or avlib installed for the mp3 decoding)

From there you should be able to use numpy. This O'Reilly post may also help