[英]How to get number of samples from wav file?
I know that I can do soxi file.wav
to get info such as我知道我可以做soxi file.wav
来获取诸如
Input File : '2.wav'
Channels : 1
Sample Rate : 8000
Precision : 16-bit
Duration : 00:04:14.54 = 2036320 samples ~ 19090.5 CDDA sectors
File Size : 4.07M
Bit Rate : 128k
Sample Encoding: 16-bit Signed Integer PCM
Where I can see that it has 2036320 samples
.我可以看到它有2036320 samples
。 However how do I do the same thing in python?但是我如何在 python 中做同样的事情?
I have tried this through reading some articles but I keep getting <bound method Wave_read.readframes of <wave.Wave_read instance at...
我已经通过阅读一些文章尝试了这一点,但我一直在获取<bound method Wave_read.readframes of <wave.Wave_read instance at...
import wave
audio_file = wave.open(wavfile, 'r')
print(audio_file.readframes)
audio_file.close()
The solution was to use getnframes()
method instead of readframes
解决方案是使用getnframes()
方法而不是readframes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.