music_parsing.py 文件源码

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

项目:DeepRemix 作者: DeepRemix 项目源码 文件源码
def parse_wav(filename, n_mfcc=40):
    '''
    Parses a single wav file into MFCC's and sample rate.

    Arguments:
        filename - Name of input wav file.
        n_mfcc   - Number of coefficients to use.

    Returns:
        A tuple with a numpy array with cepstrum coefficients, and sample rate.

    Raises:

    '''

    song_data = np.array([])
    sample_rate = -1
    if filename[-4:] == '.wav':
        try:
            y_data, sample_rate = librosa.load(filename)
            #  will need to experiment with different values for n_mfcc
            song_data = librosa.feature.mfcc(y=y_data,
                                             sr=sample_rate,
                                             n_mfcc=n_mfcc)
        except:
            sys.exit(1)

    return (song_data, sample_rate)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号