From 00359ba054797d5115c30a292f0f919c514f0046 Mon Sep 17 00:00:00 2001 From: EliasVincent Date: Thu, 9 Mar 2023 21:03:49 +0100 Subject: [PATCH] interactive preview window --- extensions/whisper_stt/script.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/extensions/whisper_stt/script.py b/extensions/whisper_stt/script.py index dcb4dfc9..9f07e5c9 100644 --- a/extensions/whisper_stt/script.py +++ b/extensions/whisper_stt/script.py @@ -1,17 +1,12 @@ import gradio as gr import speech_recognition as sr - input_hijack = { 'state': False, 'value': ["", ""] } -def input_modifier(string): - return string - - def do_stt(): transcription = "" r = sr.Recognizer() @@ -30,7 +25,13 @@ def do_stt(): return transcription +def update_hijack(val): + input_hijack.update({"state": True, "value": [val, val]}) + return val + + def ui(): speech_button = gr.Button(value="🎙️") - output_transcription = gr.Textbox(label="STT-Preview", placeholder="Speech Preview. Click \"Generate\" to send") + output_transcription = gr.Textbox(label="STT-Input", placeholder="Speech Preview. Click \"Generate\" to send", interactive=True) + output_transcription.change(fn=update_hijack, inputs=[output_transcription]) speech_button.click(do_stt, outputs=[output_transcription])