utils.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:bird-species-classification 作者: johnmartinsson 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号