Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import whisper
|
| 3 |
+
|
| 4 |
+
# Load the Whisper model (you can change to "base", "small", "medium", etc.)
|
| 5 |
+
model = whisper.load_model("base")
|
| 6 |
+
|
| 7 |
+
# Function to process the audio file and transcribe
|
| 8 |
+
def transcribe_audio(audio):
|
| 9 |
+
# Transcribe the audio using Whisper
|
| 10 |
+
result = model.transcribe(audio)
|
| 11 |
+
return result['text']
|
| 12 |
+
|
| 13 |
+
# Create a Gradio interface for audio transcription
|
| 14 |
+
iface = gr.Interface(
|
| 15 |
+
fn=transcribe_audio, # The function that will process the audio
|
| 16 |
+
inputs=gr.Audio(source="upload", type="filepath"), # Upload audio input
|
| 17 |
+
outputs="text", # Output transcription as text
|
| 18 |
+
title="Whisper Audio Transcription", # Title of the interface
|
| 19 |
+
description="Upload an audio file and get the transcription using OpenAI's Whisper model." # Description
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# Launch the interface
|
| 23 |
+
iface.launch()
|