File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change 11import gradio as gr
22import speech_recognition as sr
3- import modules . shared as shared
3+
44
55input_hijack = {
66 'state' : False ,
@@ -16,25 +16,21 @@ def do_stt():
1616 transcription = ""
1717 r = sr .Recognizer ()
1818 with sr .Microphone () as source :
19- print ("Say something!" )
2019 r .adjust_for_ambient_noise (source )
2120 audio = r .listen (source )
2221
23- # recognize speech using whisper
2422 try :
2523 transcription = r .recognize_whisper (audio , language = "english" , model = "tiny.en" )
26- print ("Whisper thinks you said " + transcription )
2724 except sr .UnknownValueError :
2825 print ("Whisper could not understand audio" )
2926 except sr .RequestError as e :
30- print ("Could not request results from Whisper" )
27+ print ("Could not request results from Whisper" , e )
3128
32- # input_modifier(transcription)
3329 input_hijack .update ({"state" : True , "value" : [transcription , transcription ]})
3430 return transcription
3531
3632
3733def ui ():
38- speech_button = gr .Button (value = "STT " )
39- output_transcription = gr .Textbox (label = "Speech Preview" )
34+ speech_button = gr .Button (value = "🎙️ " )
35+ output_transcription = gr .Textbox (label = "STT-Preview" , placeholder = " Speech Preview. Click \" Generate \" to send " )
4036 speech_button .click (do_stt , outputs = [output_transcription ])
You can’t perform that action at this time.
0 commit comments