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

This commit is contained in:
2025-12-11 10:33:39 -08:00
parent f81474aea7
commit c4051d4db4

View File

@@ -3,6 +3,7 @@ from tkinter import ttk
from tkinter import filedialog from tkinter import filedialog
import atexit import atexit
import random import random
import time
# Start of Code - Start of Tkinter loop # Start of Code - Start of Tkinter loop
Root_Window = Tk() Root_Window = Tk()
@@ -157,11 +158,25 @@ def PiperTTS_GUI_Reverse_Text():
# #
def PiperTTS_GUI_Randomize_Text(): def PiperTTS_GUI_Randomize_Text():
try: try:
start_time = time.time()
TempText = Input_Box.get("1.0","end-1c") TempText = Input_Box.get("1.0","end-1c")
Input_Box.delete("1.0", "end-1c") Input_Box.delete("1.0", "end-1c")
TempList = list(TempText) TempList = list(TempText)
random.shuffle(TempList) random.shuffle(TempList)
Input_Box.insert("1.0", ''.join(TempList)) Input_Box.insert("1.0", ''.join(TempList))
end_time = time.time()
print(f'Elapsed Time: {end_time - start_time} seconds')
except:
print("An exception occurred - when Randomizing text.")
#
def PiperTTS_GUI_Randomize_Text_2nd():
try:
start_time = time.time()
TempText = Input_Box.get("1.0","end-1c")
Input_Box.delete("1.0", "end-1c")
Input_Box.insert("1.0", "".join(random.sample(mylist, len(mylist))))
end_time = time.time()
print(f'Elapsed Time: {end_time - start_time} seconds')
except: except:
print("An exception occurred - when Randomizing text.") print("An exception occurred - when Randomizing text.")
# #
@@ -241,10 +256,10 @@ C_Button_previous.grid(row=1, column=3)
C_Button_Next.grid(row=1, column=4) C_Button_Next.grid(row=1, column=4)
# Prefrences stuff # Prefrences stuff
GUI_Combobox_1_Label = Label(Prefrences_Frame, text="Language?", side = LEFT) GUI_Combobox_1_Label = Label(Prefrences_Frame, text="Language?")
GUI_Combobox_1 = ttk.Combobox(Prefrences_Frame, side = LEFT) GUI_Combobox_1 = ttk.Combobox(Prefrences_Frame)
GUI_Combobox_2_Label = Label(Prefrences_Frame, text="Voice?", side = LEFT) GUI_Combobox_2_Label = Label(Prefrences_Frame, text="Voice?")
GUI_Combobox_2 = ttk.Combobox(Prefrences_Frame, side = LEFT) GUI_Combobox_2 = ttk.Combobox(Prefrences_Frame)
GUI_Spinbox_1_Label = Label(Prefrences_Frame, text="volume?") GUI_Spinbox_1_Label = Label(Prefrences_Frame, text="volume?")
GUI_Spinbox_1 = ttk.Spinbox(Prefrences_Frame, from_ = 1, to = 100) GUI_Spinbox_1 = ttk.Spinbox(Prefrences_Frame, from_ = 1, to = 100)
GUI_Spinbox_2_Label = Label(Prefrences_Frame, text="length_scale?") GUI_Spinbox_2_Label = Label(Prefrences_Frame, text="length_scale?")
@@ -255,10 +270,10 @@ GUI_Spinbox_4_Label = Label(Prefrences_Frame, text="noise_w_scale?")
GUI_Spinbox_4 = ttk.Spinbox(Prefrences_Frame, from_ = 1.0, to = 2.0) GUI_Spinbox_4 = ttk.Spinbox(Prefrences_Frame, from_ = 1.0, to = 2.0)
GUI_Checkbutton_1 = ttk.Checkbutton(Prefrences_Frame, text="normalize_audio?") GUI_Checkbutton_1 = ttk.Checkbutton(Prefrences_Frame, text="normalize_audio?")
# Prefrences placement # Prefrences placement
GUI_Combobox_1_Label.pack() GUI_Combobox_1_Label.pack(side = LEFT)
GUI_Combobox_1.pack() GUI_Combobox_1.pack(side = LEFT)
GUI_Combobox_2_Label.pack() GUI_Combobox_2_Label.pack(side = LEFT)
GUI_Combobox_2.pack() GUI_Combobox_2.pack(side = LEFT)
GUI_Spinbox_1_Label.pack() GUI_Spinbox_1_Label.pack()
GUI_Spinbox_1.pack() GUI_Spinbox_1.pack()
GUI_Spinbox_2_Label.pack() GUI_Spinbox_2_Label.pack()
@@ -295,6 +310,7 @@ Tools_Toolbar.add_command(label="Insert Selection", command=PiperTTS_GUI_Get_Sel
Tools_Toolbar.add_command(label="Insert Clipboard", command=PiperTTS_GUI_Get_Clipboard) Tools_Toolbar.add_command(label="Insert Clipboard", command=PiperTTS_GUI_Get_Clipboard)
Tools_Toolbar.add_separator() Tools_Toolbar.add_separator()
Tools_Toolbar.add_command(label="Randomize Text", command=PiperTTS_GUI_Randomize_Text) Tools_Toolbar.add_command(label="Randomize Text", command=PiperTTS_GUI_Randomize_Text)
Tools_Toolbar.add_command(label="Randomize Text 2nd", command=PiperTTS_GUI_Randomize_Text_2nd)
Tools_Toolbar.add_command(label="Reverse Text", command=PiperTTS_GUI_Reverse_Text) Tools_Toolbar.add_command(label="Reverse Text", command=PiperTTS_GUI_Reverse_Text)
Tools_Toolbar.add_separator() Tools_Toolbar.add_separator()
Tools_Toolbar.add_command(label="Prefrences", command=PiperTTS_GUI_Set_Prefrences) Tools_Toolbar.add_command(label="Prefrences", command=PiperTTS_GUI_Set_Prefrences)