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

Small Exception updates
This commit is contained in:
2025-12-27 06:10:07 -08:00
parent c9fd55b027
commit 36c1b1fb6e

View File

@@ -31,10 +31,13 @@ style.configure("My.TLabel", foreground="white", background="#404040")
try: try:
with open("voices/voices.json","r") as file: with open("voices/voices.json","r") as file:
data = json.load(file) data = json.load(file)
print("Loop!")
# Failed at loading voices.json # Failed at loading voices.json
except FileNotFoundError: except FileNotFoundError:
print("Error: The file 'voises.json' was not found.") print("Exception: The file 'voices/voices.json' was not found.")
except Exception as e:
print(f"An Exception has occurred - when attempting to load - 'voices/voices.json'\nException: {e}\nClass: {type(e)}")
else:
print("The file 'voices/voices.json' was loaded successfully!")
# Create a list for Languages # Create a list for Languages
mylist = ["Languages"] mylist = ["Languages"]
@@ -60,20 +63,17 @@ mylist_String_Three = StringVar(value = "Quality")
try: try:
Input_Box_Frame = ttk.Frame(Root_Window) Input_Box_Frame = ttk.Frame(Root_Window)
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when creating input Frame.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when creating input Frame.")
# Attempts to create a Controls Frame # Attempts to create a Controls Frame
try: try:
Controls_Box_Frame = ttk.Frame(Root_Window, style="My.TLabel") Controls_Box_Frame = ttk.Frame(Root_Window, style="My.TLabel")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when creating Controls Frame.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when creating Controls Frame.")
# Attempts to create a Prefrences Frame # Attempts to create a Prefrences Frame
try: try:
Prefrences_Frame = ttk.Frame(Root_Window) Prefrences_Frame = ttk.Frame(Root_Window)
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when creating Prefrence Frame.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when creating Controls Frame.")
# Attempts to Place Input and Controls frames # Attempts to Place Input and Controls frames
try: try:
#Input_Box_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 0.7) #Input_Box_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 0.7)
@@ -81,8 +81,7 @@ try:
Input_Box_Frame.pack(fill = "both", expand = True, anchor = "center") Input_Box_Frame.pack(fill = "both", expand = True, anchor = "center")
Controls_Box_Frame.pack(expand = True, anchor = "center") Controls_Box_Frame.pack(expand = True, anchor = "center")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when placing Frames.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when placing Frames.")
# Attempts to create a Input box # Attempts to create a Input box
try: try:
@@ -90,8 +89,7 @@ try:
#Input_Box.pack(padx=5, pady=5, expand = True, fill = "both") #Input_Box.pack(padx=5, pady=5, expand = True, fill = "both")
Input_Box.pack(side = "left", padx=5, pady=5, expand = True, fill = "both") Input_Box.pack(side = "left", padx=5, pady=5, expand = True, fill = "both")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when creating input box.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when creating input box.")
# Attempts to create a scrollbar for the Input box # Attempts to create a scrollbar for the Input box
try: try:
@@ -101,8 +99,7 @@ try:
Main_Text_Scrollbar.pack(side = "left", fill = "y") Main_Text_Scrollbar.pack(side = "left", fill = "y")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when creating a scroll bar.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when creating a scroll bar.")
# #
def PiperTTS_GUI_Play(): def PiperTTS_GUI_Play():
@@ -111,8 +108,7 @@ def PiperTTS_GUI_Play():
C_Button_Pause["state"] == "normal" C_Button_Pause["state"] == "normal"
C_Button_Play["state"] = "disabled" C_Button_Play["state"] = "disabled"
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when pressing Play Button.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when pressing Play Button.")
# #
def PiperTTS_GUI_Pause(): def PiperTTS_GUI_Pause():
@@ -121,8 +117,7 @@ def PiperTTS_GUI_Pause():
C_Button_Pause["state"] == "disabled" C_Button_Pause["state"] == "disabled"
C_Button_Play["state"] = "normal" C_Button_Play["state"] = "normal"
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when pressing Pause Button.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when pressing Pause Button.")
# #
def PiperTTS_GUI_Stop(): def PiperTTS_GUI_Stop():
@@ -131,24 +126,21 @@ def PiperTTS_GUI_Stop():
C_Button_Pause["state"] == "disabled" C_Button_Pause["state"] == "disabled"
C_Button_Play["state"] = "normal" C_Button_Play["state"] = "normal"
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when pressing Stop Button.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when pressing Stop Button.")
# #
def PiperTTS_GUI_Previous(): def PiperTTS_GUI_Previous():
try: try:
My_Test_Label["text"] = "Previous?" My_Test_Label["text"] = "Previous?"
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when pressing Previous Button.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when pressing Previous Button.")
# #
def PiperTTS_GUI_Next(): def PiperTTS_GUI_Next():
try: try:
My_Test_Label["text"] = "Next?" My_Test_Label["text"] = "Next?"
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when pressing Next Button.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when pressing Next Button.")
# #
def PiperTTS_GUI_New_File(): def PiperTTS_GUI_New_File():
@@ -156,8 +148,7 @@ def PiperTTS_GUI_New_File():
My_Test_Label["text"] = "New File?" My_Test_Label["text"] = "New File?"
Input_Box.delete("1.0", "end-1c") Input_Box.delete("1.0", "end-1c")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when pressing New File Button.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when pressing New File Button.")
# #
def PiperTTS_GUI_Get_Selection(): def PiperTTS_GUI_Get_Selection():
@@ -169,8 +160,7 @@ def PiperTTS_GUI_Get_Selection():
Cursor_Position = Input_Box.index(INSERT) Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert(Cursor_Position, Selected) Input_Box.insert(Cursor_Position, Selected)
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when grabbing Selection.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when grabbing Selection.")
# #
def PiperTTS_GUI_Get_Clipboard(): def PiperTTS_GUI_Get_Clipboard():
@@ -182,8 +172,7 @@ def PiperTTS_GUI_Get_Clipboard():
Cursor_Position = Input_Box.index(INSERT) Cursor_Position = Input_Box.index(INSERT)
Input_Box.insert(Cursor_Position, Selected) Input_Box.insert(Cursor_Position, Selected)
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when grabbing Clipboard.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when grabbing Clipboard.")
# #
def PiperTTS_GUI_TextFile_Open(): def PiperTTS_GUI_TextFile_Open():
try: try:
@@ -199,8 +188,7 @@ def PiperTTS_GUI_TextFile_Open():
else: else:
print("Canceled file dialog.") print("Canceled file dialog.")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when Opening Text File.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when Opening Text File.")
# #
def PiperTTS_GUI_Reverse_Text(): def PiperTTS_GUI_Reverse_Text():
try: try:
@@ -208,8 +196,7 @@ def PiperTTS_GUI_Reverse_Text():
Input_Box.delete("1.0", "end-1c") Input_Box.delete("1.0", "end-1c")
Input_Box.insert("1.0", TempText[::-1]) Input_Box.insert("1.0", TempText[::-1])
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when reversing text.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when reversing text.")
# #
def PiperTTS_GUI_Randomize_Text(): def PiperTTS_GUI_Randomize_Text():
try: try:
@@ -222,8 +209,7 @@ def PiperTTS_GUI_Randomize_Text():
end_time = time.time() end_time = time.time()
print(f'Elapsed Time: {end_time - start_time} seconds') print(f'Elapsed Time: {end_time - start_time} seconds')
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when Randomizing text.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when Randomizing text.")
# #
def PiperTTS_GUI_Randomize_Text_2nd(): def PiperTTS_GUI_Randomize_Text_2nd():
try: try:
@@ -234,8 +220,7 @@ def PiperTTS_GUI_Randomize_Text_2nd():
end_time = time.time() end_time = time.time()
print(f'Elapsed Time: {end_time - start_time} seconds') print(f'Elapsed Time: {end_time - start_time} seconds')
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when Randomizing text.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when Randomizing text.")
# #
def PiperTTS_GUI_Set_Prefrences(): def PiperTTS_GUI_Set_Prefrences():
try: try:
@@ -244,7 +229,7 @@ def PiperTTS_GUI_Set_Prefrences():
Input_Box_Frame.pack(fill = "both", expand = True) Input_Box_Frame.pack(fill = "both", expand = True)
Controls_Box_Frame.pack(fill = "both") Controls_Box_Frame.pack(fill = "both")
print("An if occurred - when Setting prefrences.") print("An if occurred - when Setting prefrences.")
print(f"{Prefrences_Frame.winfo_ismapped()}") print(f"Is Mapped: {Prefrences_Frame.winfo_ismapped()}")
else: else:
#Input_Box_Frame.place_forget() #Input_Box_Frame.place_forget()
#Controls_Box_Frame.place_forget() #Controls_Box_Frame.place_forget()
@@ -253,10 +238,9 @@ def PiperTTS_GUI_Set_Prefrences():
#Prefrences_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 1) #Prefrences_Frame.place(x = 0, y = 0, relwidth = 1, relheight = 1)
Prefrences_Frame.pack(fill = "both", expand = True) Prefrences_Frame.pack(fill = "both", expand = True)
print("An if occurred - when Setting prefrences.") print("An if occurred - when Setting prefrences.")
print(f"{Prefrences_Frame.winfo_ismapped()}") print(f"Is Mapped: {Prefrences_Frame.winfo_ismapped()}")
except Exception as e: except Exception as e:
print(e, type(e)) print(f"An exception occurred - when Setting prefrences.\nException: {e}\nClass: {type(e)}")
print("An exception occurred - when Setting prefrences.")
# #
def Select_Voice_For_Language(Mylanguages): def Select_Voice_For_Language(Mylanguages):