我以前曾使用Audacity去除录音中的噪音,但是它在命令行上的使用非常有限。我有大约100个简短的演讲视频,这些视频将在接下来的几个月中观看,并且希望有一种简便的方法可以立即或根据需要在观看之前将其全部清洁。
我可以使用命令行工具或流行语言库吗?
我以前曾使用Audacity去除录音中的噪音,但是它在命令行上的使用非常有限。我有大约100个简短的演讲视频,这些视频将在接下来的几个月中观看,并且希望有一种简便的方法可以立即或根据需要在观看之前将其全部清洁。
我可以使用命令行工具或流行语言库吗?
Answers:
看一眼 sox
报价man sox
:
SoX - Sound eXchange, the Swiss Army knife of audio manipulation
[...]
SoX is a command-line audio processing tool, particularly suited to
making quick, simple edits and to batch processing. If you need an
interactive, graphical audio editor, use audacity(1).
因此,它是替代audaciy的伴侣命令行的理想选择!
关于清理录音的实际任务,请看一下noisered
等于降噪过滤器Audacity的过滤器:
man sox | less -p 'noisered \['
[...]
noisered [profile-file [amount]]
Reduce noise in the audio signal by profiling and filtering.
This effect is moderately effective at removing consistent
background noise such as hiss or hum. To use it, first run
SoX with the noiseprof effect on a section of audio that
ideally would contain silence but in fact contains noise -
such sections are typically found at the beginning or the
end of a recording. noiseprof will write out a noise pro‐
file to profile-file, or to stdout if no profile-file or if
`-' is given. E.g.
sox speech.wav -n trim 0 1.5 noiseprof speech.noise-profil
To actually remove the noise, run SoX again, this time with
the noisered effect; noisered will reduce noise according to
a noise profile (which was generated by noiseprof), from
profile-file, or from stdin if no profile-file or if `-' is
given. E.g.
sox speech.wav cleaned.wav noisered speech.noise-profile 0
How much noise should be removed is specified by amount-a
number between 0 and 1 with a default of 0.5. Higher num‐
bers will remove more noise but present a greater likelihood
of removing wanted components of the audio signal. Before
replacing an original recording with a noise-reduced ver‐
sion, experiment with different amount values to find the
optimal one for your audio; use headphones to check that you
are happy with the results, paying particular attention to
quieter sections of the audio.
On most systems, the two stages - profiling and reduction -
can be combined using a pipe, e.g.
sox noisy.wav -n trim 0 1 noiseprof | play noisy.wav noise
[...]
可接受的答案没有给出实际的示例(请参阅对此的第一条评论),所以我尝试在此处给出一个示例。在具有apt的Ubuntu上,您应该安装sox
和支持音频格式
sox
首次安装sox
并支持格式(包括mp3):
sudo apt install sox libsox-fmt-*
然后,在对一个或多个文件运行命令之前,您需要先创建一个配置文件,制作噪声样本,这是您必须选择噪声发生的最佳时间的最重要部分,请确保不要在此示例中有声音(或您尝试保留的音乐/信号):
ffmpeg -i source.mp3 -ss 00:00:18 -t 00:00:20 noisesample.wav
现在,根据该来源创建个人资料:
sox noisesample.wav -n noiseprof noise_profile_file
最后在文件上运行降噪:
sox source.mp3 output.mp3 noisered noise_profile_file 0.31
noise_profile_file
配置文件在哪里0.30
,价值在哪里。值最好在0.20到0.30之间,超过0.3则非常好,低于0.20则比较柔和,适用于嘈杂的音频。
尝试使用该功能,如果您发现其他设置技巧,请对发现的内容和调整设置进行评论。
如果噪音相似,则可以对所有mp3使用相同的配置文件
ls -r -1 *.mp3 | xargs -L1 -I{} sox {} {}_noise_reduced.mp3 noisered noise_profile_file 0.31
或是否有文件夹结构:
tree -fai . | grep -P ".mp3$" | xargs -L1 -I{} sox {} {}_noise_reduced.mp3 noisered noise_profile_file 0.31
remix -
到缩混所有输入通道的单声道