dtkne commited on
Commit
5d6bc67
·
verified ·
1 Parent(s): 79348af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1,13 +1,21 @@
1
  import gradio as gr
 
2
  from transformers import pipeline
 
 
3
  asr = pipeline(task="automatic-speech-recognition",
4
  model="distil-whisper/distil-small.en")
5
- def launch(input):
6
- out = asr.input
7
- return out[0]['text']
8
 
9
- iface = gr.Interface(launch,
10
- inputs=gr.Image(type='pil'),
 
 
 
 
 
 
11
  outputs="text")
 
 
12
  iface.launch(share=True,
13
- server_port=int(os.environ['PORT1']))
 
1
  import gradio as gr
2
+ import os
3
  from transformers import pipeline
4
+
5
+ # Load ASR pipeline
6
  asr = pipeline(task="automatic-speech-recognition",
7
  model="distil-whisper/distil-small.en")
 
 
 
8
 
9
+ # Define function
10
+ def transcribe(audio):
11
+ out = asr(audio)
12
+ return out['text'] # Extract transcribed text
13
+
14
+ # Create Gradio Interface
15
+ iface = gr.Interface(fn=transcribe,
16
+ inputs=gr.Audio(type="filepath"), # Expect an audio file path
17
  outputs="text")
18
+
19
+ # Launch Interface
20
  iface.launch(share=True,
21
+ server_port=int(os.environ['PORT1']))