Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 794a4c4

Browse files
Merge pull request avinashkranjan#786 from Amit366/Amit
Image to speech
2 parents 5a4b79f + 321e32d commit 794a4c4

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

‎Imagetospeech/Readme.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# <b>Image To Speech File</b>
2+
3+
[![forthebadge](https://forthebadge.com/images/badges/made-with-python.svg)](https://forthebadge.com)
4+
5+
## Image To Speech Functionalities : 🚀
6+
7+
- The script converts an image to text and speech files
8+
- At the end the script asks whether to save or delete files
9+
10+
## Image To Speech Instructions: 👨🏻‍💻
11+
12+
### Step 1:
13+
14+
Open Termnial 💻
15+
16+
### Step 2:
17+
18+
Locate to the directory where python file is located 📂
19+
20+
### Step 3:
21+
22+
Run the command: python image_to_speech.py/python3 image_to_speech.py 🧐
23+
24+
### Step 4:
25+
26+
Sit back and Relax. Let the Script do the Job. ☕
27+
28+
### Requirements
29+
30+
- pytesseract
31+
- PIL
32+
- gTTS
33+
- os
34+
35+
## Author
36+
37+
Amit Kumar Mishra
38+

‎Imagetospeech/image_to_speech.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pytesseract
2+
from PIL import Image
3+
from gtts import gTTS
4+
import os
5+
6+
7+
pytesseract.pytesseract.tesseract_cmd = input(r'Enter the path for pytesseract: ')
8+
9+
img = input(r"Enter the path for image: ")
10+
target = Image.open(img)
11+
text = pytesseract.image_to_string(target, config='')
12+
13+
with open(f"./Imagetospeech/text.txt",'w') as f:
14+
f.write(text)
15+
16+
file = open(r'./Imagetospeech/text.txt')
17+
mytext = file.read().replace("\n"," ")
18+
language = 'en'
19+
output = gTTS(text=mytext, lang=language, slow=False)
20+
output.save('./Imagetospeech/imagetospeech.mp3')
21+
file.close()
22+
os.system("start ./Imagetospeech/imagetospeech.mp3")
23+
24+
question = input("Do you want to delete the files (Y/N): ")
25+
if question=='Y'or question=='y':
26+
os.remove('./Imagetospeech/text.txt')
27+
os.remove('./Imagetospeech/imagetospeech.mp3')
28+
29+
elif question=='N'or question=='n':
30+
print("Files saved")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /