|
10 | 10 | target = Image.open(img)
|
11 | 11 | text = pytesseract.image_to_string(target, config='')
|
12 | 12 |
|
13 | | -with open(f"./Imagetospeech/Text/text.txt",'w') as f: |
| 13 | +with open(f"./Imagetospeech/text.txt",'w') as f: |
14 | 14 | f.write(text)
|
15 | 15 |
|
16 | | -file = open(r'./Imagetospeech/Text/text.txt') |
| 16 | +file = open(r'./Imagetospeech/text.txt') |
17 | 17 | mytext = file.read().replace("\n"," ")
|
18 | 18 | language = 'en'
|
19 | 19 | output = gTTS(text=mytext, lang=language, slow=False)
|
20 | | -output.save('./Imagetospeech/sound/imagetospeech.mp3') |
| 20 | +output.save('./Imagetospeech/imagetospeech.mp3') |
21 | 21 | file.close()
|
22 | | -os.system("start ./Imagetospeech/sound/imagetospeech.mp3") |
| 22 | +os.system("start ./Imagetospeech/imagetospeech.mp3") |
23 | 23 |
|
24 | 24 | question = input("Do you want to delete the files (Y/N): ")
|
25 | 25 | if question=='Y'or question=='y':
|
26 | | - os.remove('./Imagetospeech/Text/text.txt') |
27 | | - os.remove('./Imagetospeech/sound/imagetospeech.mp3') |
| 26 | + os.remove('./Imagetospeech/text.txt') |
| 27 | + os.remove('./Imagetospeech/imagetospeech.mp3') |
28 | 28 |
|
29 | 29 | elif question=='N'or question=='n':
|
30 | 30 | print("Files saved")
|
0 commit comments