Audio 使用SoX检测和打印静默时间戳
我试图在给定的音频文件中输出静默周期的开始时间戳(因为存在背景噪声,静默指的是阈值)。最后,考虑到这些时间戳,我想将音频文件分割成更小的音频文件。重要的是不能丢弃原始文件的任何部分 我试过了Audio 使用SoX检测和打印静默时间戳,audio,sox,Audio,Sox,我试图在给定的音频文件中输出静默周期的开始时间戳(因为存在背景噪声,静默指的是阈值)。最后,考虑到这些时间戳,我想将音频文件分割成更小的音频文件。重要的是不能丢弃原始文件的任何部分 我试过了 sox in.wav out.wav silence 1 0.5 1% 1 2.0 1% : newfile : restart (礼貌) 虽然它在某种程度上起到了作用,但它也删减和放弃了沉默的时间段,我不希望这种情况发生 “沉默”是正确的选择,还是有更简单的方法来完成我需要做的事情 谢谢。目前(至少)没
sox in.wav out.wav silence 1 0.5 1% 1 2.0 1% : newfile : restart
(礼貌)
虽然它在某种程度上起到了作用,但它也删减和放弃了沉默的时间段,我不希望这种情况发生
“沉默”是正确的选择,还是有更简单的方法来完成我需要做的事情
谢谢。目前(至少)没有办法使静音效果输出到检测到静音的位置,或者保留所有静音音频
如果您能够自己重新编译SoX,那么您可以自己添加一条输出语句来了解剪切位置,然后在单独的调用中使用trim
来分割文件。有了股票版,你就不走运了。
您可以运行一个单独的脚本来迭代所有sox输出文件(对于*.wav中的f),并使用命令soxi-D$f
获取声音片段的持续时间。
然后,以秒为单位获取系统时间日期“+%s”
,然后减去以找到录制开始的时间。不幸的是,不是Sox,但ffmpeg有一个静音检测
过滤器,它完全满足您的要求:
ffmpeg -i in.wav -af silencedetect=noise=-50dB:d=1 -f null -
(检测阈值为-50db,持续至少1秒,垛式)
…这将打印如下结果:
Press [q] to stop, [?] for help
[silencedetect @ 0x7ff2ba5168a0] silence_start: 264.718
[silencedetect @ 0x7ff2ba5168a0] silence_end: 265.744 | silence_duration: 1.02612
size=N/A time=00:04:29.53 bitrate=N/A
SoX可以很容易地在文本文件中为您提供实际静音的时间戳。虽然不是沉默期,但你可以用一个简单的脚本来计算
.dat Text Data files. These files contain a textual representation of the sample data. There is one line at the beginning that contains the sample
rate, and one line that contains the number of channels. Subsequent lines contain two or more numeric data intems: the time since the beginning of
the first sample and the sample value for each channel.
Values are normalized so that the maximum and minimum are 1 and -1. This file format can be used to create data files for external programs such as
FFT analysers or graph routines. SoX can also convert a file in this format back into one of the other file formats.
Example containing only 2 stereo samples of silence:
; Sample Rate 8012
; Channels 2
0 0 0
0.00012481278 0 0
这样你就可以做<代码> SOX in .Wav.Out.DAT,然后解析文本文件并考虑一个值为接近0(取决于你的阈值)的行的静默
嗨,ChigLu,我希望那不是真的。我看看能做些什么。有关于这个话题的新闻吗?你能做到这一点吗?我也需要这样做。目前我用audacity检测沉默,并将标签曲目导出为文本文件。2017年有没有新的库可以实现这一点?i、 e在给定音频文件的情况下,能够检测并输出讲话时间和沉默时间的时间戳。谢谢