utils.py 文件源码

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

项目:WaveNet-Enhancement 作者: auspicious3000 项目源码 文件源码
def mu_law_bins(num_bins):
    """ 
    this functions returns the mu-law bin (right) edges and bin centers, with num_bins number of bins 

    """
    #all edges
    bins_edge = np.linspace(-1, 1, num_bins + 1)
    #center of all edges
    bins_center = np.linspace(-1 + 1.0 / num_bins, 1 - 1.0 / num_bins, num_bins)
    #get the right edges
    bins_trunc = bins_edge[1:]
    #if sample >= right edges, it might be assigned to the next bin, add 0.1 to avoid this
    bins_trunc[-1] += 0.1
    #convert edges and centers to mu-law scale
    bins_edge_mu = np.multiply(np.sign(bins_trunc), (num_bins ** np.absolute(bins_trunc) - 1) / (num_bins - 1))
    bins_center_mu = np.multiply(np.sign(bins_center), (num_bins ** np.absolute(bins_center) - 1) / (num_bins - 1))

    return (bins_edge_mu, bins_center_mu)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号