Browse Source

Init visualization, Add compined wav test file

master
Apostolos Fanakis 6 years ago
parent
commit
370318bef0
No known key found for this signature in database GPG Key ID: 56CE2DEDE9F1FB78
  1. BIN
      classifier/compined.wav
  2. 1
      classifier/feature_extraction/feature_extractor.py
  3. 13
      classifier/pipeline.py
  4. 0
      classifier/training/model_training.py
  5. 17
      classifier/visualization/visualization.py

BIN
classifier/compined.wav

Binary file not shown.

1
classifier/feature_extraction/feature_extractor.py

@ -1,4 +1,3 @@
# import essentia.standard
import essentia import essentia
from essentia.standard import (MonoLoader, Windowing, Spectrum, MFCC, from essentia.standard import (MonoLoader, Windowing, Spectrum, MFCC,
ZeroCrossingRate, SpectralCentroidTime, RollOff, Flux, Envelope, ZeroCrossingRate, SpectralCentroidTime, RollOff, Flux, Envelope,

13
classifier/pipeline.py

@ -1,7 +1,8 @@
import numpy as np import numpy as np
from feature_extraction.feature_extractor import extractFeatures
from feature_extraction.batch_feature_extractor import batchExtract from feature_extraction.batch_feature_extractor import batchExtract
from preprocessing.data_preprocessing import createSingleFeaturesArray, standardization, PCA from preprocessing.data_preprocessing import arrayFromJSON, createSingleFeaturesArray, standardization, PCA
from classification_model_training.model_training import simpleTrain, kFCrossValid from training.model_training import simpleTrain, kFCrossValid
batchExtract('../dataset/music_wav/', 'feature_extraction/music_features/', 22050) batchExtract('../dataset/music_wav/', 'feature_extraction/music_features/', 22050)
batchExtract('../dataset/speech_wav/', 'feature_extraction/speech_features/', 22050) batchExtract('../dataset/speech_wav/', 'feature_extraction/speech_features/', 22050)
@ -14,4 +15,10 @@ dataset = standardization(dataset)
# dataset = PCA(dataset) # dataset = PCA(dataset)
print('Simple train accuracy achieved = ' + str(simpleTrain(dataset, target))) print('Simple train accuracy achieved = ' + str(simpleTrain(dataset, target)))
kFCrossValid(dataset, target, model = 'svm') kFCrossValid(dataset, target, model = 'svm')
kFCrossValid(dataset, target, model = 'rndForest') 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)

0
classifier/classification_model_training/model_training.py → classifier/training/model_training.py

17
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()
Loading…
Cancel
Save