sound.py 文件源码

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

项目:coquery 作者: gkunter 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号