Merge pull request #35 from rakuri255/fix_unknown_language_for_hyphen

- Fix unknown hyphen language
This commit is contained in:
Vadim Rangnau authored and GitHub committed 2023-05-27 21:26:44 +02:00
commit d7045f4dab
3 files changed
+26 -18

No files matched your search

+13 -5
View File
@@ -4,7 +4,6 @@ import os
import sys
import Levenshtein
import librosa
import re
from moduls import os_helper
from moduls.Audio.vocal_chunks import export_chunks_from_ultrastar_data, convert_audio_to_mono_wav, \
@@ -20,7 +19,8 @@ from moduls.Ultrastar import ultrastar_parser, ultrastar_converter, ultrastar_wr
from moduls.Speech_Recognition.Vosk import transcribe_with_vosk
from moduls.Speech_Recognition.hyphenation import hyphenation, language_check
from moduls.Speech_Recognition.Whisper import transcribe_with_whisper
from moduls.Log import PRINT_ULTRASTAR, print_blue_highlighted_text, print_gold_highlighted_text, \
from moduls.Log import PRINT_ULTRASTAR, print_red_highlighted_text, print_blue_highlighted_text, \
print_gold_highlighted_text, \
print_light_blue_highlighted_text
from matplotlib import pyplot as plt
from Settings import Settings
@@ -192,8 +192,14 @@ def remove_unecessary_punctuations(transcribed_data):
def hyphenate_each_word(language, transcribed_data):
lang_region = language_check(language)
hyphenated_word = []
lang_region = language_check(language)
if lang_region is None:
print("{} {} {}".format(PRINT_ULTRASTAR, print_red_highlighted_text("Error in hyphenation for language "),
print_blue_highlighted_text(language),
print_red_highlighted_text("maybe you want to disable it?")))
return None
sleep(.1)
for i in tqdm(range(len(transcribed_data))):
hyphenated_word.append(hyphenation(transcribed_data[i].word, lang_region))
@@ -245,7 +251,8 @@ def run():
if settings.hyphenation:
hyphen_words = hyphenate_each_word(language, transcribed_data)
transcribed_data = add_hyphen_to_data(transcribed_data, hyphen_words)
if hyphen_words is not None:
transcribed_data = add_hyphen_to_data(transcribed_data, hyphen_words)
# todo: do we need to correct words?
# lyric = 'input/faber_lyric.txt'
@@ -328,7 +335,8 @@ def create_ultrastar_txt_from_ultrastar_data(song_output, ultrastar_class, ultra
def create_ultrastar_txt_from_automation(audio_separation_path, basename_without_ext, real_bpm, song_output,
transcribed_data, ultrastar_audio_input_path, ultrastar_note_numbers, language):
transcribed_data, ultrastar_audio_input_path, ultrastar_note_numbers,
language):
real_bpm = get_bpm_from_file(ultrastar_audio_input_path)
ultrastar_file_output = os.path.join(song_output, basename_without_ext + '.txt')
ultrastar_writer.create_ultrastar_txt_from_automation(transcribed_data, ultrastar_note_numbers,
+1 -1
View File
@@ -15,7 +15,7 @@ def language_check(language='en'):
break
if lang_region is None:
raise Exception('{} Missing language "{}" for {}. Install it or disable {}. >> {}'.format(PRINT_ULTRASTAR, print_blue_highlighted_text(language), print_blue_highlighted_text("hyphen"), print_blue_highlighted_text("hyphen"), print_gold_highlighted_text("--hyphenation False")))
return None
print("{} Hyphenate using language code: {}".format(PRINT_ULTRASTAR, print_blue_highlighted_text(lang_region)))
return lang_region
+12 -12
View File
@@ -33,17 +33,17 @@ def parse_ultrastar_txt(input_file):
# [2] duration
# [3] pitch
# [4] word
if parts[0] and parts[1] and parts[2] and parts[3] and parts[4]:
ultrastar_class.noteType.append(parts[0])
ultrastar_class.startBeat.append(parts[1])
ultrastar_class.durations.append(parts[2])
ultrastar_class.pitches.append(parts[3])
ultrastar_class.words.append(parts[4])
# do always as last
pos = len(ultrastar_class.startBeat) - 1
ultrastar_class.startTimes.append(get_start_time_from_ultrastar(ultrastar_class, pos))
ultrastar_class.endTimes.append(get_end_time_from_ultrastar(ultrastar_class, pos))
# todo: Progress?
# print(parts[4])
ultrastar_class.noteType.append(parts[0])
ultrastar_class.startBeat.append(parts[1])
ultrastar_class.durations.append(parts[2])
ultrastar_class.pitches.append(parts[3])
ultrastar_class.words.append(parts[4] if len(parts) > 4 else '')
# do always as last
pos = len(ultrastar_class.startBeat) - 1
ultrastar_class.startTimes.append(get_start_time_from_ultrastar(ultrastar_class, pos))
ultrastar_class.endTimes.append(get_end_time_from_ultrastar(ultrastar_class, pos))
# todo: Progress?
return ultrastar_class