Update app.py
Browse files
app.py
CHANGED
@@ -1,27 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def summarize_audio(audio_file):
|
5 |
-
|
6 |
-
|
|
|
|
|
7 |
return summary
|
8 |
|
9 |
-
|
10 |
-
return "ืชืืืื ืืืืืื"
|
11 |
-
|
12 |
-
def create_summary(transcript):
|
13 |
-
response = openai.Completion.create(
|
14 |
-
engine="text-davinci-003",
|
15 |
-
prompt=f"Please summarize the following text:\n\n{transcript}",
|
16 |
-
max_tokens=100
|
17 |
-
)
|
18 |
-
return response['choices'][0]['text'].strip()
|
19 |
-
|
20 |
interface = gr.Interface(
|
21 |
fn=summarize_audio,
|
22 |
-
inputs=gr.Audio(source="upload", type="
|
23 |
outputs="text",
|
24 |
-
title="ืืืืจ ืืืืื ืืกืืืื"
|
|
|
25 |
)
|
26 |
|
27 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# ืืฆืืจืช pipe ืืชืืืื ืืืกืืืื
|
5 |
+
transcriber = pipeline("automatic-speech-recognition", model="openai/whisper-base")
|
6 |
+
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
7 |
|
8 |
def summarize_audio(audio_file):
|
9 |
+
# ืชืืืื ืืืืืื
|
10 |
+
transcript = transcriber(audio_file)["text"]
|
11 |
+
# ืืฆืืจืช ืกืืืื ืฉื ืืชืืืื
|
12 |
+
summary = summarizer(transcript, max_length=50, min_length=25, do_sample=False)[0]["summary_text"]
|
13 |
return summary
|
14 |
|
15 |
+
# ืืืืจืช ืืืฉืง Gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
interface = gr.Interface(
|
17 |
fn=summarize_audio,
|
18 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
19 |
outputs="text",
|
20 |
+
title="ืืืืจ ืืืืื ืืกืืืื",
|
21 |
+
description="ืืขืื ืงืืืฅ ืืืืื ืฉื ืืจืฆื ืืงืื ืกืืืื ืงืฆืจ ืฉื ืืชืืื."
|
22 |
)
|
23 |
|
24 |
if __name__ == "__main__":
|