Commit 15f0a7e4 authored by Tomas Rokos's avatar Tomas Rokos
parents d0bd0c32 4ade09aa
......@@ -11,3 +11,4 @@ audio_classification.egg-info
node_modules
.cache
graphs/*
*/__pycache__
......@@ -20,6 +20,7 @@ def preprocess_sample(path, **kwargs):
def preprocess(n_mfcc):
output_folder = f'preprocessed_nmfcc_{n_mfcc}'
output_file = os.path.join(output_folder, 'data.csv')
similarity_file = os.path.join(output_folder, 'similarity.pyc')
columns = ['file', 'label']
df = pd.read_csv(DATASET_FILE, sep='\t', header=None, names=columns)
......@@ -54,11 +55,20 @@ def preprocess(n_mfcc):
done += 1
print(f'Preprocessing <{done}/{length}> ', end='\r')
print('\nDone')
output_df = pd.DataFrame(output_index, columns=columns, index=None)
output_df.to_csv(output_file, header=False, index=False)
similarity_list = list()
for i in range(len(output_index)):
for j in range(i, len(output_index)):
similarity_list.append((output_index[j][0], output_index[i][0], output_index[i][1] == output_index[j][1]))
similarity_df = pd.DataFrame(similarity_list, columns=['file_1', 'file_2', 'label'], index=None)
similarity_df.to_pickle(similarity_file, protocol=4)
print('\nDone')
if __name__ == '__main__':
preprocess(13)
......@@ -14,6 +14,8 @@ classifiers = {
'mock': MockClassifier()
}
classifier = classifiers['mock']
if not os.path.exists(UPLOAD_FOLDER):
os.mkdir(UPLOAD_FOLDER)
......@@ -60,8 +62,9 @@ def classify():
try:
os.mkdir(folder)
file.save(filepath)
# prediction = classifier.classify_file(filepath)
prediction = classifier.classify_file(filepath)
return jsonify({
"prediction": prediction,
"filename": file.filename,
"soundwave": generate_soundwave(filepath)
})
......@@ -77,3 +80,4 @@ def classify():
if __name__ == '__main__':
app.run(port=4666)
app.run(port=4667)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment