| import gradio as gr |
| import os |
| from services.transcription import TranscriptionService |
| from services.summarization import SummarizationService |
|
|
| def process_audio(audio_file): |
| """Process uploaded audio file through transcription and summarization pipeline.""" |
| if audio_file is None: |
| return "Error: Please upload an audio file", "", "" |
| |
| try: |
| |
| transcription_service = TranscriptionService() |
| summarization_service = SummarizationService() |
| |
| |
| transcript = transcription_service.transcribe(audio_file) |
| if not transcript: |
| return "Error: Failed to transcribe audio", "", "" |
| |
| |
| summary = summarization_service.summarize(transcript) |
| |
| |
| action_items = summarization_service.extract_action_items(transcript) |
| |
| return transcript, summary, action_items |
| |
| except Exception as e: |
| return f"Error: {str(e)}", "", "" |
|
|
| def create_interface(): |
| """Create and configure the Gradio interface.""" |
| with gr.Blocks(title="Meeting Audio Processor") as interface: |
| gr.Markdown("# Meeting Audio Processor") |
| gr.Markdown("Upload an audio file to get transcript, summary, and action items") |
| |
| with gr.Row(): |
| audio_input = gr.Audio( |
| label="Upload Audio File", |
| type="filepath" |
| ) |
| |
| process_btn = gr.Button("Process Audio", variant="primary") |
| |
| with gr.Row(): |
| with gr.Column(): |
| transcript_output = gr.Textbox( |
| label="Transcript", |
| lines=10, |
| placeholder="Transcript will appear here..." |
| ) |
| |
| with gr.Column(): |
| summary_output = gr.Textbox( |
| label="Summary", |
| lines=5, |
| placeholder="Summary will appear here..." |
| ) |
| |
| action_items_output = gr.Textbox( |
| label="Action Items", |
| lines=5, |
| placeholder="Action items will appear here..." |
| ) |
| |
| process_btn.click( |
| fn=process_audio, |
| inputs=[audio_input], |
| outputs=[transcript_output, summary_output, action_items_output] |
| ) |
| |
| return interface |
|
|
| if __name__ == "__main__": |
| interface = create_interface() |
| interface.launch() |