Update app.py
Browse files
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 |
-
#
|
| 31 |
-
def
|
|
|
|
| 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=
|
| 40 |
-
inputs=gr.File(
|
| 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",
|