spk-change-detection.py 文件源码

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

项目:speaker-diarization 作者: aalto-speech 项目源码 文件源码
def bic(arr1, arr2, arr, i=0, saved={}):
    """Bayes Information Criterion

    Notes: In the seminal paper "Speakers, environment and channel change
    detection and clustering via the Bayesian Information Criterion" by Chen
    and Gopalakrishnan, they use a growing window approach, so it's not
    directly comparable when using a fixed sliding window.

    In BIC, we can save the first matrix calculations since in growing windows
    these keep repeating all the time, and we are saving just one float so
    it's also memory efficient and saves a lot of time (Antonio)"""

    if i in saved:
        c1 = saved[i]
    else:
        S1 = np.cov(arr1, rowvar=0)
        N1 = arr1.shape[0]
        c1 = 0.5 * N1 * np.log(det(S1))
        saved[i] = c1
    S2 = np.cov(arr2, rowvar=0)
    N2 = arr2.shape[0]
    N = arr.shape[0]
    S = np.cov(arr, rowvar=0)
    d = 0.5 * N * np.log(det(S)) - c1\
        - 0.5 * N2 * np.log(det(S2))
    p = arr.shape[1]
    corr = args.lambdac * 0.5 * (p + 0.5 * p * (p + 1)) * np.log(N)
    d -= corr
    return d
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号