Update app.py
Browse files
app.py
CHANGED
|
@@ -8,7 +8,6 @@ asr = pipeline(task="automatic-speech-recognition", model="distil-whisper/distil
|
|
| 8 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 9 |
qa_pipeline = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
|
| 10 |
|
| 11 |
-
# Global transcript
|
| 12 |
stored_transcript = ""
|
| 13 |
|
| 14 |
def transcribe_and_summarize(video_file):
|
|
@@ -44,47 +43,27 @@ def answer_question(question):
|
|
| 44 |
result = qa_pipeline(question=question, context=stored_transcript)
|
| 45 |
return result['answer']
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
button_primary_text_color="#000000",
|
| 56 |
-
button_secondary_background="#222222",
|
| 57 |
-
button_secondary_text_color="#FFFF33",
|
| 58 |
-
input_background="#111111",
|
| 59 |
-
input_border_color="#FFFF33",
|
| 60 |
-
input_text_color="#FFFF33",
|
| 61 |
-
block_border_color="#FFFF33",
|
| 62 |
-
block_background="#000000"
|
| 63 |
-
)
|
| 64 |
-
|
| 65 |
-
# Gradio UI
|
| 66 |
-
with gr.Blocks(theme=neon_theme) as iface:
|
| 67 |
-
gr.Markdown("## π₯ <span style='color:#FFFF33'>Video Transcriber, Summarizer & Q&A Tool</span>", unsafe_allow_html=True)
|
| 68 |
-
gr.Markdown("<span style='color:#CCCC33'>Upload a video to get a transcript, summary, and ask questions about its content.</span>", unsafe_allow_html=True)
|
| 69 |
|
| 70 |
with gr.Tab("π Transcription & Summary"):
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
with gr.Row():
|
| 76 |
-
transcribed_text = gr.Textbox(label="Transcribed Text", lines=8, interactive=False)
|
| 77 |
-
summarized_text = gr.Textbox(label="Summarized Text", lines=8, interactive=False)
|
| 78 |
|
| 79 |
transcribe_btn.click(fn=transcribe_and_summarize, inputs=video_input, outputs=[transcribed_text, summarized_text])
|
| 80 |
|
| 81 |
with gr.Tab("β Ask Questions"):
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
ask_btn = gr.Button("π Get Answer")
|
| 86 |
-
with gr.Row():
|
| 87 |
-
answer_output = gr.Textbox(label="Answer", interactive=False)
|
| 88 |
|
| 89 |
ask_btn.click(fn=answer_question, inputs=question_input, outputs=answer_output)
|
| 90 |
|
|
|
|
| 8 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 9 |
qa_pipeline = pipeline("question-answering", model="distilbert-base-cased-distilled-squad")
|
| 10 |
|
|
|
|
| 11 |
stored_transcript = ""
|
| 12 |
|
| 13 |
def transcribe_and_summarize(video_file):
|
|
|
|
| 43 |
result = qa_pipeline(question=question, context=stored_transcript)
|
| 44 |
return result['answer']
|
| 45 |
|
| 46 |
+
with gr.Blocks(css="""
|
| 47 |
+
body { background-color: black !important; }
|
| 48 |
+
.gradio-container { color: #FFFF33 !important; }
|
| 49 |
+
button { background-color: #FFFF33 !important; color: black !important; border: none !important; }
|
| 50 |
+
input, textarea, .gr-textbox, .gr-video { background-color: #111 !important; color: #FFFF33 !important; border-color: #FFFF33 !important; }
|
| 51 |
+
""") as iface:
|
| 52 |
+
gr.HTML("<h1 style='color:#FFFF33'>π₯ Video Transcriber, Summarizer & Q&A Tool</h1>")
|
| 53 |
+
gr.HTML("<p style='color:#CCCC33'>Upload a video to get a transcript, summary, and ask questions about its content.</p>")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
with gr.Tab("π Transcription & Summary"):
|
| 56 |
+
video_input = gr.Video(label="Upload Video (.mp4)", interactive=True)
|
| 57 |
+
transcribe_btn = gr.Button("π Transcribe and Summarize")
|
| 58 |
+
transcribed_text = gr.Textbox(label="Transcribed Text", lines=8, interactive=False)
|
| 59 |
+
summarized_text = gr.Textbox(label="Summarized Text", lines=8, interactive=False)
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
transcribe_btn.click(fn=transcribe_and_summarize, inputs=video_input, outputs=[transcribed_text, summarized_text])
|
| 62 |
|
| 63 |
with gr.Tab("β Ask Questions"):
|
| 64 |
+
question_input = gr.Textbox(label="Ask a question based on the transcript", placeholder="E.g., What is the main topic?")
|
| 65 |
+
ask_btn = gr.Button("π Get Answer")
|
| 66 |
+
answer_output = gr.Textbox(label="Answer", interactive=False)
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
ask_btn.click(fn=answer_question, inputs=question_input, outputs=answer_output)
|
| 69 |
|