mindspark121 commited on
Commit
fb41c74
·
verified ·
1 Parent(s): a553298

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -6,14 +6,17 @@ model = whisper.load_model("small") # Change to "base", "medium", or "large" if
6
 
7
  def transcribe(audio):
8
  """Transcribe Speech to Text"""
 
 
 
9
  result = model.transcribe(audio)
10
  return result["text"]
11
 
12
- # Gradio UI with Microphone
13
  gr.Interface(
14
  fn=transcribe,
15
- inputs=gr.Audio(source="microphone", type="filepath"),
16
  outputs="text",
17
  title="Whisper Speech-to-Text",
18
- description="Speak into the microphone and get text output.",
19
  ).launch()
 
6
 
7
  def transcribe(audio):
8
  """Transcribe Speech to Text"""
9
+ if audio is None:
10
+ return "No audio detected. Please try again."
11
+
12
  result = model.transcribe(audio)
13
  return result["text"]
14
 
15
+ # Corrected Gradio UI
16
  gr.Interface(
17
  fn=transcribe,
18
+ inputs=gr.Audio(sources=["microphone"], type="filepath"),
19
  outputs="text",
20
  title="Whisper Speech-to-Text",
21
+ description="Click 'Record', speak into the microphone, then stop recording to get text output.",
22
  ).launch()