Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,7 @@ def summarize_text(text):
|
|
22 |
break
|
23 |
abstract = ". ".join(sentences[start:end+1])
|
24 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
25 |
-
summary = summarizer(abstract, max_length=50, min_length=
|
26 |
return summary[0]['summary_text']
|
27 |
|
28 |
def text_to_audio(text):
|
@@ -32,7 +32,7 @@ def text_to_audio(text):
|
|
32 |
buffer.seek(0)
|
33 |
return buffer.read()
|
34 |
|
35 |
-
def
|
36 |
text = extract_text(pdf_file)
|
37 |
summary = summarize_text(text)
|
38 |
audio = text_to_audio(summary)
|
@@ -42,10 +42,10 @@ inputs = gr.File()
|
|
42 |
audio_summary = gr.Audio()
|
43 |
|
44 |
iface = gr.Interface(
|
45 |
-
fn=
|
46 |
inputs=inputs,
|
47 |
outputs=audio_summary,
|
48 |
title="PDF Summarizer"
|
49 |
)
|
50 |
|
51 |
-
iface.launch()
|
|
|
22 |
break
|
23 |
abstract = ". ".join(sentences[start:end+1])
|
24 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
25 |
+
summary = summarizer(abstract, max_length=50, min_length=30)
|
26 |
return summary[0]['summary_text']
|
27 |
|
28 |
def text_to_audio(text):
|
|
|
32 |
buffer.seek(0)
|
33 |
return buffer.read()
|
34 |
|
35 |
+
def audio_pdf(pdf_file):
|
36 |
text = extract_text(pdf_file)
|
37 |
summary = summarize_text(text)
|
38 |
audio = text_to_audio(summary)
|
|
|
42 |
audio_summary = gr.Audio()
|
43 |
|
44 |
iface = gr.Interface(
|
45 |
+
fn=audio_pdf,
|
46 |
inputs=inputs,
|
47 |
outputs=audio_summary,
|
48 |
title="PDF Summarizer"
|
49 |
)
|
50 |
|
51 |
+
iface.launch()
|