from gtts import gTTS # ask for text to speak text = input("enter text to speak: ") # generate tts output = gTTS(text=text, lang="en", tld="co.in") output.save(f"tts.mp3")
Here is what the above code is Doing:
1. We are importing the gTTS module.
2. We are asking the user to input the text to be spoken.
3. We are generating the tts file.
4. We are saving the tts file.