Refactor flag icon handling and update language code mappings for SuperTonic and Kokoro
|
Before Width: | Height: | Size: 571 B |
|
After Width: | Height: | Size: 992 B |
|
Before Width: | Height: | Size: 786 B |
|
After Width: | Height: | Size: 877 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 832 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 521 B |
|
After Width: | Height: | Size: 868 B |
|
After Width: | Height: | Size: 808 B |
|
Before Width: | Height: | Size: 372 B |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 883 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 465 B |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 885 B |
|
Before Width: | Height: | Size: 381 B |
|
After Width: | Height: | Size: 855 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 917 B |
|
Before Width: | Height: | Size: 441 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 856 B |
|
After Width: | Height: | Size: 837 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 875 B |
|
Before Width: | Height: | Size: 617 B |
|
After Width: | Height: | Size: 843 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 875 B |
|
After Width: | Height: | Size: 891 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 851 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 431 B |
@@ -29,6 +29,57 @@ LANGUAGE_DESCRIPTIONS = {
|
||||
"z": "Mandarin Chinese",
|
||||
}
|
||||
|
||||
# Mapping from Kokoro single-letter language codes to ISO 3166-1 alpha-2 country codes
|
||||
# Used for loading flag icons
|
||||
KOKORO_LANG_TO_COUNTRY = {
|
||||
"a": "us", # American English -> United States
|
||||
"b": "gb", # British English -> United Kingdom
|
||||
"e": "es", # Spanish -> Spain
|
||||
"f": "fr", # French -> France
|
||||
"h": "in", # Hindi -> India
|
||||
"i": "it", # Italian -> Italy
|
||||
"j": "jp", # Japanese -> Japan
|
||||
"p": "br", # Brazilian Portuguese -> Brazil
|
||||
"z": "cn", # Mandarin Chinese -> China
|
||||
}
|
||||
|
||||
# Mapping from SuperTonic ISO 639-1 language codes to ISO 3166-1 alpha-2 country codes
|
||||
# Used for loading flag icons in the SuperTonic language picker
|
||||
SUPERTONIC_LANG_TO_COUNTRY = {
|
||||
"en": "gb",
|
||||
"ko": "kr",
|
||||
"ja": "jp",
|
||||
"ar": "ae",
|
||||
"bg": "bg",
|
||||
"cs": "cz",
|
||||
"da": "dk",
|
||||
"de": "de",
|
||||
"el": "gr",
|
||||
"es": "es",
|
||||
"et": "ee",
|
||||
"fi": "fi",
|
||||
"fr": "fr",
|
||||
"hi": "in",
|
||||
"hr": "hr",
|
||||
"hu": "hu",
|
||||
"id": "id",
|
||||
"it": "it",
|
||||
"lt": "lt",
|
||||
"lv": "lv",
|
||||
"nl": "nl",
|
||||
"pl": "pl",
|
||||
"pt": "pt",
|
||||
"ro": "ro",
|
||||
"ru": "ru",
|
||||
"sk": "sk",
|
||||
"sl": "si",
|
||||
"sv": "se",
|
||||
"tr": "tr",
|
||||
"uk": "ua",
|
||||
"vi": "vn",
|
||||
"na": "na",
|
||||
}
|
||||
|
||||
# Supported sound formats
|
||||
SUPPORTED_SOUND_FORMATS = [
|
||||
"wav",
|
||||
|
||||
@@ -84,6 +84,8 @@ from abogen.constants import (
|
||||
PROGRAM_DESCRIPTION,
|
||||
LANGUAGE_DESCRIPTIONS,
|
||||
VOICES_INTERNAL,
|
||||
KOKORO_LANG_TO_COUNTRY,
|
||||
SUPERTONIC_LANG_TO_COUNTRY,
|
||||
SUPPORTED_LANGUAGES_FOR_SUBTITLE_GENERATION,
|
||||
COLORS,
|
||||
SUBTITLE_FORMATS,
|
||||
@@ -1143,7 +1145,10 @@ class abogen(QWidget):
|
||||
supertonic_row_layout.addWidget(st_lang_label)
|
||||
self.st_lang_combo = QComboBox(self)
|
||||
for code in SUPERTONIC_AVAILABLE_LANGS:
|
||||
self.st_lang_combo.addItem(code, code)
|
||||
country_code = SUPERTONIC_LANG_TO_COUNTRY.get(code, code)
|
||||
flag = get_resource_path("abogen.assets.flags", f"{country_code}.png")
|
||||
icon_st = QIcon(flag) if flag and os.path.exists(flag) else QIcon()
|
||||
self.st_lang_combo.addItem(icon_st, code, code)
|
||||
self.st_lang_combo.setCurrentText("en")
|
||||
self.st_lang_combo.setStyleSheet("QComboBox { min-height: 20px; padding: 6px 12px; }")
|
||||
self.st_lang_combo.currentTextChanged.connect(self._on_st_lang_changed)
|
||||
@@ -2011,7 +2016,8 @@ class abogen(QWidget):
|
||||
else:
|
||||
for v in VOICES_INTERNAL:
|
||||
icon = QIcon()
|
||||
flag_path = get_resource_path("abogen.assets.flags", f"{v[0]}.png")
|
||||
country_code = KOKORO_LANG_TO_COUNTRY.get(v[0], v[0])
|
||||
flag_path = get_resource_path("abogen.assets.flags", f"{country_code}.png")
|
||||
if flag_path and os.path.exists(flag_path):
|
||||
icon = QIcon(flag_path)
|
||||
self.voice_combo.addItem(icon, f"{v}", v)
|
||||
|
||||
@@ -31,6 +31,7 @@ from abogen.constants import (
|
||||
VOICES_INTERNAL,
|
||||
SUPPORTED_LANGUAGES_FOR_SUBTITLE_GENERATION,
|
||||
LANGUAGE_DESCRIPTIONS,
|
||||
KOKORO_LANG_TO_COUNTRY,
|
||||
COLORS,
|
||||
)
|
||||
import re
|
||||
@@ -189,8 +190,9 @@ class VoiceMixer(QWidget):
|
||||
) # Center the icons horizontally
|
||||
|
||||
# Flag icon
|
||||
country_code = KOKORO_LANG_TO_COUNTRY.get(language_code, language_code)
|
||||
flag_icon_path = get_resource_path(
|
||||
"abogen.assets.flags", f"{language_code}.png"
|
||||
"abogen.assets.flags", f"{country_code}.png"
|
||||
)
|
||||
gender_icon_path = get_resource_path(
|
||||
"abogen.assets", "female.png" if is_female else "male.png"
|
||||
@@ -512,7 +514,8 @@ class VoiceFormulaDialog(QDialog):
|
||||
header_row.addWidget(QLabel("Language:"))
|
||||
self.language_combo = QComboBox()
|
||||
for code, desc in LANGUAGE_OPTIONS:
|
||||
flag = get_resource_path("abogen.assets.flags", f"{code}.png")
|
||||
country_code = KOKORO_LANG_TO_COUNTRY.get(code, code)
|
||||
flag = get_resource_path("abogen.assets.flags", f"{country_code}.png")
|
||||
if flag and os.path.exists(flag):
|
||||
self.language_combo.addItem(QIcon(flag), desc, code)
|
||||
else:
|
||||
|
||||