def read_wave_file_not_normalized(filename):
""" Read a wave file from disk
# Arguments
filename : the name of the wave file
# Returns
(fs, x) : (sampling frequency, signal)
"""
if (not os.path.isfile(filename)):
raise ValueError("File does not exist")
s = wave.open(filename, 'rb')
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
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录