MOHAN KRISHNA

0 %
Mohan Krishna
Multimedia Professional
Ai & ML Researcher & Enthusiast
  • Residence:
    India
  • City:
    Vijayawada
  • Age:
    46
AI/ML Enthusiast. New Media Trainer, VFX Artist, Non Linear Video Editor, Graphic Designer, Sound Editor and iOS App Designer.
Telugu
English
Hindi
Tamil
Proficiency:
Graphic Design
Web Design
Video & VFX
Machine Learning
Artificial Intelligence
Digital Marketing
Areas of Interest:
Take a look at some of the things I love working on.
  • Non Linear Video Editing
  • Graphic Design
  • Web Design
  • Audio Editing
  • Content Management Systems
  • Python
  • Deep Learning
  • OpenCV
  • Image Classification

Image to Speech

October 4, 2022
import pytesseract
from PIL import Image
from gtts import gTTS
import os
# http://www.pillalamarri.in/python/image-to-speech/

pytesseract.pytesseract.tesseract_cmd = input(
    r'Enter the path for pytesseract: ')

img = input(r"Enter the path for image: ")
target = Image.open(img)
text = pytesseract.image_to_string(target, config='')

with open(f"./Imagetospeech/text.txt", 'w') as f:
    f.write(text)

file = open(r'./Imagetospeech/text.txt')
mytext = file.read().replace("\n", " ")
language = 'en'
output = gTTS(text=mytext, lang=language, slow=False)
output.save('./Imagetospeech/imagetospeech.mp3')
file.close()
os.system("start ./Imagetospeech/imagetospeech.mp3")

question = input("Do you want to delete the files (Y/N): ")
if question == 'Y' or question == 'y':
    os.remove('./Imagetospeech/text.txt')
    os.remove('./Imagetospeech/imagetospeech.mp3')

elif question == 'N' or question == 'n':
    print("Files saved")
# http://www.pillalamarri.in/python/image-to-speech/
Posted in PythonTags: