I am creating a quiz game using Tkinter. I want to use gtts to read a text file which contains question and options. So is there any way to do that? I tried using pyttsx3 but the voice is too robotic and it always says "backslash n" after the end of sentence (basically its a new line). Thank you!
Asked
Active
Viewed 1,595 times
1 Answers
0
the trick is to replace \n or any other character by space .here abc.txt is your text file
from gtts import gTTS
import os
file = open("abc.txt", "r").read().replace("\n", " ")
speech = gTTS(text = str(file),lang='en',slow = False)
speech.save("voice.mp3")
os.system("start voice.mp3")
hope it solves your query. here you can read more

bipin_s
- 455
- 3
- 15
-
Thank You! That helps. Any chance that I can reduce the speed of the voice?? – Harsh R Dec 24 '19 at 17:15
-
@HarshR i think there is no functionality to change speed of voice. only bool values :slow or fast . further reading : https://stackoverflow.com/questions/54178646/python-gtts-is-there-a-way-to-change-the-speed-of-the-speech – bipin_s Dec 25 '19 at 13:24