SoundUtils.py 文件源码

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

项目:PyPeVoc 作者: goiosunsw 项目源码 文件源码
def SpecCentWind(x, sr=1, nwind=1024, nhop=512, windfunc=np.blackman):
    '''
    Calculates the SpectralCentroid of x, in frames of
    length nwind, and in steps of nhop. windfunc is used as
    windowing function

    nwind should be at least 3 periods if the signal is periodic.
    '''
    ff = np.arange(nwind/2)/float(nwind)*sr

    def SCvec(xw):
        xf = np.fft.fft(xw)
        xf2 = xf[:nwind/2]
        return sum(np.abs(xf2)*ff)/sum(np.abs(xf2))

    amp, t = FuncWind(SCvec, x, power=0, sr=sr,
                      nwind=nwind, nhop=nhop)

    return np.array(amp), np.array(t)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号