mirror of
https://github.com/SevaSk/ecoute.git
synced 2024-12-24 23:06:39 +00:00
Fixing The delay in the freeze and unfreeze operation
This commit is contained in:
parent
540bfb1bf7
commit
162f3a6f7e
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ __pycache__/
|
|||||||
*.wav
|
*.wav
|
||||||
keys.py
|
keys.py
|
||||||
.venv/
|
.venv/
|
||||||
|
.DS_Store
|
||||||
|
15
main.py
15
main.py
@ -17,21 +17,18 @@ def write_in_textbox(textbox, text):
|
|||||||
def update_transcript_UI(transcriber, textbox):
|
def update_transcript_UI(transcriber, textbox):
|
||||||
transcript_string = transcriber.get_transcript()
|
transcript_string = transcriber.get_transcript()
|
||||||
write_in_textbox(textbox, transcript_string)
|
write_in_textbox(textbox, transcript_string)
|
||||||
textbox.after(300, update_transcript_UI, transcriber, textbox)
|
textbox.after(500, update_transcript_UI, transcriber, textbox)
|
||||||
|
|
||||||
def update_response_UI(responder, textbox, update_interval_slider_label, update_interval_slider, freeze_state):
|
def update_response_UI(responder, textbox, update_interval_slider_label, update_interval_slider, freeze_state):
|
||||||
if not freeze_state[0]:
|
if not freeze_state[0]:
|
||||||
response = responder.response
|
response = responder.response
|
||||||
|
|
||||||
textbox.configure(state="normal")
|
textbox.configure(state="normal")
|
||||||
write_in_textbox(textbox, response)
|
write_in_textbox(textbox, response)
|
||||||
textbox.configure(state="disabled")
|
textbox.configure(state="disabled")
|
||||||
|
|
||||||
update_interval = int(update_interval_slider.get())
|
update_interval = int(update_interval_slider.get())
|
||||||
responder.update_response_interval(update_interval)
|
responder.update_response_interval(update_interval)
|
||||||
update_interval_slider_label.configure(text=f"Update interval: {update_interval} seconds")
|
update_interval_slider_label.configure(text=f"Update interval: {update_interval} seconds")
|
||||||
|
textbox.after(500, update_response_UI, responder, textbox, update_interval_slider_label, update_interval_slider, freeze_state)
|
||||||
textbox.after(300, update_response_UI, responder, textbox, update_interval_slider_label, update_interval_slider, freeze_state)
|
|
||||||
|
|
||||||
def clear_context(transcriber, audio_queue):
|
def clear_context(transcriber, audio_queue):
|
||||||
transcriber.clear_transcript_data()
|
transcriber.clear_transcript_data()
|
||||||
@ -106,14 +103,14 @@ def main():
|
|||||||
root.grid_columnconfigure(0, weight=2)
|
root.grid_columnconfigure(0, weight=2)
|
||||||
root.grid_columnconfigure(1, weight=1)
|
root.grid_columnconfigure(1, weight=1)
|
||||||
|
|
||||||
# Add the clear transcript button to the UI
|
clear_transcript_button = ctk.CTkButton(root, text="Clear Transcript", command=lambda: clear_context(transcriber, audio_queue))
|
||||||
clear_transcript_button = ctk.CTkButton(root, text="Clear Transcript", command=lambda: clear_context(transcriber, audio_queue, ))
|
|
||||||
clear_transcript_button.grid(row=1, column=0, padx=10, pady=3, sticky="nsew")
|
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
|
freeze_state = [False]
|
||||||
def freeze_unfreeze():
|
def freeze_unfreeze():
|
||||||
freeze_state[0] = not freeze_state[0] # Invert the freeze state
|
freeze_state[0] = not freeze_state[0]
|
||||||
freeze_button.configure(text="Unfreeze" if freeze_state[0] else "Freeze")
|
freeze_button.configure(text="Unfreeze" if freeze_state[0] else "Freeze")
|
||||||
|
response_textbox.configure(state="normal" if freeze_state[0] else "disabled")
|
||||||
|
|
||||||
freeze_button.configure(command=freeze_unfreeze)
|
freeze_button.configure(command=freeze_unfreeze)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user