数据集和代码均已上传到Github中,欢迎大家下载使用。
Github地址:https://github.com/JasonZhang156/Sound-Recognition-Tutorial
如果这个教程对您有所帮助,请不吝贡献您的小星星Q^Q.
数据分析
本节针对ESC-10数据集进行基本的数据分析,包括数据样本数,数据类别数,每类声音样本数等信息。并且对每类样本的声音波形,功率谱进行绘制,比较不同类样本之间的声音特性差异。代码如下:
# -*- coding: utf-8 -*-
"""
@author: Jason Zhang
@github: https://github.com/JasonZhang156/Sound-Recognition-Tutorial
"""
import os
import numpy as np
import librosa
import librosa.display
import matplotlib.pyplot as plt
from glob import glob
def data_stat():
"""data statistic"""
audio_path = './data/esc10/audio/'
class_list = [os.path.basename(i) for i in glob(audio_path + '*')]
nums_each_class = [len(glob(audio_path +