目的:识别三个单词(bed,cat,happy)
github:https://github.com/yaokaishile/three-classification
一:导入需要的包
import librosa import os from sklearn.model_selection import train_test_split from keras.utils import to_categorical import numpy as np from tqdm import tqdm123456
二、定义所需函数
def get_labels(path=DATA_PATH): labels = os.listdir(path) label_indices = np.arange(0, len(labels)) return labels, label_indices, to_categorical(label_indices) def wav2mfcc(file_path): wave, sr = librosa.load(file_path, mono=True, sr=None) mfcc = librosa.feature.mfcc(wave, sr=16000) return mfcc def save_data_to_array(path=DATA_PATH): lab
12345678910111213141516