interactive preview window

This commit is contained in:
EliasVincent 2023-03-09 21:03:49 +01:00
parent 7a03d0bda3
commit 00359ba054

View File

@ -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])