def read_gzip_wave_file(filename):
if (not os.path.isfile(filename)):
raise ValueError("File does not exist")
with gzip.open(filename, 'rb') as wav_file:
with wave.open(wav_file, 'rb') as s:
if (s.getnchannels() != 1):
raise ValueError("Wave file should be mono")
#if (s.getframerate() != 22050):
#raise ValueError("Sampling rate of wave file should be 16000")
strsig = s.readframes(s.getnframes())
x = np.fromstring(strsig, np.short)
fs = s.getframerate()
s.close()
return fs, x
utils.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录