mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-11-25 17:29:22 +01:00
add auto-transcribe option
This commit is contained in:
parent
48aa52849b
commit
02e1113d95
@ -32,13 +32,23 @@ def update_hijack(val):
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
def auto_transcribe(audio, audio_auto, text_state=""):
|
||||||
|
if audio is None:
|
||||||
|
return "", ""
|
||||||
|
if audio_auto:
|
||||||
|
return do_stt(audio, text_state)
|
||||||
|
return "", ""
|
||||||
|
|
||||||
|
|
||||||
def ui():
|
def ui():
|
||||||
tr_state = gr.State(value="")
|
tr_state = gr.State(value="")
|
||||||
output_transcription = gr.Textbox(label="STT-Input",
|
output_transcription = gr.Textbox(label="STT-Input",
|
||||||
placeholder="Speech Preview. Click \"Generate\" to send",
|
placeholder="Speech Preview. Click \"Generate\" to send",
|
||||||
interactive=True)
|
interactive=True)
|
||||||
output_transcription.change(fn=update_hijack, inputs=[output_transcription], outputs=[tr_state])
|
output_transcription.change(fn=update_hijack, inputs=[output_transcription], outputs=[tr_state])
|
||||||
|
audio_auto = gr.Checkbox(label="Auto-Transcribe", value=True)
|
||||||
with gr.Row():
|
with gr.Row():
|
||||||
audio = gr.Audio(source="microphone")
|
audio = gr.Audio(source="microphone")
|
||||||
|
audio.change(fn=auto_transcribe, inputs=[audio, audio_auto, tr_state], outputs=[output_transcription, tr_state])
|
||||||
transcribe_button = gr.Button(value="Transcribe")
|
transcribe_button = gr.Button(value="Transcribe")
|
||||||
transcribe_button.click(do_stt, inputs=[audio, tr_state], outputs=[output_transcription, tr_state])
|
transcribe_button.click(do_stt, inputs=[audio, tr_state], outputs=[output_transcription, tr_state])
|
||||||
|
Loading…
Reference in New Issue
Block a user