在Python读物* .wav文件 [英] Reading *.wav files in Python
问题描述
我需要分析写在一个.wav文件的声音。对于我需要把这个文件转换成一组数字(阵列,例如)。我想我需要使用波包。但是,我不知道它究竟是如何工作的。比如我做了以下内容:
I need to analyze sound written in a .wav file. For that I need to transform this file into set of numbers (arrays, for example). I think I need to use the wave package. However, I do not know how exactly it works. For example I did the following:
import wave
w = wave.open('/usr/share/sounds/ekiga/voicemail.wav', 'r')
for i in range(w.getnframes()):
frame = w.readframes(i)
print frame
由于这code我期望看到声音pressure作为时间函数的结果。相反我看到很多奇怪的,神秘的符号(不是十六进制数)的。任何人可以,恳求,帮我吗?
As a result of this code I expected to see sound pressure as function of time. In contrast I see a lot of strange, mysterious symbols (which are not hexadecimal numbers). Can anybody, pleas, help me with that?
推荐答案
每的来源中, scipy.io.wavfile.read(somefile)
返回两个项目的元组:第一个是采样率以每秒采样,第二个是 numpy的
阵列从文件中读取的所有数据。看起来pretty好用!
Per the sources, scipy.io.wavfile.read(somefile)
returns a tuple of two items: the first is the sampling rate in samples per second, the second is a numpy
array with all the data read from the file. Looks pretty easy to use!
这篇关于在Python读物* .wav文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!