Update Uptated-Prototype/PiperTTS-GUI-Test.py

This commit is contained in:
2025-12-13 15:04:58 -08:00
parent cb54d3b8d9
commit fbdd42c75f

View File

@@ -34,13 +34,17 @@ except FileNotFoundError:
# Create a list for Languages # Create a list for Languages
mylist = ["Languages"] mylist = ["Languages"]
mylist_code = ["Languages"]
# Appends and formats all the languages to the list # Appends and formats all the languages to the list
for voice_id, info in data.items(): for voice_id, info in data.items():
mylist.append(f"{info["language"]["name_native"]} ({info["language"]["name_english"]}, {info["language"]["country_english"]})") mylist.append(f"{info["language"]["name_native"]} ({info["language"]["name_english"]}, {info["language"]["country_english"]})")
mylist_code.append(f"{info["language"]["code"]}")
# Removes duplicate languages choices from list # Removes duplicate languages choices from list
mylist = list(dict.fromkeys(mylist)) mylist = list(dict.fromkeys(mylist))
mylist_code = list(dict.fromkeys(mylist_code))
mylist_String = StringVar(value = "Languages") mylist_String = StringVar(value = "Languages")
# Attempts to create a Input Frame # Attempts to create a Input Frame
@@ -230,9 +234,10 @@ def PiperTTS_GUI_Set_Prefrences():
# #
def Select_Voice_For_Language(Mylanguages): def Select_Voice_For_Language(Mylanguages):
x = mylist.index(Mylanguages)
mylist2 = [] mylist2 = []
for voice_id, info in data.items(): for voice_id, info in data.items():
if info["language"]["name_native"] == Mylanguages: if info["language"]["name_native"] == mylist_code[x]:
mylist2.append(f"{info["name"]}") mylist2.append(f"{info["name"]}")
mylist2 = list(dict.fromkeys(mylist2)) mylist2 = list(dict.fromkeys(mylist2))
@@ -332,7 +337,7 @@ GUI_Combobox_1 = ttk.Combobox(Prefrences_Frame, textvariable = mylist_String)
# #
GUI_Combobox_1["values"] = mylist GUI_Combobox_1["values"] = mylist
#GUI_Combobox_1.bind("<<ComboboxSelected>>", lambda event: print(mylist_String.get().split(" ", 1)[0])) #GUI_Combobox_1.bind("<<ComboboxSelected>>", lambda event: print(mylist_String.get().split(" ", 1)[0]))
GUI_Combobox_1.bind("<<ComboboxSelected>>", lambda event: Select_Voice_For_Language(mylist_String.get().split(" ", 1)[0])) GUI_Combobox_1.bind("<<ComboboxSelected>>", lambda event: Select_Voice_For_Language(mylist_String.get()))
# #
GUI_Combobox_2_Label = Label(Prefrences_Frame, text="Voice?") GUI_Combobox_2_Label = Label(Prefrences_Frame, text="Voice?")