Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -61,19 +61,19 @@ def text_to_speech(text):
|
|
61 |
return wav, rate
|
62 |
|
63 |
def process_pdf(uploaded_file, hf_model_name):
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
iface = gr.Interface(
|
74 |
fn=process_pdf,
|
75 |
inputs=[
|
76 |
-
gr.File(label="Upload PDF"
|
77 |
gr.Textbox(label="Hugging Face Model Name for Summarization")
|
78 |
],
|
79 |
outputs=gr.Audio(label="Audio Summary"),
|
|
|
61 |
return wav, rate
|
62 |
|
63 |
def process_pdf(uploaded_file, hf_model_name):
|
64 |
+
if uploaded_file.name.lower().endswith('.pdf'):
|
65 |
+
abstract = extract_and_clean_abstract(uploaded_file)
|
66 |
+
summary = summarize_text(hf_model_name, abstract)
|
67 |
+
wav, rate = text_to_speech(summary)
|
68 |
+
sf.write('/tmp/speech_output.wav', wav, rate)
|
69 |
+
return '/tmp/speech_output.wav'
|
70 |
+
else:
|
71 |
+
return "Error: Please upload a PDF file."
|
72 |
|
73 |
iface = gr.Interface(
|
74 |
fn=process_pdf,
|
75 |
inputs=[
|
76 |
+
gr.File(label="Upload PDF"),
|
77 |
gr.Textbox(label="Hugging Face Model Name for Summarization")
|
78 |
],
|
79 |
outputs=gr.Audio(label="Audio Summary"),
|