# Path: pyAudioAnalysis/audioTrainTest.py
# class Knn:
#     def __init__(self, features, labels, neighbors):
#     def classify(self, test_sample):
# def classifier_wrapper(classifier, classifier_type, test_sample):
# def regression_wrapper(model, model_type, test_sample):
# def train_knn(features, labels, neighbors):
# def train_svm(features, labels, c_param, kernel='linear'):
# def train_random_forest(features, labels, n_estimators):
# def train_gradient_boosting(features, labels, n_estimators):
# def train_extra_trees(features, labels, n_estimators):
# def train_svm_regression(features, labels, c_param, kernel='linear'):
# def train_random_forest_regression(features, labels, n_estimators):
# def extract_features_and_train(paths, mid_window, mid_step, short_window,
#                                short_step, classifier_type, model_name,
#                                compute_beat=False, train_percentage=0.90,
#                                dict_of_ids=None,
#                                use_smote=False):
# def save_parameters(path, *parameters):
# def feature_extraction_train_regression(folder_name, mid_window, mid_step,
#                                         short_window, short_step, model_type,
#                                         model_name, compute_beat=False):
# def load_model_knn(knn_model_name, is_regression=False):
# def load_model(model_name, is_regression=False):
# def group_split(X, y, train_indeces, test_indeces, split_id):
# def evaluate_classifier(features, class_names, classifier_name, params,
#                         parameter_mode, list_of_ids=None, n_exp=-1,
#                         train_percentage=0.90,
#                         smote=False):
# def evaluate_regression(features, labels, n_exp, method_name, params):
# def print_confusion_matrix(cm, class_names):
# def features_to_matrix(features):
# def pca_wrapper(features, dimensions):
# def compute_class_rec_pre_f1(c_mat):
# def evaluate_model_for_folders(input_test_folders, model_name, model_type,
#                                positive_class, plot=True):
# def file_classification(input_file, model_name, model_type):
# def file_regression(input_file, model_name, model_type):
# def lda(data, labels, red_dim):
# def train_speaker_models():
# def main(argv):
#         P = np.zeros((n_classes,))
#                 R = regression_wrapper(classifier, method_name, fTest)
#     R = []
#     C = np.cov((data.T))


import os
import sys
import argparse
from pyAudioAnalysis import audioTrainTest as aT
def parseArguments():
    parser = argparse.ArgumentParser(prog='PROG')
    parser.add_argument('-d' , '--data_folder',
                        nargs=None,
                        default="/Users/tyiannak/ResearchData/"
                                "Audio Dataset/pyAudioAnalysisData/")
    parser.add_argument('-c', '--classifier_type', nargs=None, required=True,
                        choices = ["knn", "svm", "svm_rbf", "randomforest",
                                   "extratrees", "gradientboosting"],
                        help="Classifier type")
    parser.add_argument('-t', '--task', nargs=None, required=True,
                        choices = ["sm", "movie8", "speakers", "speaker-gender",
                                   "music-genre6", "4class"],
                        help="Classification task")
    args = parser.parse_args()        
    return args



if __name__ == '__main__':
    args = parseArguments()
    root_data_path = args.data_folder
    classifier_type = args.classifier_type

    if args.task == "sm":
        aT.extract_features_and_train([root_data_path +"SM/speech",
                            root_data_path + "SM/music"],
                           1.0, 1.0, 0.05, 0.05, classifier_type,
                           classifier_type + "_sm", False)
    elif args.task == "movie8":

# Path: pyAudioAnalysis/audioTrainTest.py
# class Knn:
#     def __init__(self, features, labels, neighbors):
#     def classify(self, test_sample):
# def classifier_wrapper(classifier, classifier_type, test_sample):
# def regression_wrapper(model, model_type, test_sample):
# def train_knn(features, labels, neighbors):
# def train_svm(features, labels, c_param, kernel='linear'):
# def train_random_forest(features, labels, n_estimators):
# def train_gradient_boosting(features, labels, n_estimators):
# def train_extra_trees(features, labels, n_estimators):
# def train_svm_regression(features, labels, c_param, kernel='linear'):
# def train_random_forest_regression(features, labels, n_estimators):
# def extract_features_and_train(paths, mid_window, mid_step, short_window,
#                                short_step, classifier_type, model_name,
#                                compute_beat=False, train_percentage=0.90,
#                                dict_of_ids=None,
#                                use_smote=False):
# def save_parameters(path, *parameters):
# def feature_extraction_train_regression(folder_name, mid_window, mid_step,
#                                         short_window, short_step, model_type,
#                                         model_name, compute_beat=False):
# def load_model_knn(knn_model_name, is_regression=False):
# def load_model(model_name, is_regression=False):
# def group_split(X, y, train_indeces, test_indeces, split_id):
# def evaluate_classifier(features, class_names, classifier_name, params,
#                         parameter_mode, list_of_ids=None, n_exp=-1,
#                         train_percentage=0.90,
#                         smote=False):
# def evaluate_regression(features, labels, n_exp, method_name, params):
# def print_confusion_matrix(cm, class_names):
# def features_to_matrix(features):
# def pca_wrapper(features, dimensions):
# def compute_class_rec_pre_f1(c_mat):
# def evaluate_model_for_folders(input_test_folders, model_name, model_type,
#                                positive_class, plot=True):
# def file_classification(input_file, model_name, model_type):
# def file_regression(input_file, model_name, model_type):
# def lda(data, labels, red_dim):
# def train_speaker_models():
# def main(argv):
#         P = np.zeros((n_classes,))
#                 R = regression_wrapper(classifier, method_name, fTest)
#     R = []
#     C = np.cov((data.T))


# Path: tests/script_train_classifiers_all.py
import os
import sys
import argparse
from pyAudioAnalysis import audioTrainTest as aT

def parseArguments():
    parser = argparse.ArgumentParser(prog='PROG')
    parser.add_argument('-d' , '--data_folder',
                        nargs=None,
                        default="/Users/tyiannak/ResearchData/"
                                "Audio Dataset/pyAudioAnalysisData/")
    parser.add_argument('-c', '--classifier_type', nargs=None, required=True,
                        choices = ["knn", "svm", "svm_rbf", "randomforest",
                                   "extratrees", "gradientboosting"],
                        help="Classifier type")
    parser.add_argument('-t', '--task', nargs=None, required=True,
                        choices = ["sm", "movie8", "speakers", "speaker-gender",
                                   "music-genre6", "4class"],
                        help="Classification task")
    args = parser.parse_args()        
    return args



if __name__ == '__main__':
    args = parseArguments()
    root_data_path = args.data_folder
    classifier_type = args.classifier_type

    if args.task == "sm":
        aT.extract_features_and_train([root_data_path +"SM/speech",
                            root_data_path + "SM/music"],
                           1.0, 1.0, 0.05, 0.05, classifier_type,
                           classifier_type + "_sm", False)
    elif args.task == "movie8":

        aT.extract_features_and_train([root_data_path + "movieSegments/8-class/Speech",