Spaces:
Sleeping
Sleeping
Upload 2 files
Browse files- app.py +38 -0
- requirements.txt +5 -0
app.py
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import whisper
|
3 |
+
from transformers import pipeline
|
4 |
+
|
5 |
+
# Load models
|
6 |
+
print("Loading models...")
|
7 |
+
whisper_model = whisper.load_model("base")
|
8 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
9 |
+
|
10 |
+
def transcribe(audio_path):
|
11 |
+
if audio_path is None:
|
12 |
+
return "Please record some audio."
|
13 |
+
result = whisper_model.transcribe(audio_path)
|
14 |
+
return result["text"]
|
15 |
+
|
16 |
+
def summarize(text):
|
17 |
+
if not text.strip():
|
18 |
+
return "No transcription available to summarize."
|
19 |
+
summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
|
20 |
+
return summary[0]['summary_text']
|
21 |
+
|
22 |
+
with gr.Blocks() as app:
|
23 |
+
gr.Markdown("## ποΈ Real-Time Transcription & Summarization Tool\nSpeak into your mic and generate a summary.")
|
24 |
+
|
25 |
+
with gr.Row():
|
26 |
+
audio_input = gr.Audio(source="microphone", type="filepath", label="π§ Record Audio")
|
27 |
+
transcription_output = gr.Textbox(label="π Transcription", lines=6, interactive=False)
|
28 |
+
|
29 |
+
transcribe_button = gr.Button("Transcribe")
|
30 |
+
transcribe_button.click(fn=transcribe, inputs=audio_input, outputs=transcription_output)
|
31 |
+
|
32 |
+
with gr.Row():
|
33 |
+
summarize_button = gr.Button("Generate Summary")
|
34 |
+
summary_output = gr.Textbox(label="π Summary", lines=6, interactive=False)
|
35 |
+
|
36 |
+
summarize_button.click(fn=summarize, inputs=transcription_output, outputs=summary_output)
|
37 |
+
|
38 |
+
app.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
transformers
|
3 |
+
torch
|
4 |
+
torchaudio
|
5 |
+
whisper
|