Ofiroz91's picture
Update app.py
7e6ae8c verified
raw
history blame
897 Bytes
import gradio as gr
from transformers import pipeline
# ื™ืฆื™ืจืช pipe ืœืชืžืœื•ืœ ื•ืœืกื™ื›ื•ื
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base")
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
def summarize_audio(audio_file):
# ืชืžืœื•ืœ ื”ืื•ื“ื™ื•
transcript = transcriber(audio_file)["text"]
# ื™ืฆื™ืจืช ืกื™ื›ื•ื ืฉืœ ื”ืชืžืœื•ืœ
summary = summarizer(transcript, max_length=50, min_length=25, do_sample=False)[0]["summary_text"]
return summary
# ื”ื’ื“ืจืช ืžืžืฉืง Gradio
interface = gr.Interface(
fn=summarize_audio,
inputs=gr.Audio(source="upload", type="filepath"),
outputs="text",
title="ืžืžื™ืจ ืื•ื“ื™ื• ืœืกื™ื›ื•ื",
description="ื”ืขืœื” ืงื•ื‘ืฅ ืื•ื“ื™ื• ืฉืœ ืžืจืฆื” ื•ืงื‘ืœ ืกื™ื›ื•ื ืงืฆืจ ืฉืœ ื”ืชื•ื›ืŸ."
)
if __name__ == "__main__":
interface.launch()