mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-11-20 13:07:52 +09:00
Merge pull request #31 from rakuri255/write_and_parse_in_utf8
Write and parse in utf8
This commit is contained in:
3 files changed
+26
-9
No files matched your search
+21
-4
@@ -20,7 +20,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, print_light_blue_highlighted_text
|
||||
from moduls.Log import PRINT_ULTRASTAR, print_blue_highlighted_text, print_gold_highlighted_text, \
|
||||
print_light_blue_highlighted_text
|
||||
from matplotlib import pyplot as plt
|
||||
from Settings import Settings
|
||||
from tqdm import tqdm
|
||||
@@ -201,9 +202,12 @@ def hyphenate_each_word(language, transcribed_data):
|
||||
|
||||
def print_support():
|
||||
print()
|
||||
print("{} {} {}{}".format(PRINT_ULTRASTAR, print_gold_highlighted_text("Do you like UltraSinger? And want it to be even better? Then help with your"), print_light_blue_highlighted_text("support"), print_gold_highlighted_text("!")))
|
||||
print("{} {} {}{}".format(PRINT_ULTRASTAR, print_gold_highlighted_text(
|
||||
"Do you like UltraSinger? And want it to be even better? Then help with your"),
|
||||
print_light_blue_highlighted_text("support"), print_gold_highlighted_text("!")))
|
||||
print("{} See project page -> https://github.com/rakuri255/UltraSinger".format(PRINT_ULTRASTAR))
|
||||
print("{} {}".format(PRINT_ULTRASTAR, print_gold_highlighted_text("This will help alot to keep this project alive and improved.")))
|
||||
print("{} {}".format(PRINT_ULTRASTAR,
|
||||
print_gold_highlighted_text("This will help alot to keep this project alive and improved.")))
|
||||
|
||||
|
||||
def run():
|
||||
@@ -279,6 +283,7 @@ def run():
|
||||
# Print Support
|
||||
print_support()
|
||||
|
||||
|
||||
def transcribe_audio(transcribed_data):
|
||||
if settings.transcriber == "whisper":
|
||||
transcribed_data, language = transcribe_with_whisper(settings.mono_audio_path, settings.whisper_model,
|
||||
@@ -352,9 +357,21 @@ def setup_audio_input_file():
|
||||
return basename_without_ext, song_output, ultrastar_audio_input_path
|
||||
|
||||
|
||||
FILENAME_REPLACEMENTS = (('?:"', ""), ("<", "("), (">", ")"), ("/\\|*", "-"))
|
||||
|
||||
|
||||
def sanitize_filename(fname: str) -> str:
|
||||
for old, new in FILENAME_REPLACEMENTS:
|
||||
for char in old:
|
||||
fname = fname.replace(char, new)
|
||||
if fname.endswith("."):
|
||||
fname = fname.rstrip(" .") # Windows does not like trailing periods
|
||||
return fname
|
||||
|
||||
|
||||
def download_from_youtube():
|
||||
title = get_youtube_title(settings.input_file_path)
|
||||
basename_without_ext = re.sub('[^A-Za-z0-9. _-]+', '', title).strip()
|
||||
basename_without_ext = sanitize_filename(title)
|
||||
basename = basename_without_ext + '.mp3'
|
||||
song_output = os.path.join(settings.output_file_path, basename_without_ext)
|
||||
os_helper.create_folder(song_output)
|
||||
|
||||
@@ -2,10 +2,11 @@ from moduls.Ultrastar.ultrastar_txt import UltrastarTxt
|
||||
from moduls.Ultrastar.ultrastar_converter import get_end_time_from_ultrastar, get_start_time_from_ultrastar
|
||||
from moduls.Log import PRINT_ULTRASTAR
|
||||
|
||||
|
||||
def parse_ultrastar_txt(input_file):
|
||||
print(PRINT_ULTRASTAR + " Parse ultrastar txt -> {}".format(input_file))
|
||||
|
||||
file = open(input_file, 'r')
|
||||
file = open(input_file, 'r', encoding='utf8')
|
||||
txt = file.readlines()
|
||||
|
||||
ultrastar_class = UltrastarTxt()
|
||||
@@ -46,5 +47,3 @@ def parse_ultrastar_txt(input_file):
|
||||
# print(parts[4])
|
||||
|
||||
return ultrastar_class
|
||||
|
||||
|
||||
@@ -20,14 +20,15 @@ def get_language_name(language):
|
||||
return langcodes.Language.make(language=language).display_name()
|
||||
|
||||
|
||||
def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrastar_file_output, title, language, bpm=120):
|
||||
def create_ultrastar_txt_from_automation(transcribed_data, note_numbers, ultrastar_file_output, title, language,
|
||||
bpm=120):
|
||||
print("{} Creating {} from transcription.".format(PRINT_ULTRASTAR, ultrastar_file_output))
|
||||
|
||||
real_bpm = real_bpm_to_ultrastar_bpm(bpm)
|
||||
multiplication = get_multiplier(real_bpm)
|
||||
ultrastar_bpm = real_bpm * get_multiplier(real_bpm)
|
||||
|
||||
with open(ultrastar_file_output, 'w') as f:
|
||||
with open(ultrastar_file_output, 'w', encoding='utf8') as f:
|
||||
gap = transcribed_data[0].start
|
||||
|
||||
f.write('#ARTIST:' + title + '\n')
|
||||
|
||||
Reference in new issue
Block a user