Rahuluni commited on
Commit
40b8c7a
·
1 Parent(s): 822cbeb

app error fixed

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -12,7 +12,7 @@ from transformers import pipeline
12
  # The model "openai/whisper-small" is public and works on CPU (smaller memory footprint).
13
  # Loading may take a few seconds at startup.
14
  ASR_MODEL = "openai/whisper-small"
15
- asr = pipeline("automatic-speech-recognition", model=ASR_MODEL, chunk_length_s=30)
16
 
17
  def save_audio_to_wav(audio, sr):
18
  """
@@ -76,8 +76,9 @@ with gr.Blocks(title="Whisper Tiny Speech-to-Text (Free on HF Spaces)") as demo:
76
 
77
  with gr.Row():
78
  with gr.Column(scale=1):
79
- audio_input = gr.Audio(source="microphone", type="numpy", label="Record or upload audio")
80
- upload_input = gr.Audio(source="upload", type="numpy", label="Or upload an audio file")
 
81
  transcribe_btn = gr.Button("Transcribe")
82
  clear_btn = gr.Button("Clear")
83
  with gr.Column(scale=1):
@@ -108,10 +109,9 @@ with gr.Blocks(title="Whisper Tiny Speech-to-Text (Free on HF Spaces)") as demo:
108
 
109
  # Copy transcript to clipboard (Gradio has `copy` action for buttons)
110
  copy_btn.click(
111
- fn=lambda txt: txt,
112
- inputs=transcript,
113
- outputs=gr.Textbox(visible=False),
114
- _js="(x) => { navigator.clipboard.writeText(x); return x; }" # copies to clipboard in browser
115
  )
116
 
117
  gr.Markdown(
@@ -120,4 +120,4 @@ with gr.Blocks(title="Whisper Tiny Speech-to-Text (Free on HF Spaces)") as demo:
120
  )
121
 
122
  if __name__ == "__main__":
123
- demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
 
12
  # The model "openai/whisper-small" is public and works on CPU (smaller memory footprint).
13
  # Loading may take a few seconds at startup.
14
  ASR_MODEL = "openai/whisper-small"
15
+ asr = pipeline("automatic-speech-recognition", model=ASR_MODEL, chunk_length_s=30, ignore_warning=True)
16
 
17
  def save_audio_to_wav(audio, sr):
18
  """
 
76
 
77
  with gr.Row():
78
  with gr.Column(scale=1):
79
+ audio_input = gr.Audio(type="numpy", label="Record or upload audio")
80
+ upload_input = gr.Audio(type="numpy", label="Or upload an audio file")
81
+
82
  transcribe_btn = gr.Button("Transcribe")
83
  clear_btn = gr.Button("Clear")
84
  with gr.Column(scale=1):
 
109
 
110
  # Copy transcript to clipboard (Gradio has `copy` action for buttons)
111
  copy_btn.click(
112
+ fn=lambda txt: txt,
113
+ inputs=transcript,
114
+ outputs=None
 
115
  )
116
 
117
  gr.Markdown(
 
120
  )
121
 
122
  if __name__ == "__main__":
123
+ demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)), share=True)