Update app.py
Browse files
app.py
CHANGED
@@ -66,12 +66,14 @@ should_we_translate = gr.Interface(
|
|
66 |
# Function to read text from a Word document
|
67 |
def read_word_document(uploaded_file):
|
68 |
if uploaded_file is not None:
|
69 |
-
|
|
|
70 |
document = Document(file_stream)
|
71 |
text = '\n'.join([para.text for para in document.paragraphs])
|
72 |
return text
|
73 |
return "Please upload a Word document."
|
74 |
|
|
|
75 |
# Gradio interface for reading Word document
|
76 |
read_docx = gr.Interface(
|
77 |
read_word_document,
|
|
|
66 |
# Function to read text from a Word document
|
67 |
def read_word_document(uploaded_file):
|
68 |
if uploaded_file is not None:
|
69 |
+
# The file content is in uploaded_file['content'], which is bytes
|
70 |
+
file_stream = io.BytesIO(uploaded_file['content'])
|
71 |
document = Document(file_stream)
|
72 |
text = '\n'.join([para.text for para in document.paragraphs])
|
73 |
return text
|
74 |
return "Please upload a Word document."
|
75 |
|
76 |
+
|
77 |
# Gradio interface for reading Word document
|
78 |
read_docx = gr.Interface(
|
79 |
read_word_document,
|