Breaking

header ads

Text to Speech Conversion using Python and gTTS.

This post teaches you how to convert the text in speech. There are various APIs accessible to convert text to speech in python. one among such APIs is that the Google Text to Speech API commonly referred to as the gTTS API. gTTS may be very easy to use tool which converts the text entered, into audio which may be saved as an mp3 file.

The gTTS API supports several languages including English, Hindi, Tamil, French, German and lots of more. The speech is often delivered in anybody of the 2 available audio speeds, fast or slow. However, as of the newest update, it's impossible to vary the voice of the generated audio.

Installation


Installation of gTTS API is necessary for doing this task. Open the command prompt and use the following command to install the gTTS API Package.

pip install gTTS

This code is work on every platform.

Here I'm giving you the code with convert the Text into Speech.

        from gtts import gTTS
        import os
        myText = "Welcome to the Helping Information"
        language = 'en'

        myObj = gTTS(text = myText, lang =language, slow = False)
        myObj.save(Speech.mp3)
        os.system(mpg321 Speech.mp3)


The output of the above code should be the voice saying "Welcome to the Helping Information"

For the practical purpose, you should watch the following video.



Post a Comment

0 Comments