音频文件读取与存储的话,目前有librosa,scipy.io.wavfile,soundfile,essentia其中前两者是一样的程序,sf的读取与写入只能是wav/ogg/flac的,最后一个库win安装失败,这个问题我给官方提过,服务器没有问题,我似乎记得win也安装成功过,现在看来需要运气(环境配置问题)。
可以采用librosa读取文件,然后scale到16bit数据,直接用sf写入flac即可,这个大小与mp3差不多。
>>> help(sf.write)
Help on function write in module soundfile:
write(file, data, samplerate, subtype=None, endian=None, format=None, closefd=True)
Write data to a sound file.
.. note:: If `file` exists, it will be truncated and overwritten!
Parameters
----------
file : str or int or file-like object
The file to writ