PyAudio 中文手册--静音移除/有声检测

静音移除/有声检测

audioSegmentation.py中的silenceRemoval()方法将连续的音频拆分为独立的事件片段,即静默的信号都被移除掉了。 其实现主要通过一个半监督方法:首先训练一个SVM模型来分辨(短期时长的)高能信号与低能信号,使用其中10%的高能片段和10%的低能片段来作为训练集。然后对整段音频应用这一SVM训练模型,并使用动态的阈值来判断动态的片段。

核心方法:silenceRemoval(x, fs, st_win, st_step, smoothWindow=0.5, weight=0.5, plot=False)

def silenceRemoval(x, fs, st_win, st_step, smoothWindow=0.5, weight=0.5, plot=False):
    '''
    Event Detection (silence removal)
    ARGUMENTS:
         - x:                the input audio signal
         - fs:               sampling freq
         - st_win, st_step:    window size and step in seconds
         - smoothWindow:     (optinal) smooth window (in seconds)
         - weight:           (optinal) weight factor (0 < weight < 1) the higher, the more strict
         - plot:             (optinal) True if results are to be plotted
    RETURNS:
         - seg_limits:    list of segment limits in seconds (e.g [[0.1, 0.9], [1.4, 3.0]] means that
                    the resulting segments are (0.1 - 0.9) seconds and (1.4, 3.0) seconds
    '''

参数:

x: 输入的音频(数字化的) fs: 采样频率 st_win, st_step: 短期时长的窗口及步长 smoothWindow=0.5: 平滑窗口(单位秒) weight=0.5: 决策阈值(越高越严格) plot=False: 是否可视化结果

返回结果seg_limits是一个数组,表示非静音(有声)片段的起止时间。

根据音频性质的不同,也应该使用不同的平滑窗口和决策阈值。上述的样本中,声音是非常稀疏的。对于持续的讲话,应该使用更短(值更小)的平滑窗口和更严格的(值更大)的决策阈值。

 

全部手册:https://www.cnblogs.com/liuzhongrong/p/12269181.html

posted @ 2020-04-10 00:27  虚幻的街景  阅读(1484)  评论(0编辑  收藏  举报