def model_check(): new_path = model_path new_model = current_model tools.printer(11, 'training', new_model) if os.path.isdir(new_path) == True: tools.printer(8, 'already trainings file for', new_model) u_input = tools.get_inputs([['d', 'delete and recreate', 0], ['c', 'choose another trainings name', 0]], '', True, True) if u_input == 'd': tools.delete_all(new_path) elif u_input == 'c': while True: new_model = input(" new name for training\n\n--:") new_path = current_dir + '/languages/' + str( language_data[0]) + '/training/' + new_model + '/' if os.path.isdir(new_path) == False: break elif new_model in ['q', 'Q']: return [False] print() tools.printer(8, 'already trainings file for', new_model) elif new_model in ['q', 'Q']: return [False] else: return [False] tools.create_folder(current_dir, new_model, 'create', language_data[0]) tools.printer(-3, '', '', True, new_path + 'info/training.txt', True, False) return [True, new_model, new_path]
def error_flag(): if sec_input == '': tools.printer(8, 'no audio path') array = [ tools.get_inputs([['wav_path', 'audio path from db', 1], ['audios_id', 'audio id from db', 5]], '', True, True) ] else: array = [sec_input] try: sql_test = "select audios_id from audios where audios_id=" + str( int(array[0])) + "" sql = "update audios set errors=9 where wav_path=" + str(int( array[0])) + "" except: sql_test = "select audios_id from audios where wav_path='" + str( array[0]) + "'" sql = "update audios set errors=9 where wav_path='" + str( array[0]) + "'" if str(array[0]) == 'unflag': tools.printer(22, 'all errors are unflagged', array[0]) main_db[1].execute('update audios set errors=0') main_db[0].commit() else: main_db[1].execute(sql_test) test = main_db[1].fetchall() if len(test) > 0: tools.printer(22, 'error flagged', array[0]) main_db[1].execute(sql) main_db[0].commit() else: tools.printer(9, 'not found', array[0])
def test_sentences(): if sec_input == '': tools.printer(8, 'no test input') array = [ tools.get_inputs([['', 'sentences or path', -1]], '', True, True) ] if os.path.isfile(sec_input) == True: array = tools.get_file(sec_input, True) elif sec_input != '': array = [sec_input] print() for arr in array: cleaned = alphabet.sentences_cleaner(prepare, str(arr), language_data[0], args.upper, num_activ, args.lower) if cleaned == False: tools.printer(8, arr + '\n') else: tools.printer(2, arr) tools.printer(22, cleaned + '\n')
model_path + 'info/training.txt', deepspeech_dir[1]) language_data[4].commit() create_train_files() elif mode == 'error': error_flag() elif mode == 'insert': tools.printer(-3) tools.printer(1, 'Inserter\n') if sec_input == '': tools.printer(8, 'no path selected', '') corpus_path = tools.get_inputs([['', '', 2]], 'enter corpus path', True, True) else: corpus_path = sec_input if corpus_path != False: tools.printer(2, 'found path', str(corpus_path)) downloader.insert_corpora(corpus_path, True, main_db, language_data[0]) else: tools.printer(9, 'path not found', str(corpus_path)) elif mode == 'test' or mode == 'testing': tools.printer(-3) tools.printer(1, 'Replacement Tester\n') test_sentences()