utils.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号