Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,27 +1,26 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
demo.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the whisper-large-v3 model from Hugging Face on CPU
|
| 5 |
+
transcriber = pipeline(
|
| 6 |
+
"automatic-speech-recognition",
|
| 7 |
+
model="openai/whisper-large-v3",
|
| 8 |
+
device=-1 # Ensures the model runs on the CPU
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
def transcribe_audio(audio_file):
|
| 12 |
+
# Transcribe the audio file
|
| 13 |
+
transcription = transcriber(audio_file)["text"]
|
| 14 |
+
return transcription
|
| 15 |
+
|
| 16 |
+
# Gradio interface setup
|
| 17 |
+
iface = gr.Interface(
|
| 18 |
+
fn=transcribe_audio,
|
| 19 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
| 20 |
+
outputs="text",
|
| 21 |
+
title="Whisper Large v3 ASR",
|
| 22 |
+
description="Transcribe audio files using OpenAI's Whisper Large v3 model.",
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
# Launch the app
|
| 26 |
+
iface.launch()
|
|
|