Skip to content

Commit 00359ba

Browse files
committed
interactive preview window
1 parent 7a03d0b commit 00359ba

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

extensions/whisper_stt/script.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
import gradio as gr
22
import speech_recognition as sr
33

4-
54
input_hijack = {
65
'state': False,
76
'value': ["", ""]
87
}
98

109

11-
def input_modifier(string):
12-
return string
13-
14-
1510
def do_stt():
1611
transcription = ""
1712
r = sr.Recognizer()
@@ -30,7 +25,13 @@ def do_stt():
3025
return transcription
3126

3227

28+
def update_hijack(val):
29+
input_hijack.update({"state": True, "value": [val, val]})
30+
return val
31+
32+
3333
def ui():
3434
speech_button = gr.Button(value="🎙️")
35-
output_transcription = gr.Textbox(label="STT-Preview", placeholder="Speech Preview. Click \"Generate\" to send")
35+
output_transcription = gr.Textbox(label="STT-Input", placeholder="Speech Preview. Click \"Generate\" to send", interactive=True)
36+
output_transcription.change(fn=update_hijack, inputs=[output_transcription])
3637
speech_button.click(do_stt, outputs=[output_transcription])

0 commit comments

Comments
 (0)