Spaces:
Running
Running
Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,5 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import whisper
|
| 3 |
-
import os
|
| 4 |
-
import tempfile
|
| 5 |
|
| 6 |
model = None
|
| 7 |
|
|
@@ -14,12 +12,10 @@ def load_model():
|
|
| 14 |
def transcribe(file):
|
| 15 |
if file is None:
|
| 16 |
return "Please upload a video or audio file."
|
| 17 |
-
|
| 18 |
try:
|
| 19 |
m = load_model()
|
| 20 |
result = m.transcribe(file, language="en", verbose=False)
|
| 21 |
-
|
| 22 |
-
return transcript
|
| 23 |
except Exception as e:
|
| 24 |
return f"Error: {str(e)}"
|
| 25 |
|
|
@@ -29,7 +25,6 @@ demo = gr.Interface(
|
|
| 29 |
outputs=gr.Textbox(label="Transcript", lines=15),
|
| 30 |
title="🎙️ AI Video Transcriber",
|
| 31 |
description="Upload any video or audio file and get a full transcript powered by OpenAI Whisper.",
|
| 32 |
-
examples=[],
|
| 33 |
theme=gr.themes.Soft()
|
| 34 |
)
|
| 35 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import whisper
|
|
|
|
|
|
|
| 3 |
|
| 4 |
model = None
|
| 5 |
|
|
|
|
| 12 |
def transcribe(file):
|
| 13 |
if file is None:
|
| 14 |
return "Please upload a video or audio file."
|
|
|
|
| 15 |
try:
|
| 16 |
m = load_model()
|
| 17 |
result = m.transcribe(file, language="en", verbose=False)
|
| 18 |
+
return result["text"].strip()
|
|
|
|
| 19 |
except Exception as e:
|
| 20 |
return f"Error: {str(e)}"
|
| 21 |
|
|
|
|
| 25 |
outputs=gr.Textbox(label="Transcript", lines=15),
|
| 26 |
title="🎙️ AI Video Transcriber",
|
| 27 |
description="Upload any video or audio file and get a full transcript powered by OpenAI Whisper.",
|
|
|
|
| 28 |
theme=gr.themes.Soft()
|
| 29 |
)
|
| 30 |
|