mirror of
https://github.com/SevaSk/ecoute.git
synced 2025-01-18 18:56:24 +00:00
added freeze/unfreeze for response
This commit is contained in:
parent
e0caf957e5
commit
02209898cb
35
main.py
35
main.py
@ -15,18 +15,19 @@ def update_transcript_UI(transcriber, textbox):
|
||||
write_in_textbox(textbox, transcript_string)
|
||||
textbox.after(300, update_transcript_UI, transcriber, textbox)
|
||||
|
||||
def update_response_UI(responder, textbox, update_interval_slider_label, update_interval_slider):
|
||||
response = responder.response
|
||||
def update_response_UI(responder, textbox, update_interval_slider_label, update_interval_slider, freeze_state):
|
||||
if not freeze_state[0]:
|
||||
response = responder.response
|
||||
|
||||
textbox.configure(state="normal")
|
||||
write_in_textbox(textbox, response)
|
||||
textbox.configure(state="disabled")
|
||||
textbox.configure(state="normal")
|
||||
write_in_textbox(textbox, response)
|
||||
textbox.configure(state="disabled")
|
||||
|
||||
update_interval = int(update_interval_slider.get())
|
||||
responder.update_response_interval(update_interval)
|
||||
update_interval_slider_label.configure(text=f"Update interval: {update_interval} seconds")
|
||||
update_interval = int(update_interval_slider.get())
|
||||
responder.update_response_interval(update_interval)
|
||||
update_interval_slider_label.configure(text=f"Update interval: {update_interval} seconds")
|
||||
|
||||
textbox.after(300, update_response_UI, responder, textbox, update_interval_slider_label, update_interval_slider)
|
||||
textbox.after(300, update_response_UI, responder, textbox, update_interval_slider_label, update_interval_slider, freeze_state)
|
||||
|
||||
def clear_context(transcriber, audio_queue):
|
||||
transcriber.clear_transcript_data()
|
||||
@ -58,11 +59,14 @@ def create_ui_components(root):
|
||||
update_interval_slider_label = ctk.CTkLabel(root, text=f"Update interval: {update_interval_slider.get()} seconds", font=("Arial", 12), text_color="#FFFCF2")
|
||||
update_interval_slider_label.grid(row=2, column=1, padx=10, pady=10, sticky="nsew")
|
||||
|
||||
return transcript_textbox, response_textbox, update_interval_slider, update_interval_slider_label
|
||||
freeze_button = ctk.CTkButton(root, text="Freeze", command=None)
|
||||
freeze_button.grid(row=4, column=1, padx=10, pady=3, sticky="nsew")
|
||||
|
||||
return transcript_textbox, response_textbox, update_interval_slider, update_interval_slider_label, freeze_button
|
||||
|
||||
def main():
|
||||
root = ctk.CTk()
|
||||
transcript_textbox, response_textbox, update_interval_slider, update_interval_slider_label = create_ui_components(root)
|
||||
transcript_textbox, response_textbox, update_interval_slider, update_interval_slider_label, freeze_button = create_ui_components(root)
|
||||
|
||||
audio_queue = queue.Queue()
|
||||
|
||||
@ -96,8 +100,15 @@ def main():
|
||||
clear_transcript_button = ctk.CTkButton(root, text="Clear Transcript", command=lambda: clear_context(global_transcriber, audio_queue, ))
|
||||
clear_transcript_button.grid(row=1, column=0, padx=10, pady=3, sticky="nsew")
|
||||
|
||||
freeze_state = [False] # Using list to be able to change its content inside inner functions
|
||||
def freeze_unfreeze():
|
||||
freeze_state[0] = not freeze_state[0] # Invert the freeze state
|
||||
freeze_button.configure(text="Unfreeze" if freeze_state[0] else "Freeze")
|
||||
|
||||
freeze_button.configure(command=freeze_unfreeze)
|
||||
|
||||
update_transcript_UI(global_transcriber, transcript_textbox)
|
||||
update_response_UI(responder, response_textbox, update_interval_slider_label, update_interval_slider)
|
||||
update_response_UI(responder, response_textbox, update_interval_slider_label, update_interval_slider, freeze_state)
|
||||
|
||||
root.mainloop()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user