Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -17,20 +17,23 @@ import io
|
|
17 |
#Here is the code
|
18 |
|
19 |
summarization = pipeline ('summarization', model = "pszemraj/long-t5-tglobal-base-16384-book-summary")
|
|
|
20 |
|
21 |
def summarize_and_speech(pdf_file):
|
22 |
-
pdf_bytes_io = io.BytesIO(pdf_file)
|
23 |
-
pdf_reader = PyPDF2.PdfReader(pdf_bytes_io)
|
24 |
-
abstract_text = pdf_reader.pages[0].extract_text()
|
25 |
-
summary = summarization(abstract_text, max_length=13, min_length=10)[0]['summary_text']
|
26 |
-
|
27 |
-
# Use a text-to-speech model to generate audio
|
28 |
-
synthesiser = pipeline("text-to-speech", "facebook/mms-tts-eng")
|
29 |
-
tts_output = synthesiser(summary)
|
30 |
-
audio_data = tts_output[0]["audio"]
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
-
return summary, audio_data
|
34 |
|
35 |
iface = gr.Interface(
|
36 |
fn= summarize_and_speech,
|
@@ -41,5 +44,4 @@ iface = gr.Interface(
|
|
41 |
description="Upload a Research Paper PDF File. The model will generate a one line summary of the Abstract section and a speech audio."
|
42 |
)
|
43 |
|
44 |
-
iface.launch()
|
45 |
-
|
|
|
17 |
#Here is the code
|
18 |
|
19 |
summarization = pipeline ('summarization', model = "pszemraj/long-t5-tglobal-base-16384-book-summary")
|
20 |
+
synthesiser = pipeline("text-to-speech", model='facebook/mms-tts-eng')
|
21 |
|
22 |
def summarize_and_speech(pdf_file):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
+
pdf_bytes_io = io.BytesIO(pdf_file)
|
25 |
+
pdf_reader = PyPDF2.PdfReader(pdf_bytes_io)
|
26 |
+
abstract_text = pdf_reader.pages[0].extract_text()
|
27 |
+
summary = summarization(abstract_text, max_length=13, min_length=10)[0]['summary_text']
|
28 |
+
print(summary)
|
29 |
+
|
30 |
+
# Use a text-to-speech model to generate audio
|
31 |
+
synthesiser = pipeline("text-to-speech", model='facebook/mms-tts-eng')
|
32 |
+
tts_output = synthesiser(summary)
|
33 |
+
audio_data = tts_output[0]["audio"]
|
34 |
+
|
35 |
+
return summary, audio_data
|
36 |
|
|
|
37 |
|
38 |
iface = gr.Interface(
|
39 |
fn= summarize_and_speech,
|
|
|
44 |
description="Upload a Research Paper PDF File. The model will generate a one line summary of the Abstract section and a speech audio."
|
45 |
)
|
46 |
|
47 |
+
iface.launch()
|
|