-1

Problem Statement

I have to sample the frequency of a .mp3 audio file for every 5 ms (milliseconds) using Python. However, because I am a complete newbie in audio processing, I basically have no idea (even to the libraries required) for this issue. Is it possible to do so using Python? Thank you very much!

PS. I guarantee that this problem is not repetitive to other problems. I want to convert them to a list of floating point frequencies, not a .wav file.

江赫霆
  • 9
  • 5
  • 1
    It is not clear what you mean by "sampling frequency". Do you want the average frequency value of combined frequencies from T - 2.5 to T + 2.5 ? What would that accomplish and how can it handle low frequencies ? – Alceste_ Jul 22 '23 at 03:50
  • It's unclear what you are trying to achieve. What does it mean to "sample the frequency of an .mp3 audio file"? Do you mean you want to sample the specific frequency being played every 5 milliseconds, in the decoded audio stream? Are you aware that a decoded .mp3 won't necessarily generate the exact same audio stream on every decoding (unlike .flac or the raw .wav)? – Grismar Jul 22 '23 at 03:54

1 Answers1

0

First you need to load the mp3 from disk and convert it to a numpy array, see this answer: https://stackoverflow.com/a/53633178/3706049

Then you can calculate the frequency with the FFT for the given time interval, see for example here: https://www.cbcity.de/die-fft-mit-python-einfach-erklaert

Balzer82
  • 999
  • 4
  • 10
  • 21