Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import torch
|
| 3 |
+
from transformers import pipeline
|
| 4 |
+
import tempfile
|
| 5 |
+
|
| 6 |
+
# Set the Streamlit page config
|
| 7 |
+
st.set_page_config(page_title="Meeting Summarizer", layout="centered")
|
| 8 |
+
|
| 9 |
+
# Title
|
| 10 |
+
st.title("π Intelligent Meeting Summarizer")
|
| 11 |
+
st.write("Upload your English meeting audio, and we'll generate a professional summary for you using Hugging Face models.")
|
| 12 |
+
|
| 13 |
+
# Load ASR pipeline
|
| 14 |
+
@st.cache_resource
|
| 15 |
+
def load_asr_pipeline():
|
| 16 |
+
return pipeline("automatic-speech-recognition", model="facebook/s2t-medium-librispeech-asr")
|
| 17 |
+
|
| 18 |
+
# Load Text Generation pipeline
|
| 19 |
+
@st.cache_resource
|
| 20 |
+
def load_summary_pipeline():
|
| 21 |
+
return pipeline(
|
| 22 |
+
task="text-generation",
|
| 23 |
+
model="huggyllama/llama-7b",
|
| 24 |
+
torch_dtype=torch.float16,
|
| 25 |
+
device=0 # set to -1 for CPU
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
asr_pipeline = load_asr_pipeline()
|
| 29 |
+
gen_pipeline = load_summary_pipeline()
|
| 30 |
+
|
| 31 |
+
# Upload audio file
|
| 32 |
+
uploaded_file = st.file_uploader("π€ Upload your meeting audio (.wav)", type=["wav", "mp3", "flac"])
|
| 33 |
+
|
| 34 |
+
if uploaded_file is not None:
|
| 35 |
+
# Save to temp file
|
| 36 |
+
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_audio:
|
| 37 |
+
tmp_audio.write(uploaded_file.read())
|
| 38 |
+
tmp_audio_path = tmp_audio.name
|
| 39 |
+
|
| 40 |
+
st.audio(uploaded_file, format='audio/wav')
|
| 41 |
+
|
| 42 |
+
if st.button("π Transcribe and Summarize"):
|
| 43 |
+
# ASR: Audio to Text
|
| 44 |
+
with st.spinner("Transcribing audio..."):
|
| 45 |
+
result = asr_pipeline(tmp_audio_path)
|
| 46 |
+
transcription = result["text"]
|
| 47 |
+
st.subheader("π Transcribed Text")
|
| 48 |
+
st.write(transcription)
|
| 49 |
+
|
| 50 |
+
# Text to Text
|
| 51 |
+
with st.spinner("Generating summary..."):
|
| 52 |
+
prompt = f"Summarize the following meeting transcript into a professional meeting report:\n{transcription}\n\nSummary:"
|
| 53 |
+
summary = gen_pipeline(prompt, max_new_tokens=300, do_sample=True, top_k=50, temperature=0.7)[0]["generated_text"]
|
| 54 |
+
st.subheader("π§ Meeting Summary")
|
| 55 |
+
st.write(summary)
|