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 1
1
import gradio as gr
2
2
import speech_recognition as sr
3
- import modules . shared as shared
3
+
4
4
5
5
input_hijack = {
6
6
'state' : False ,
@@ -16,25 +16,21 @@ def do_stt():
16
16
transcription = ""
17
17
r = sr .Recognizer ()
18
18
with sr .Microphone () as source :
19
- print ("Say something!" )
20
19
r .adjust_for_ambient_noise (source )
21
20
audio = r .listen (source )
22
21
23
- # recognize speech using whisper
24
22
try :
25
23
transcription = r .recognize_whisper (audio , language = "english" , model = "tiny.en" )
26
- print ("Whisper thinks you said " + transcription )
27
24
except sr .UnknownValueError :
28
25
print ("Whisper could not understand audio" )
29
26
except sr .RequestError as e :
30
- print ("Could not request results from Whisper" )
27
+ print ("Could not request results from Whisper" , e )
31
28
32
- # input_modifier(transcription)
33
29
input_hijack .update ({"state" : True , "value" : [transcription , transcription ]})
34
30
return transcription
35
31
36
32
37
33
def 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 " )
40
36
speech_button .click (do_stt , outputs = [output_transcription ])
You can’t perform that action at this time.
0 commit comments