求助:pysynth模块报AttributeError,无make_wav属性问题解决
解决pysynth模块的AttributeError: 'module' has no attribute 'make_wav'问题
出现这个错误的核心原因是你安装的pysynth包并非提供make_wav方法的版本——原始pysynth模块已停止维护,目前常用的是其分叉版本pysynth-s或pysynth-m,这两个版本才包含make_wav函数。
解决步骤:
先卸载已安装的旧版pysynth:
pip uninstall pysynth -y安装维护中的分叉版本(二选一即可,推荐
pysynth-s):# 安装pysynth-s pip install pysynth-s # 或者安装pysynth-m pip install pysynth-m修改代码中的导入语句,对应安装的包:
如果安装的是pysynth-s,代码改为:import pysynth_s as ps test = (('c', 4), ('e', 4), ('g', 4), ('c5', -2), ('e6', 8), ('d#6', 2)) ps.make_wav(test, fn="test.wav")如果安装的是
pysynth-m,代码改为:import pysynth_m as ps test = (('c', 4), ('e', 4), ('g', 4), ('c5', -2), ('e6', 8), ('d#6', 2)) ps.make_wav(test, fn="test.wav")
执行以上步骤后,代码即可正常生成WAV音频文件。
内容的提问来源于stack exchange,提问作者Ali Valizade
相关产品推荐
相关产品推荐

