简体   繁体   English

如何读出 mp3 文件的值?

[英]How can you read out values of mp3 files?

Music is just a modulation of a sine wave, therefore it must have a "y"-value at any given time.音乐只是正弦波的调制,因此它在任何给定时间都必须具有“y”值。 In mp3 files, the standard sampling frequency is 44100Hz and therefore has a "y"-value once every 44100th of a second.在 mp3 文件中,标准采样频率是 44100Hz,因此每 44100 秒就有一个“y”值。 But how can You read these values out?但是你怎么能读出这些值呢? Preferably in Python3.最好在 Python3 中。

Thought this won't read mp3 directly from Python, I'd suggest first converting mp3 to wav, and then reading wav from Python.认为这不会直接从 Python 读取 mp3,我建议先将 mp3 转换为 wav,然后从 Python 读取 wav。

Install mpg123 if you don't have it:如果没有,请安装 mpg123:

sudo apt-get install mpg123

Then convert the file like this:然后像这样转换文件:

mpg123 -w file_out.wav file_in.mp3

Or use ffmpeg:或者使用 ffmpeg:

ffmpeg -i file_in.mp3 file_out.wav 

Then, try scipy.io.wavfile.read to read the wav file.然后,尝试scipy.io.wavfile.read读取 wav 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM