Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -21,18 +21,13 @@ summarization = pipeline ('summarization', model = "pszemraj/long-t5-tglobal-bas
|
|
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[
|
25 |
-
summary = summarization(abstract_text, max_length=13, min_length=10)[
|
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[
|
31 |
-
|
32 |
-
if "audio" in tts_output[0]:
|
33 |
-
audio_data = tts_output[1]["audio"]
|
34 |
-
else:
|
35 |
-
print("Audio data is not available")
|
36 |
|
37 |
|
38 |
return summary, audio_data
|
|
|
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
|