Skip to content

Commit

Permalink
text to speech with tesseract only working on im
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishan123 committed Oct 2, 2020
1 parent e105377 commit d706ac1
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 103 deletions.
Binary file added TTS/hello.mp3
Binary file not shown.
7 changes: 7 additions & 0 deletions TTS/test_tts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from gtts import gTTS
import os

tts = gTTS('hello')
tts.save('hello.mp3')
os.system('omxplayer /home/pi/Rishan-BOT/TTS/hello.mp3')
print('hello')
Binary file removed computer-vision/7080.png
Binary file not shown.
40 changes: 0 additions & 40 deletions computer-vision/ocr_tesseract.py

This file was deleted.

63 changes: 0 additions & 63 deletions computer-vision/ocr_tesseract_camera_text-to-speech.py

This file was deleted.

22 changes: 22 additions & 0 deletions computer-vision/ocr_tesseract_text-to-speech.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# import the necessary packages
import pytesseract
import cv2
from gtts import gTTS
import os

# load the example image and convert it to grayscale
image = cv2.imread('/home/pi/Rishan-BOT/computer-vision/example_01.png')
config = ('-l eng --oem 1 --psm 3')

image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = cv2.threshold(image, 0, 255,
cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]

text = pytesseract.image_to_string(image, config=config)
tts = gTTS(text)
tts.save('/home/pi/text.mp3')
os.system('omxplayer /home/pi/text.mp3')

print(text)
cv2.imshow('OCR',image)
cv2.waitKey(0)
Empty file added computer-vision/text.mp3
Empty file.

0 comments on commit d706ac1

Please sign in to comment.