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

Added Image to Speech #657

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions image_to_speech/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
USER GUIDE
Setup and activate virtual environment :

For Unix based systems please execute the following command to create venv and install requirements.

make init
source .venv/bin/activate

Pre-requisites

1) Python pillow (PIL)
$ pip install pillow

2) Python pytesseract (py package wrapper)
$ pip install pytesseract

3) Tesseract (OCR Tool)
Download from here https://github.com/tesseract-ocr/tesseract/releases

4) Python pyttsx3 (Text-to-Speech)
$ pip install pyttsx3

How to run the script?

$ python image_to_speech.py

Once done, Speech would be produced for the given text image
12 changes: 12 additions & 0 deletions image_to_speech/image_to_speech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import pytesseract
from PIL import Image
import pyttsx3
img = Image.open('Location_to_Image/text_image.png')
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'
result = pytesseract.image_to_string(img)
with open('text.txt', mode='w') as file:
file.write(result)
print(result)
engine = pyttsx3.init()
engine.say(result)
engine.runAndWait()
3 changes: 3 additions & 0 deletions image_to_speech/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pytesseract
pillow
pyttsx3