|
|
import gradio as gr, os, json |
|
|
from nlp_utils import transcribe_audio, summarize, extract_actions_decisions, make_minutes_md |
|
|
|
|
|
OUT_DIR = "outputs" |
|
|
os.makedirs(OUT_DIR, exist_ok=True) |
|
|
|
|
|
def process(audio_file, transcript_text, meeting_title): |
|
|
text = "" |
|
|
if audio_file is not None: |
|
|
text = transcribe_audio(audio_file) |
|
|
if transcript_text and transcript_text.strip(): |
|
|
extra = transcript_text.strip() |
|
|
text = (text + "\n" + extra).strip() if text else extra |
|
|
|
|
|
if not text or len(text) < 40: |
|
|
return "Please, upload an audio or paste a transcript (≥ 40 characters).", "", [], [], None |
|
|
|
|
|
resum = summarize(text) |
|
|
ed = extract_actions_decisions(text) |
|
|
actions = ed.get("actions", []) |
|
|
decisions = ed.get("decisions", []) |
|
|
|
|
|
title = meeting_title or "Meeting" |
|
|
md = make_minutes_md(title, resum, actions, decisions) |
|
|
md_path = os.path.join(OUT_DIR, "minutes.md") |
|
|
with open(md_path, "w", encoding="utf-8") as f: |
|
|
f.write(md) |
|
|
|
|
|
|
|
|
actions_ht = [(a, "Action") for a in actions] if actions else [] |
|
|
decisions_ht = [(d, "Decision") for d in decisions] if decisions else [] |
|
|
|
|
|
return "Analyze finished ✅", resum, actions_ht, decisions_ht, md_path |
|
|
|
|
|
with gr.Blocks(title="MeetingNotes AI") as demo: |
|
|
gr.Markdown("# MeetingNotes AI") |
|
|
gr.Markdown("Upload an **audio** or **paste a transcript**, then clic **Analyze**.") |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
meeting_title = gr.Textbox(label="Title of the meeting", value="Launch product — Weekly") |
|
|
audio = gr.Audio(label="Audio (mp3/wav)", sources=["upload"], type="filepath") |
|
|
transcript = gr.Textbox(label="Transcript (optional if audio)", lines=10, placeholder="Paste here…") |
|
|
btn = gr.Button("Analyze") |
|
|
with gr.Column(): |
|
|
status = gr.Textbox(label="Statu") |
|
|
resume = gr.Textbox(label="Sum up", lines=8) |
|
|
actions = gr.HighlightedText(label="Action Points", combine_adjacent=True) |
|
|
decisions = gr.HighlightedText(label="Decisions Taken", combine_adjacent=True) |
|
|
files = gr.File(label="Download minutes.md") |
|
|
|
|
|
btn.click(process, inputs=[audio, transcript, meeting_title], outputs=[status, resume, actions, decisions, files]) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
demo.launch() |
|
|
|