Spaces:
Sleeping
Sleeping
import gradio as gr | |
import torch | |
from utils.speech_processor import SpeechProcessor | |
from utils.text_processor import TextProcessor | |
from utils.output_generator import OutputGenerator | |
import tempfile | |
import os | |
# Initialize processors | |
speech_processor = SpeechProcessor() | |
text_processor = TextProcessor() | |
output_generator = OutputGenerator() | |
def process_meeting(audio_file, language="id", summary_ratio=0.3): | |
""" | |
Main pipeline untuk memproses audio meeting | |
""" | |
try: | |
# Step 1: Speech Processing | |
gr.Info("π€ Memproses audio...") | |
transcript_with_speakers = speech_processor.process_audio( | |
audio_file, | |
language=language | |
) | |
# Step 2: Text Processing & Summarization | |
gr.Info("π Membuat ringkasan...") | |
summary = text_processor.summarize_transcript( | |
transcript_with_speakers, | |
ratio=summary_ratio | |
) | |
# Step 3: Information Extraction | |
gr.Info("π Mengekstrak informasi penting...") | |
extracted_info = text_processor.extract_key_information( | |
transcript_with_speakers | |
) | |
# Step 4: Generate Output | |
gr.Info("π Membuat notulensi...") | |
outputs = output_generator.generate_all_formats( | |
transcript_with_speakers, | |
summary, | |
extracted_info | |
) | |
return ( | |
outputs['markdown'], | |
outputs['json'], | |
outputs['transcript_table'], | |
outputs['action_items_table'], | |
outputs['decisions_table'] | |
) | |
except Exception as e: | |
gr.Error(f"Error: {str(e)}") | |
return None, None, None, None, None | |
# Gradio Interface | |
with gr.Blocks(title="π€ AI Meeting Minutes Generator") as demo: | |
gr.Markdown(""" | |
# π€ AI Meeting Minutes Generator | |
Upload audio rapat Anda dan dapatkan notulensi otomatis dengan: | |
- π― Identifikasi pembicara | |
- π Ringkasan otomatis | |
- β Action items | |
- π Keputusan penting | |
""") | |
with gr.Row(): | |
with gr.Column(): | |
audio_input = gr.Audio( | |
label="Upload Audio Rapat", | |
type="filepath", | |
sources=["upload", "microphone"] | |
) | |
with gr.Row(): | |
language = gr.Dropdown( | |
choices=[ | |
("Indonesia", "id"), | |
("English", "en") | |
], | |
value="id", | |
label="Bahasa" | |
) | |
summary_ratio = gr.Slider( | |
minimum=0.1, | |
maximum=0.5, | |
value=0.3, | |
step=0.05, | |
label="Rasio Ringkasan" | |
) | |
process_btn = gr.Button("π Proses Audio", variant="primary") | |
with gr.Row(): | |
with gr.Column(): | |
gr.Markdown("### π Notulensi (Markdown)") | |
markdown_output = gr.Textbox( | |
label="Preview Notulensi", | |
lines=20, | |
max_lines=30 | |
) | |
json_download = gr.File( | |
label="π₯ Download JSON" | |
) | |
with gr.Row(): | |
with gr.Column(): | |
gr.Markdown("### π Transkrip Lengkap") | |
transcript_table = gr.Dataframe( | |
headers=["Waktu", "Pembicara", "Teks"], | |
label="Transkrip dengan Pembicara" | |
) | |
with gr.Row(): | |
with gr.Column(): | |
gr.Markdown("### β Action Items") | |
action_items_table = gr.Dataframe( | |
headers=["Action Item", "Penanggung Jawab", "Timestamp"], | |
label="Daftar Action Items" | |
) | |
with gr.Column(): | |
gr.Markdown("### π Keputusan") | |
decisions_table = gr.Dataframe( | |
headers=["Keputusan", "Pembicara", "Timestamp"], | |
label="Daftar Keputusan" | |
) | |
# Process button action | |
process_btn.click( | |
fn=process_meeting, | |
inputs=[audio_input, language, summary_ratio], | |
outputs=[ | |
markdown_output, | |
json_download, | |
transcript_table, | |
action_items_table, | |
decisions_table | |
] | |
) | |
# Examples | |
gr.Examples( | |
examples=[ | |
["examples/meeting_sample_id.wav", "id", 0.3], | |
["examples/meeting_sample_en.wav", "en", 0.25] | |
], | |
inputs=[audio_input, language, summary_ratio] | |
) | |
if __name__ == "__main__": | |
demo.launch() |