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)
评论列表
文章目录