# Path: pyAudioAnalysis/audioBasicIO.py
# def convert_dir_mp3_to_wav(audio_folder, sampling_rate, num_channels,
#                            use_tags=False):
# def convert_dir_fs_wav_to_wav(audio_folder, sampling_rate, num_channels):
# def read_audio_file(input_file):
# def read_aif(path):
# def read_audio_generic(input_file):
# def stereo_to_mono(signal):
# 
# Path: pyAudioAnalysis/MidTermFeatures.py
# def beat_extraction(short_features, window_size, plot=False):
# def mid_feature_extraction(signal, sampling_rate, mid_window, mid_step,
#                            short_window, short_step):
# def directory_feature_extraction(folder_path, mid_window, mid_step,
#                                  short_window, short_step,
#                                  compute_beat=True):
# def multiple_directory_feature_extraction(path_list, mid_window, mid_step,
#                                           short_window, short_step,
#                                           compute_beat=False):
# def directory_feature_extraction_no_avg(folder_path, mid_window, mid_step,
#                                         short_window, short_step):
# def mid_feature_extraction_to_file(file_path, mid_window, mid_step,
#                                    short_window, short_step, output_file,
#                                    store_short_features=False, store_csv=False,
#                                    plot=False):
# def mid_feature_extraction_file_dir(folder_path, mid_window, mid_step,
#                                     short_window, short_step,
#                                     store_short_features=False, store_csv=False,
#                                     plot=False):


from imblearn.under_sampling import RandomUnderSampler
from imblearn.over_sampling import SMOTE
from sklearn.model_selection import GroupShuffleSplit
from pyAudioAnalysis import audioBasicIO
from pyAudioAnalysis import MidTermFeatures as aF
from scipy import linalg as la
from scipy.spatial import distance
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
import sys
import numpy as np
import os
import glob
import pickle as cPickle
import csv
import ntpath
import sklearn.svm
import sklearn.decomposition
import sklearn.ensemble
import plotly
import plotly.subplots
import plotly.graph_objs as go
import sklearn.metrics

def file_classification(input_file, model_name, model_type):
    # Load classifier:
    if not os.path.isfile(model_name):
        print("fileClassification: input model_name not found!")
        return -1, -1, -1

    if isinstance(input_file, str) and not os.path.isfile(input_file):
        print("fileClassification: wav file not found!")
        return -1, -1, -1

    if model_type == 'knn':
        classifier, mean, std, classes, mid_window, mid_step, short_window, \
            short_step, compute_beat = load_model_knn(model_name)
    else:
        classifier, mean, std, classes, mid_window, mid_step, short_window, \
            short_step, compute_beat = load_model(model_name)

    # read audio file and convert to mono
    sampling_rate, signal = audioBasicIO.read_audio_file(input_file)
    signal = audioBasicIO.stereo_to_mono(signal)

    if sampling_rate == 0:
        # audio file IO problem
        return -1, -1, -1
    if signal.shape[0] / float(sampling_rate) < mid_window:
        mid_window = signal.shape[0] / float(sampling_rate)

    # feature extraction:
    mid_features, s, _ = \

# Path: pyAudioAnalysis/audioBasicIO.py
# def convert_dir_mp3_to_wav(audio_folder, sampling_rate, num_channels,
#                            use_tags=False):
# def convert_dir_fs_wav_to_wav(audio_folder, sampling_rate, num_channels):
# def read_audio_file(input_file):
# def read_aif(path):
# def read_audio_generic(input_file):
# def stereo_to_mono(signal):
# 
# Path: pyAudioAnalysis/MidTermFeatures.py
# def beat_extraction(short_features, window_size, plot=False):
# def mid_feature_extraction(signal, sampling_rate, mid_window, mid_step,
#                            short_window, short_step):
# def directory_feature_extraction(folder_path, mid_window, mid_step,
#                                  short_window, short_step,
#                                  compute_beat=True):
# def multiple_directory_feature_extraction(path_list, mid_window, mid_step,
#                                           short_window, short_step,
#                                           compute_beat=False):
# def directory_feature_extraction_no_avg(folder_path, mid_window, mid_step,
#                                         short_window, short_step):
# def mid_feature_extraction_to_file(file_path, mid_window, mid_step,
#                                    short_window, short_step, output_file,
#                                    store_short_features=False, store_csv=False,
#                                    plot=False):
# def mid_feature_extraction_file_dir(folder_path, mid_window, mid_step,
#                                     short_window, short_step,
#                                     store_short_features=False, store_csv=False,
#                                     plot=False):


# Path: pyAudioAnalysis/audioTrainTest.py
from imblearn.under_sampling import RandomUnderSampler
from imblearn.over_sampling import SMOTE
from sklearn.model_selection import GroupShuffleSplit
from pyAudioAnalysis import audioBasicIO
from pyAudioAnalysis import MidTermFeatures as aF
from scipy import linalg as la
from scipy.spatial import distance
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
import sys
import numpy as np
import os
import glob
import pickle as cPickle
import csv
import ntpath
import sklearn.svm
import sklearn.decomposition
import sklearn.ensemble
import plotly
import plotly.subplots
import plotly.graph_objs as go
import sklearn.metrics


def file_classification(input_file, model_name, model_type):
    # Load classifier:
    if not os.path.isfile(model_name):
        print("fileClassification: input model_name not found!")
        return -1, -1, -1

    if isinstance(input_file, str) and not os.path.isfile(input_file):
        print("fileClassification: wav file not found!")
        return -1, -1, -1

    if model_type == 'knn':
        classifier, mean, std, classes, mid_window, mid_step, short_window, \
            short_step, compute_beat = load_model_knn(model_name)
    else:
        classifier, mean, std, classes, mid_window, mid_step, short_window, \
            short_step, compute_beat = load_model(model_name)

    # read audio file and convert to mono
    sampling_rate, signal = audioBasicIO.read_audio_file(input_file)
    signal = audioBasicIO.stereo_to_mono(signal)

    if sampling_rate == 0:
        # audio file IO problem
        return -1, -1, -1
    if signal.shape[0] / float(sampling_rate) < mid_window:
        mid_window = signal.shape[0] / float(sampling_rate)

    # feature extraction:
    mid_features, s, _ = \

        aF.mid_feature_extraction(signal, sampling_rate,