Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import whisper
|
3 |
+
|
4 |
+
# Load the Whisper model
|
5 |
+
model = whisper.load_model("base")
|
6 |
+
|
7 |
+
def transcribe_audio(audio):
|
8 |
+
"""
|
9 |
+
This function takes in an audio file and returns its transcription.
|
10 |
+
"""
|
11 |
+
# Transcribe the audio using Whisper
|
12 |
+
result = model.transcribe(audio)
|
13 |
+
return result['text']
|
14 |
+
|
15 |
+
# Create the Gradio interface for real-time transcription
|
16 |
+
interface = gr.Interface(
|
17 |
+
fn=transcribe_audio, # Function to process the audio input
|
18 |
+
inputs=gr.Audio(source="microphone", type="filepath"), # Real-time audio input from the microphone
|
19 |
+
outputs="text", # Display the transcription as text
|
20 |
+
live=True # Enables real-time transcription
|
21 |
+
)
|
22 |
+
|
23 |
+
# Launch the Gradio interface
|
24 |
+
interface.launch(share=True)
|