Skip to content

Commit

Permalink
Merge pull request #657 from avats101/main
Browse files Browse the repository at this point in the history
Added Image to Speech
  • Loading branch information
pawangeek authored Oct 6, 2021
2 parents 5d4058a + 3ad2680 commit c98c109
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
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

0 comments on commit c98c109

Please sign in to comment.