A Python Script to convert text to speech using Google's text to speech API commonly known as gTTS API.
1.Install the gTTS API using the command given below in the terminal because this API doesn't come with python:
pip install gTTS
1.Import the gTTS API
2.Import OS (this module is imported so that we can play the converted audio)
3.Enter the text to be converted
4.Choose the language in which you want to convert
5.Create the object of gTTS module and pass the following parameters in it:
* slow=False (by doing this it will tell the module that the converted audio will have a high speed)
6.Now, save the converted audio in a mp3 file named "audio.mp3"
7.Play the audio
1. The gTTS API supports languages like English, Hindi, French, Tamil, and many more.
2. We can set the speed of converted audio(fast or slow).
Submitted by Suryansh Mamgain (Suryansh)
Download packets of source code on Coders Packet