mrsk1883 commited on
Commit
44285d5
·
1 Parent(s): ad72987

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -27,17 +27,18 @@ def text_to_speech(text, output_path='output.mp3'):
27
  tts = gTTS(text, lang='en')
28
  tts.save(output_path)
29
 
30
- # Function to handle file upload
31
- def summarize_and_speak(file_contents):
 
32
  text = extract_text_from_pdf(file_contents)
33
  summary = summarize_text(text)
34
  text_to_speech(summary, output_path='output.mp3')
35
- return summary
36
 
37
  # Gradio Interface
38
  iface = gr.Interface(
39
- fn=summarize_and_speak,
40
- inputs=gr.File("pdf"),
41
  outputs=["text", "audio"],
42
  live=True,
43
  interpretation="default",
 
27
  tts = gTTS(text, lang='en')
28
  tts.save(output_path)
29
 
30
+ # Custom function to handle file uploads and processing
31
+ def process_file(input_file):
32
+ file_contents = input_file.read()
33
  text = extract_text_from_pdf(file_contents)
34
  summary = summarize_text(text)
35
  text_to_speech(summary, output_path='output.mp3')
36
+ return {"text": summary, "audio": "output.mp3"}
37
 
38
  # Gradio Interface
39
  iface = gr.Interface(
40
+ fn=process_file,
41
+ inputs=gr.File(),
42
  outputs=["text", "audio"],
43
  live=True,
44
  interpretation="default",