Skip to content

Commit 02e1113

Browse files
committed
add auto-transcribe option
1 parent 48aa528 commit 02e1113

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

extensions/whisper_stt/script.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@ def update_hijack(val):
3232
return val
3333

3434

35+
def auto_transcribe(audio, audio_auto, text_state=""):
36+
if audio is None:
37+
return "", ""
38+
if audio_auto:
39+
return do_stt(audio, text_state)
40+
return "", ""
41+
42+
3543
def ui():
3644
tr_state = gr.State(value="")
3745
output_transcription = gr.Textbox(label="STT-Input",
3846
placeholder="Speech Preview. Click \"Generate\" to send",
3947
interactive=True)
4048
output_transcription.change(fn=update_hijack, inputs=[output_transcription], outputs=[tr_state])
49+
audio_auto = gr.Checkbox(label="Auto-Transcribe", value=True)
4150
with gr.Row():
4251
audio = gr.Audio(source="microphone")
52+
audio.change(fn=auto_transcribe, inputs=[audio, audio_auto, tr_state], outputs=[output_transcription, tr_state])
4353
transcribe_button = gr.Button(value="Transcribe")
4454
transcribe_button.click(do_stt, inputs=[audio, tr_state], outputs=[output_transcription, tr_state])

0 commit comments

Comments
 (0)