Update app.py
Browse files
app.py
CHANGED
|
@@ -2,15 +2,19 @@ from transformers import pipeline
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
def summarize_text(article):
|
| 7 |
-
summary = summarizer(article, max_length=130, min_length=30, do_sample=False)
|
| 8 |
-
return summary[0]['summary_text']
|
| 9 |
|
| 10 |
interface = gr.Interface(
|
| 11 |
-
fn=
|
| 12 |
-
inputs=gr.Textbox(lines=10, label="Input
|
| 13 |
-
outputs=gr.Textbox(label="Summary")
|
| 14 |
)
|
| 15 |
|
| 16 |
interface.launch()
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
|
| 4 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
| 5 |
+
speech = pipeline("text-to-speech", model="myshell-ai/MeloTTS-English")
|
| 6 |
+
|
| 7 |
+
def summarize_text_and_speak(prompt):
|
| 8 |
+
summary = summarizer(prompt, max_length=150, min_length=30, do_sample=False)
|
| 9 |
+
summary_text = summary[0]['summary_text']
|
| 10 |
+
audio = speech(summary_text)
|
| 11 |
+
return summary_text, audio["audio"]
|
| 12 |
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
interface = gr.Interface(
|
| 15 |
+
fn=summarize_text_and_speak,
|
| 16 |
+
inputs=gr.Textbox(lines=10, label="Input text"),
|
| 17 |
+
outputs=[gr.Textbox(label="Summary"), "audio"]
|
| 18 |
)
|
| 19 |
|
| 20 |
interface.launch()
|