estimation.py 文件源码

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

项目:psola 作者: jcreinhold 项目源码 文件源码
def pitch_strength_all_candidates(f_erbs, L, pc):
    """
    Calculates the pitch ``strength'' of all candidate
    pitches

    Args:
        f_erbs (array): frequencies in ERBs
        L     (matrix): loudness matrix
        pc     (array): pitch candidates array

    Returns:
        S   (array): strength of pitches corresponding to pc's
    """
    # create pitch strength matrix
    S = np.zeros((pc.size, L.shape[1]))

    # define integration regions
    k = np.zeros(pc.size+1)

    for j in range(k.size-1):
        idx = int(k[j])
        f = f_erbs[idx:]
        val = find(f > pc[j] / 4)[0]
        k[j+1] = k[j] + val

    k = k[1:]  # TODO: fix this sloppiness

    # create loudness normalization matrix
    N = np.sqrt(np.flipud(np.cumsum(np.flipud(L * L), 0)))
    for j in range(pc.size):
        # normalize loudness
        n = N[int(k[j]), :]
        n[n == 0] = -np.inf  # to make zero-loudness equal zero after normalization
        nL = L[int(k[j]):] / np.tile(n, (int(L.shape[0] - k[j]), 1))

        # compute pitch strength
        S[j] = pitch_strength_one_candidate(f_erbs[int(k[j]):], nL, pc[j])

    return S
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号