diff --git a/classifier/compined.wav b/classifier/compined.wav new file mode 100644 index 0000000..b9c1d1e Binary files /dev/null and b/classifier/compined.wav differ diff --git a/classifier/feature_extraction/feature_extractor.py b/classifier/feature_extraction/feature_extractor.py index aaa8025..34cc6b9 100644 --- a/classifier/feature_extraction/feature_extractor.py +++ b/classifier/feature_extraction/feature_extractor.py @@ -1,4 +1,3 @@ -# import essentia.standard import essentia from essentia.standard import (MonoLoader, Windowing, Spectrum, MFCC, ZeroCrossingRate, SpectralCentroidTime, RollOff, Flux, Envelope, diff --git a/classifier/pipeline.py b/classifier/pipeline.py index 3fd8720..f291d77 100644 --- a/classifier/pipeline.py +++ b/classifier/pipeline.py @@ -1,7 +1,8 @@ import numpy as np +from feature_extraction.feature_extractor import extractFeatures from feature_extraction.batch_feature_extractor import batchExtract -from preprocessing.data_preprocessing import createSingleFeaturesArray, standardization, PCA -from classification_model_training.model_training import simpleTrain, kFCrossValid +from preprocessing.data_preprocessing import arrayFromJSON, createSingleFeaturesArray, standardization, PCA +from training.model_training import simpleTrain, kFCrossValid batchExtract('../dataset/music_wav/', 'feature_extraction/music_features/', 22050) batchExtract('../dataset/speech_wav/', 'feature_extraction/speech_features/', 22050) @@ -14,4 +15,10 @@ dataset = standardization(dataset) # dataset = PCA(dataset) print('Simple train accuracy achieved = ' + str(simpleTrain(dataset, target))) kFCrossValid(dataset, target, model = 'svm') -kFCrossValid(dataset, target, model = 'rndForest') \ No newline at end of file +clf = kFCrossValid(dataset, target, model = 'rndForest') + +extractFeatures('compined.wav', 'featuresStream/tmp.json', 22050) +values = arrayFromJSON('featuresStream/tmp.json')[1] +values = standardization(values) +audioClass = clf.predict(values) +print(audioClass) \ No newline at end of file diff --git a/classifier/classification_model_training/model_training.py b/classifier/training/model_training.py similarity index 100% rename from classifier/classification_model_training/model_training.py rename to classifier/training/model_training.py diff --git a/classifier/visualization/visualization.py b/classifier/visualization/visualization.py new file mode 100644 index 0000000..b51bc8d --- /dev/null +++ b/classifier/visualization/visualization.py @@ -0,0 +1,17 @@ +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import seaborn as sns +sns.set() + +datasetArray = np.load('../preprocessing/dataset.npy') +target = np.load('../preprocessing/target.npy') +featureKeysVector = np.load('../preprocessing/featureKeys.npy') + +dataset = pd.DataFrame(datasetArray) +dataset.columns = featureKeysVector + +sns.relplot(x="4HzMod", y="Flat", data=dataset[["4HzMod", "Flat"]], hue = target, style = target) +sns.jointplot(x="SLAtt", y="ZCR", data=dataset[["SLAtt", "ZCR"]]); +sns.pairplot(data=dataset[["SDec", "Flat", "mfcc2", "HFC"]]); +plt.show()