Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,17 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
# Load
|
6 |
print("Loading models...")
|
7 |
-
whisper_model =
|
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 |
-
|
14 |
-
|
|
|
|
|
15 |
|
16 |
def summarize(text):
|
17 |
if not text.strip():
|
@@ -19,11 +21,12 @@ def summarize(text):
|
|
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
|
24 |
|
25 |
with gr.Row():
|
26 |
-
audio_input = gr.Audio(type="filepath", label="π§ Record
|
27 |
transcription_output = gr.Textbox(label="π Transcription", lines=6, interactive=False)
|
28 |
|
29 |
transcribe_button = gr.Button("Transcribe")
|
|
|
1 |
import gradio as gr
|
2 |
+
from faster_whisper import WhisperModel
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
# Load Faster-Whisper and BART model
|
6 |
print("Loading models...")
|
7 |
+
whisper_model = WhisperModel("base") # You can use "tiny" if it's still too heavy
|
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 |
+
|
14 |
+
segments, _ = whisper_model.transcribe(audio_path)
|
15 |
+
transcription = " ".join([segment.text for segment in segments])
|
16 |
+
return transcription
|
17 |
|
18 |
def summarize(text):
|
19 |
if not text.strip():
|
|
|
21 |
summary = summarizer(text, max_length=150, min_length=40, do_sample=False)
|
22 |
return summary[0]['summary_text']
|
23 |
|
24 |
+
# Build Gradio UI
|
25 |
with gr.Blocks() as app:
|
26 |
+
gr.Markdown("## ποΈ Real-Time Transcription & Summarization\nSpeak into your mic and generate a summary.")
|
27 |
|
28 |
with gr.Row():
|
29 |
+
audio_input = gr.Audio(type="filepath", label="π§ Record Audio (Max ~120 sec)")
|
30 |
transcription_output = gr.Textbox(label="π Transcription", lines=6, interactive=False)
|
31 |
|
32 |
transcribe_button = gr.Button("Transcribe")
|