import librosa.display import matplotlib.pyplot as plt import numpy as np from import_dataset import import_all_files from group_data import get_data from librosa.feature import mfcc from librosa.feature import melspectrogram from tqdm import tqdm directory = "D:\\Google Drive\\Programs\\Jupyter\\Machine Learning\\project\\data\\audio_and_txt_files" #%% Get clips clips = import_all_files(directory) #%% Get data and test separated only by class data = get_data(clips, grouping="default", dtype="clip") #%% Do mfcc on every clip c = 1 images = [[], [], [], []] for group in data: for clip in tqdm( group, "Taking MFCC of clips in group " + str(c) + " of " + str(len(data))): clip.mfcc = mfcc(y=clip.sound_data, sr=clip.sr) c += 1 #%% Plot random mfccs from each group c = 0 for group in data: # Get images to plot
Created on Thu Jun 25 02:08:28 2020 @author: sukris """ from import_dataset import import_all_files from group_data import get_data import numpy as np directory = "D:\\Google Drive\\Programs\\Jupyter\\Machine Learning\\project\\data\\audio_and_txt_files" # Get clips clips = import_all_files(directory) # Get data and test separated only by class data0 = get_data(clips, grouping="default", dtype="clip") # Test if all clips in first group are normal (No wheezes or crackles) for clip in data0[0]: if clip.crackle or clip.wheeze: print("Test failed, line 24",clip.crackle,clip.wheeze) break for clip in data0[1]: if not (clip.crackle and not clip.wheeze): print("Test failed, line 28",clip.crackle,clip.wheeze) break for clip in data0[2]: if not (not clip.crackle and clip.wheeze): print("Test failed, line 32",clip.crackle,clip.wheeze) break for clip in data0[3]: