将受控降级引入音频的工具
audio-degrader的Python项目详细描述
音频降级器
最新版本:1.2.3
python中的音频降级工具箱,带有命令行工具。对音频应用受控降级是有用的。
安装
pip install audio_degrader
程序依赖于sox
、ffmpeg
和rubberband
,因此您可能也需要安装它们。建议在osx中使用brew
,在linux中使用apt-get
(对于rubberband,在linux中使用rubberband-cli
)。
python包的使用
importaudio_degraderasadaudio_file=ad.AudioFile('input.wav','./tmp_dir')fordinad.ALL_DEGRADATIONS.values():printad.DegradationUsageDocGenerator.get_degradation_help(d)degradations=ad.ParametersParser.parse_degradations_args(['normalize','gain,6','dr_compression,3','equalize,500,10,30'])fordindegradations:audio_file.apply_degradation(d)audio_file.to_wav('output.wav')audio_file.delete_tmp_files()
命令行工具的使用
脚本audio_degrader
与python包一起安装。
# e.g. mix with restaurant08.wav with snr=10db, then amplifies 6db, then compress dynamic range
$ audio_degrader -i input.mp3 -d mix,https://github.com/hagenw/audio-degradation-toolbox/raw/master/AudioDegradationToolbox/degradationData/PubSounds/restaurant08.wav,10 gain,6 dr_compression,3 -o out.wav
# for more details:
$ audio_degrader --help
一小部分声音和脉冲响应与脚本一起安装,脚本中可以列出:
$ audio_degrader -l
# these relative paths can be used directly in the script too:
$ audio_degrader -i input.mp3 -d mix,sounds/applause.wav,-3 gain,6 -o out.wav
应用程序
- 评估不同退化程度下的音乐信息检索系统
- 为机器学习系统的培训准备扩充数据
它类似于Audio Degradation Toolbox in Matlab by Sebastian Ewert and Matthias Mauch(对于matlab)。
一些示例
# Mix input with a sound / noise (e.g. using installed resources)
$ audio_degrader -i input.wav -d mix,sounds/applause.wav,-3 -o out.wav
# Instead of paths, we can also use URLs
$ audio_degrader -i input.wav -d mix,https://www.pacdv.com/sounds/ambience_sounds/airport-security-1.mp3,-3 -o out.wav
# Microphone recording style
$ audio_degrader -i input.wav -d gain,-15 mix,sounds/ambience-pub.wav,18 convolution,impulse_responses/ir_smartphone_mic_mono.wav,0.8 dr_compression,2 equalize,50,100,-6 normalize -o out.wav
# Resample and normalize
$ audio_degrader -i input.mp3 -d resample,8000 normalize -o out.wav
# Convolution (again impulse responses can be resources, full paths or URLs)
$ audio_degrader -i input.wav -d convolution,impulse_responses/ir_classroom_mono.wav,0.7 -o out.wav
$ audio_degrader -i input.wav -d convolution,http://www.cksde.com/sounds/month_ir/FLANGERSPACE%20E001%20M2S.wav,0.7 -o out.wav
音频格式
输入
audio_degrader
依赖ffmpeg进行音频读取,因此它可以读取任何格式(甚至视频)。
输出
audio_degrader
输出格式始终为wav立体声pcm_f32le
(原始音频文件的采样率)。
此输出wav文件可以使用ffmpeg轻松转换为其他格式,例如:
$ ffmpeg -i out.wav -b:a 320k out.mp3
$ ffmpeg -i out.wav -ac 2 -ar 44100 -acodec pcm_s16le out_formatted.wav