I'm trying to get the byte string from a wavefile with the wave module:
我正在尝试从一个波形文件中获取字节串和wave模块:
import wave
wavfile = open(filename)
w = wave.open(wavfile)
print "nsamples:", w.getnframes()
print "sample size:", w.getsampwidth()
print "channels:", w.getnchannels()
data = w.readframes(w.getnframes())
print "number of samples read:", len(data) / (w.getsampwidth() * w.getnchannels())
On Unix systems, using the Anaconda installation, this works (for any given wavefile):
在Unix系统上,使用Anaconda安装,这是可行的(对于任何给定的波形文件):
nsamples: 4800000
sample size: 3
channels: 1
number of samples read: 4800000
However on Windows systems, also using the Anaconda installation, this doesn't work (for any given wavefile):
但是在Windows系统上,也使用Anaconda安装,这是不工作的(对于任何给定的波形文件):
nsamples: 4800000
sample size: 3
channels: 1
number of samples read: 443
The 443 samples read are equal to the first 443 samples of the 4800000. Any ideas?
443个样本值等于4800000的前443个样本。什么好主意吗?
1 个解决方案
#1
0
Found the solution, it wasn't an issue with the wave module:
找到了解决方案,wave模块没有问题:
wavfile = open(filename, 'rb')
as per: Python Does Not Read Entire Text File
如:Python不读取整个文本文件
#1
0
Found the solution, it wasn't an issue with the wave module:
找到了解决方案,wave模块没有问题:
wavfile = open(filename, 'rb')
as per: Python Does Not Read Entire Text File
如:Python不读取整个文本文件