M
M
MaxBat2021-02-26 13:45:07
Python
MaxBat, 2021-02-26 13:45:07

How to convert audio to array in python?

Good afternoon. I have an audio file that needs to be represented as an array of numbers. I can't find a solution in python.

Audio file - array - audio file.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Pankov, 2021-02-26
@MaxBat

Few data. If your audio file is in WAV format, then this is actually the data array that you need. It is enough to cut off the "header" from it, look at the bitrate and the number of channels in the header and accordingly interpret it as an array of samples of the required bitness.
If the file is encoded with a codec (mp3, ogg, etc.), then first you need to decode the file, and then see, as they say, the first paragraph.
How exactly it will look in the code depends on what format, what libraries you use to work with arrays of data. Be specific, please.
Searched, by the way, elementary:
https://stackoverflow.com/questions/3049572/how-to...
https://pythonbasics.org/convert-mp3-to-wav/
https://www.geeksforgeeks.org/ convert-mp3-to-wav-u...
UPD:
https://google.gik-team.com/?q=wav+python
As a result we have:
https://habr.com/ru/post/113239/
https://docs.python.org/3/library/ wave.html
https://coderoad.ru/2060628/Reading-wav-files-in-Python
These are the first three links in Google. If you couldn’t find it, then get out of the profession.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question