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()