def read_wav(source, start=0, end=None):
warnings.warn(
"read_wav() is deprecated, use Sound() class instead",
DeprecationWarning)
in_wav = wave.open(source, "rb")
fr = in_wav.getframerate()
chan = in_wav.getnchannels()
sw = in_wav.getsampwidth()
in_wav.setpos(int(start * fr))
if end is None:
end = (in_wav.getnframes() - start / fr)
data = in_wav.readframes(int((end - start) * fr))
in_wav.close()
d = {"framerate": fr,
"channels": chan,
"samplewidth": sw,
"length": end - start,
"state": 0,
"data": data}
return d
评论列表
文章目录