mirror of
https://github.com/rakuri255/UltraSinger.git
synced 2026-12-04 17:16:05 +09:00
- Update PyHyphen lang codes
- Catch when lang code for hyphen is unknown - Fix hyphenation disabling
This commit is contained in:
1 parent
1b8003b2ba
commit
37664ab35d
3 files changed
+81
-14
No files matched your search
+1
-1
@@ -1,5 +1,5 @@
|
||||
class Settings:
|
||||
APP_VERSION = "0.0.1-2023-10-06"
|
||||
APP_VERSION = "0.0.1-2023-11-13"
|
||||
|
||||
create_midi = True
|
||||
create_plot = False
|
||||
|
||||
+14
-9
@@ -229,20 +229,25 @@ def remove_unecessary_punctuations(transcribed_data: list[TranscribedData]) -> N
|
||||
|
||||
def hyphenate_each_word(language: str, transcribed_data: list[TranscribedData]) -> list[list[str]] | None:
|
||||
"""Hyphenate each word in the transcribed data."""
|
||||
hyphenated_word = []
|
||||
lang_region = language_check(language)
|
||||
if lang_region is None:
|
||||
print(
|
||||
f"{ULTRASINGER_HEAD} {red_highlighted('Error in hyphenation for language ')} {blue_highlighted(language)} {red_highlighted(', maybe you want to disable it?')}"
|
||||
f"{ULTRASINGER_HEAD} {red_highlighted('Error in hyphenation for language ')} {blue_highlighted(language)}{red_highlighted(', maybe you want to disable it?')}"
|
||||
)
|
||||
return None
|
||||
|
||||
hyphenator = create_hyphenator(lang_region)
|
||||
for i in tqdm(enumerate(transcribed_data)):
|
||||
pos = i[0]
|
||||
hyphenated_word.append(
|
||||
hyphenation(transcribed_data[pos].word, hyphenator)
|
||||
)
|
||||
hyphenated_word = []
|
||||
try:
|
||||
hyphenator = create_hyphenator(lang_region)
|
||||
for i in tqdm(enumerate(transcribed_data)):
|
||||
pos = i[0]
|
||||
hyphenated_word.append(
|
||||
hyphenation(transcribed_data[pos].word, hyphenator)
|
||||
)
|
||||
except:
|
||||
print(f"{ULTRASINGER_HEAD} {red_highlighted('Error in hyphenation for language ')} {blue_highlighted(language)}{red_highlighted(', maybe you want to disable it?')}")
|
||||
return None
|
||||
|
||||
return hyphenated_word
|
||||
|
||||
|
||||
@@ -808,7 +813,7 @@ def init_settings(argv: list[str]) -> None:
|
||||
elif opt in ("--midi"):
|
||||
settings.create_midi = arg in ["True", "true"]
|
||||
elif opt in ("--hyphenation"):
|
||||
settings.hyphenation = arg
|
||||
settings.hyphenation = eval(arg.title())
|
||||
elif opt in ("--disable_separation"):
|
||||
settings.use_separated_vocal = not arg
|
||||
elif opt in ("--disable_karaoke"):
|
||||
|
||||
@@ -2,21 +2,83 @@
|
||||
|
||||
import string
|
||||
|
||||
from hyphen import Hyphenator, dictools
|
||||
from hyphen import Hyphenator
|
||||
|
||||
from modules.console_colors import (
|
||||
ULTRASINGER_HEAD,
|
||||
blue_highlighted,
|
||||
)
|
||||
|
||||
# PyHyphen tries to retrieve dictionaries for download 'https://cgit.freedesktop.org/libreoffice/dictionaries/plain/'
|
||||
# Updated PyHyphen dictools Languages, so they can be installed
|
||||
LANGUAGES = [
|
||||
"af_ZA",
|
||||
"an_ES",
|
||||
"ar",
|
||||
"be_BY",
|
||||
"bg_BG",
|
||||
"bn_BD",
|
||||
"bo",
|
||||
"br_FR",
|
||||
"bs_BA",
|
||||
"ca",
|
||||
"ckb",
|
||||
"cs_CZ",
|
||||
"da_DK",
|
||||
"de",
|
||||
"el_GR",
|
||||
"en",
|
||||
"eo",
|
||||
"es",
|
||||
"et_EE",
|
||||
"fa_IR",
|
||||
"fr_FR",
|
||||
"gd_GB",
|
||||
"gl",
|
||||
"gu_IN",
|
||||
"gug",
|
||||
"he_IL",
|
||||
"hi_IN",
|
||||
"hr_HR",
|
||||
"hu_HU",
|
||||
"id",
|
||||
"is",
|
||||
"it_IT",
|
||||
"kmr_Latn",
|
||||
"ko_KR",
|
||||
"lo_LA",
|
||||
"lt_LT",
|
||||
"lv_LV",
|
||||
"mn_MN",
|
||||
"ne_NP",
|
||||
"nl_NL",
|
||||
"no",
|
||||
"oc_FR",
|
||||
"pl_PL",
|
||||
"pt_BR",
|
||||
"pt_PT",
|
||||
"ro",
|
||||
"ru_RU",
|
||||
"si_LK",
|
||||
"sk_SK",
|
||||
"sl_SI",
|
||||
"sq_AL",
|
||||
"sr",
|
||||
"sv_SE",
|
||||
"sw_TZ",
|
||||
"te_IN",
|
||||
"th_TH",
|
||||
"tr_TR",
|
||||
"uk_UA",
|
||||
"vi",
|
||||
"zu_ZA",
|
||||
]
|
||||
|
||||
def language_check(language="en") -> str | None:
|
||||
"""Check if language is supported"""
|
||||
|
||||
dict_langs = dictools.LANGUAGES
|
||||
|
||||
lang_region = None
|
||||
for dict_lang in dict_langs:
|
||||
for dict_lang in LANGUAGES:
|
||||
if dict_lang.startswith(language):
|
||||
lang_region = dict_lang
|
||||
break
|
||||
|
||||
Reference in new issue
Block a user