Skip to content

Commit 7a03d0b

Browse files
committed
cleanup
1 parent 4c72e43 commit 7a03d0b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

extensions/whisper_stt/script.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import gradio as gr
22
import speech_recognition as sr
3-
import modules.shared as shared
3+
44

55
input_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

3733
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")
4036
speech_button.click(do_stt, outputs=[output_transcription])

0 commit comments

Comments
 (0)