Dreaded Harvester
Dreaded Harvester

Reputation: 1547

How to convert .mp3 files to arrays of frequencies and amplitudes using python?

I wanted to design a neural network, which after training would take .mp3 files as input, and then based on training, it would decide if the music is good or bad on a scale of 1-10. But for this, I would need to convert the audio file into arrays of wavelength, frequencies, amplitude and all other parameters required to define music, and then use these arrays as input to the neural network. How should I approach this problem?

Upvotes: 9

Views: 4133

Answers (1)

Nathan
Nathan

Reputation: 3648

if you convert your .mp3 files to .wav you can do:

from scipy.io import wavfile as wav
from scipy.fftpack import fft
import numpy as np
rate, data = wav.read('music.wav')
fft_out = fft(data)

From http://www.dummies.com/programming/python/performing-a-fast-fourier-transform-fft-on-a-sound-file/

Upvotes: 9

Related Questions