Xuratron commited on
Commit
08b8b1c
·
1 Parent(s): 47bffbc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
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
- Processes the uploaded PDF file to extract, summarize the abstract, and convert it to speech.
66
- """
67
- abstract = extract_and_clean_abstract(uploaded_file)
68
- summary = summarize_text(hf_model_name, abstract)
69
- wav, rate = text_to_speech(summary)
70
- sf.write('/tmp/speech_output.wav', wav, rate)
71
- return '/tmp/speech_output.wav'
72
 
73
  iface = gr.Interface(
74
  fn=process_pdf,
75
  inputs=[
76
- gr.File(label="Upload PDF", type="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"),