deep_throat.py 文件源码

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

项目:deep_throat 作者: wdbm 项目源码 文件源码
def save_values_to_wave_file(
    values             = None,
    filename           = None,
    maximum_amplitude  = 65535, # maximum value of unsigned short 16 bit number
    sample_rate        = 44100, # Hz
    number_of_channels = 1,
    sample_width       = 2      # bytes per frame
    ):
    values = datavision.normalize_to_range(
        values,
        minimum = -(maximum_amplitude / 2),
        maximum = maximum_amplitude / 2
    )
    file_output = wave.open(filename, "w")
    file_output.setnchannels(number_of_channels)
    file_output.setsampwidth(sample_width)
    file_output.setframerate(sample_rate)
    for value in values:
        write_data = struct.pack("<h", value)
        file_output.writeframesraw(write_data)
    file_output.writeframes("")
    file_output.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号