Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,12 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from textblob import TextBlob
|
3 |
-
import PyPDF2
|
4 |
|
5 |
def extract_text_from_pdf(file_path):
|
6 |
-
|
7 |
-
pdf_reader = PyPDF2.PdfFileReader(pdf_file_obj)
|
8 |
text = ''
|
9 |
-
for
|
10 |
-
|
11 |
-
text += page_obj.extractText()
|
12 |
-
pdf_file_obj.close()
|
13 |
return text
|
14 |
|
15 |
def translate_text(text, dest_lang='en'):
|
@@ -22,5 +19,9 @@ def translate_pdf(file):
|
|
22 |
translation = translate_text(text)
|
23 |
return translation
|
24 |
|
25 |
-
iface = gr.Interface(fn=translate_pdf,
|
|
|
|
|
|
|
|
|
26 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from PyPDF2 import PdfReader
|
3 |
from textblob import TextBlob
|
|
|
4 |
|
5 |
def extract_text_from_pdf(file_path):
|
6 |
+
pdf = PdfReader(file_path)
|
|
|
7 |
text = ''
|
8 |
+
for page in pdf.pages:
|
9 |
+
text += page.extract_text()
|
|
|
|
|
10 |
return text
|
11 |
|
12 |
def translate_text(text, dest_lang='en'):
|
|
|
19 |
translation = translate_text(text)
|
20 |
return translation
|
21 |
|
22 |
+
iface = gr.Interface(fn=translate_pdf,
|
23 |
+
inputs=gr.inputs.File(label="Upload PDF file to translate"),
|
24 |
+
outputs='text',
|
25 |
+
title="PDF Translation App",
|
26 |
+
description="Use this application to translate from foreign language to English. Push 'Run' button when ready to translate.")
|
27 |
iface.launch()
|