File size: 897 Bytes
2612e90 7e6ae8c 2612e90 7e6ae8c 2612e90 7e6ae8c 2612e90 7e6ae8c 2612e90 7e6ae8c 2612e90 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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()
|