Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf reader for blind people. #4675

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 57 additions & 0 deletions Python/read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
####
# Run the following on terminal:
# pip install streamlit
# Install any other pacakges as required
####

import PyPDF2
import streamlit as st
from gtts import gTTS
from io import BytesIO

def speakText(text):
sound_file = BytesIO()
tts = gTTS(text, lang='en')
tts.write_to_fp(sound_file)
st.audio(sound_file)

def extractText(pdfPath):
pdfReader = PyPDF2.PdfReader(pdfPath)

text = ""
for pageObj in pdfReader.pages:
st.write("Reading PDF ..")
text += pageObj.extract_text()

return text

def readPDF(pdf):
text = extractText(pdf)
speakText(text)

pdfReader, textReader = st.columns(2)

with pdfReader:
st.write("""
# PDF Reader
Helps blind people read a PDF document.
""")

uploaded_pdf = st.file_uploader("Upload your PDF", type = "pdf")

if uploaded_pdf:
readPDF(uploaded_pdf)

with textReader:
st.write("""
# Text Reader
Helps blind people read a piece of text.
""")

text = st.text_input(label = "To read")

if text:
speakText(text)