hbchiu commited on
Commit
7139c0d
·
verified ·
1 Parent(s): 5451dd0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load ASR model
5
+ transcriber = pipeline(
6
+ "automatic-speech-recognition",
7
+ model="openai/whisper-base"
8
+ )
9
+
10
+ # Transcription function
11
+ def transcribe_audio(audio):
12
+ if audio is None:
13
+ return "No audio recorded. Please record something."
14
+
15
+ result = transcriber(audio)
16
+ return result["text"]
17
+
18
+ # Create interface
19
+ interface = gr.Interface(
20
+ fn=transcribe_audio,
21
+ inputs=gr.Audio(sources=["microphone"], type="filepath"),
22
+ outputs=gr.Textbox(label="Transcription"),
23
+ title="Automatic Speech Recognition",
24
+ description="Click the microphone icon, speak, then click stop. Your speech will be transcribed."
25
+ )
26
+
27
+ # Launch
28
+ interface.launch()