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 53553ba

Browse files
committed
Updated
1 parent 024ca90 commit 53553ba

File tree

4 files changed

+33
-39
lines changed

4 files changed

+33
-39
lines changed

‎Imagetospeech/Readme.md‎

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,8 @@
44

55
## Image To Speech Functionalities : 🚀
66

7-
- There are two parts :
8-
1) The first script image_to_text.py. In this the user gives the input of the image path
9-
and the script converts the image to text file.
10-
2) The second script text_to_speech.py. This script directly converts the text file of the first
11-
script to speech file or mp3 file.
12-
13-
- The scripts run depending on the user requirement
7+
- The script converts an image to text and speech files
8+
- At the end the script asks whether to save or delete files
149

1510
## Image To Speech Instructions: 👨🏻‍💻
1611

@@ -24,11 +19,7 @@
2419

2520
### Step 3:
2621

27-
Run the command: python image_to_text.py/python3 image_to_text.py 🧐
28-
To convert image to text
29-
30-
Run the command: python text_to_speech.py/python3 text_to_speech.py 🧐
31-
If you want to convert above obtained text file to speech
22+
Run the command: python image_to_speech.py/python3 image_to_speech.py 🧐
3223

3324
### Step 4:
3425

‎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: ')
8+
9+
img = input(r"Enter image: ")
10+
target = Image.open(img)
11+
text = pytesseract.image_to_string(target, config='')
12+
13+
with open(f"./Imagetospeech/Text/text.txt",'w') as f:
14+
f.write(text)
15+
16+
file = open(r'./Imagetospeech/Text/text.txt')
17+
mytext = file.read().replace("\n"," ")
18+
language = 'en'
19+
output = gTTS(text=mytext, lang=language, slow=False)
20+
output.save('./Imagetospeech/sound/imagetospeech.mp3')
21+
file.close()
22+
os.system("start ./Imagetospeech/sound/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/text.txt')
27+
os.remove('./Imagetospeech/sound/imagetospeech.mp3')
28+
29+
elif question=='N'or question=='n':
30+
print("Files saved")

‎Imagetospeech/image_to_text.py‎

Lines changed: 0 additions & 15 deletions
This file was deleted.

‎Imagetospeech/text_to_speech.py‎

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
(0)

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