|
import gradio as gr |
|
from transformers import pipeline |
|
|
|
|
|
asr = pipeline("automatic-speech-recognition", model="distil-whisper/distil-small.en") |
|
|
|
|
|
summarizer = pipeline("summarization", model="facebook/bart-large-cnn") |
|
|
|
def process_audio(audio_path): |
|
try: |
|
|
|
transcription = asr(audio_path, return_timestamps=True) |
|
transcribed_text = transcription["text"] |
|
|
|
|
|
summary = summarizer(transcribed_text, max_length=150, min_length=50, do_sample=False)[0]["summary_text"] |
|
|
|
return transcribed_text, summary |
|
except Exception as e: |
|
print(f"Error: {str(e)}") |
|
return f"Error: {str(e)}", "" |
|
|
|
|
|
iface = gr.Interface( |
|
fn=process_audio, |
|
inputs=gr.Audio(source="upload", type="filepath"), |
|
outputs=[gr.Textbox(label="Transcription"), gr.Textbox(label="Summary")], |
|
title="Audio Summarizer", |
|
description="Upload an audio file, and this app will transcribe and summarize its content.", |
|
) |
|
|
|
iface.launch() |