Spaces:
Sleeping
Sleeping
Commit
·
75ad4a8
1
Parent(s):
acd79d8
fixed app.py
Browse files
app.py
CHANGED
@@ -71,25 +71,16 @@ def summarize_and_convert_to_audio(pdf_file):
|
|
71 |
inputs = inputs.to(device)
|
72 |
|
73 |
speech_values = model.generate(**inputs, do_sample=True)
|
74 |
-
|
75 |
-
print("speech_values : ", speech_values)
|
76 |
-
|
77 |
sampling_rate = model.generation_config.sample_rate
|
78 |
-
|
79 |
-
print("sampling_rate : ", sampling_rate)
|
80 |
|
81 |
# Convert speech values to audio data
|
82 |
audio_data = speech_values.cpu().numpy().squeeze()
|
83 |
|
84 |
-
print("audio_data : ", audio_data)
|
85 |
-
|
86 |
# Convert audio data to bytes
|
87 |
with BytesIO() as buffer:
|
88 |
write_wav(buffer, sampling_rate, audio_data.astype(np.float32))
|
89 |
audio_bytes = buffer.getvalue()
|
90 |
|
91 |
-
print("audio_bytes : ", audio_bytes)
|
92 |
-
|
93 |
return audio_bytes
|
94 |
|
95 |
|
@@ -99,7 +90,11 @@ iface = gr.Interface(
|
|
99 |
inputs=gr.UploadButton(label="Upload PDF", type="binary", file_types=["pdf"]), # Set to accept only PDF files
|
100 |
outputs=gr.Audio(label="Audio"),
|
101 |
title="PDF Abstract Summarizer",
|
102 |
-
description="
|
|
|
|
|
|
|
|
|
103 |
)
|
104 |
|
105 |
iface.launch()
|
|
|
71 |
inputs = inputs.to(device)
|
72 |
|
73 |
speech_values = model.generate(**inputs, do_sample=True)
|
|
|
|
|
|
|
74 |
sampling_rate = model.generation_config.sample_rate
|
|
|
|
|
75 |
|
76 |
# Convert speech values to audio data
|
77 |
audio_data = speech_values.cpu().numpy().squeeze()
|
78 |
|
|
|
|
|
79 |
# Convert audio data to bytes
|
80 |
with BytesIO() as buffer:
|
81 |
write_wav(buffer, sampling_rate, audio_data.astype(np.float32))
|
82 |
audio_bytes = buffer.getvalue()
|
83 |
|
|
|
|
|
84 |
return audio_bytes
|
85 |
|
86 |
|
|
|
90 |
inputs=gr.UploadButton(label="Upload PDF", type="binary", file_types=["pdf"]), # Set to accept only PDF files
|
91 |
outputs=gr.Audio(label="Audio"),
|
92 |
title="PDF Abstract Summarizer",
|
93 |
+
description="""
|
94 |
+
This application is supposed to summarize the 'abstract' section of a PDF file and convert the summarization into a speech.
|
95 |
+
Please make sure you upload a PDF file with the 'abstract' section for application to work.
|
96 |
+
Note: If you get an error while processing the file please refresh your browser and try again.
|
97 |
+
"""
|
98 |
)
|
99 |
|
100 |
iface.launch()
|