nasality.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:AutismVoicePrint 作者: opraveen 项目源码 文件源码
def is_periodic(aud_sample, SAMPLING_RATE = 8000):
    '''
    :param aud_sample: Numpy 1D array rep of audio sample
    :param SAMPLING_RATE: Used to focus on human speech freq range
    :return: True if periodic, False if aperiodic
    '''

    threshold = 20

    # Use auto-correlation to find if there is enough periodicity in [50-400] Hz range
    values = signal.correlate(aud_sample, aud_sample, mode='full')

    # [50-400 Hz] corresponds to [2.5-20] ms OR [20-160] samples for 8 KHz sampling rate
    l_idx = int(SAMPLING_RATE*2.5/1000)
    r_idx = int(SAMPLING_RATE*20/1000)
    values = values[len(values)/2:]

    subset_values = values[l_idx:r_idx]

    if np.argmax(subset_values) < threshold:
        return False
    else:
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号