Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,36 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
| 5 |
-
asr = pipeline("automatic-speech-recognition", model="openai/whisper-small")
|
| 6 |
-
|
| 7 |
-
# Function to convert video to text
|
| 8 |
-
def video_to_text(video):
|
| 9 |
-
# Hugging Face pipeline can take audio from video
|
| 10 |
-
text = asr(video)["text"]
|
| 11 |
return text
|
| 12 |
|
| 13 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue")) as demo:
|
| 14 |
-
gr.Markdown(
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
**Steps:**
|
| 20 |
-
1. Upload a short video (MP4, MOV, MKV, etc.).
|
| 21 |
-
2. Click **Generate Transcript**.
|
| 22 |
-
3. Copy your transcript.
|
| 23 |
-
"""
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
with gr.Row():
|
| 27 |
-
video_input = gr.Video(label="Upload Your Video", type="filepath")
|
| 28 |
-
transcript_output = gr.Textbox(
|
| 29 |
-
label="Transcript Output",
|
| 30 |
-
placeholder="Your transcript will appear here...",
|
| 31 |
-
lines=10
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
btn = gr.Button("Generate Transcript")
|
| 35 |
btn.click(video_to_text, inputs=video_input, outputs=transcript_output)
|
| 36 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
def video_to_text(video_path):
|
| 5 |
+
asr = pipeline("automatic-speech-recognition", model="openai/whisper-small", device=-1)
|
| 6 |
+
text = asr(video_path)["text"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
return text
|
| 8 |
|
| 9 |
with gr.Blocks(theme=gr.themes.Default(primary_hue="blue")) as demo:
|
| 10 |
+
gr.Markdown("# 🎥 Video-to-Text AI Tool\nUpload a video and get the transcript instantly.")
|
| 11 |
+
|
| 12 |
+
video_input = gr.Video(label="Upload Video", type="filepath")
|
| 13 |
+
transcript_output = gr.Textbox(label="Transcript", lines=10)
|
| 14 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
btn = gr.Button("Generate Transcript")
|
| 16 |
btn.click(video_to_text, inputs=video_input, outputs=transcript_output)
|
| 17 |
|