Text to speech converter in python

Text to speech converter in python

There are several APIs available to convert text to speech in python. One of such APIs is the google text to speech API commonly known as the gTTS API .gTTS is a very easy to use tool which converts the text entered, into audio which can be saved as a mp3 file.

The gTTS API supports several languages including English, Hindi, Tamil, French, German and many more. the speech can be delivered in any one of the two available audio speeds, fast or slow. however, as of the update, it is not possible to change the voice of the generated audio.

Installation

1.TO install the gTTS API, open terminal and write

pip install gTTS

2. Python

How to convert text to speech with python using the gTTS Library
  1. Install the gTTS library
  2. Import the required libraries
  3. Create the text-to-speech conversion function
  4. Test the text-to-speech conversion function
  5. Customize the text-to-speech conversion
    import pyttsx3
    engine = pyttsx3.init()
    voices = engine.getproperty('voices')
    engine.setproperty('voice',voices[1].id)
    
    engine.setproperty('rate',150)
    engine.say("Hello, How are you?")
    engine.runAndwait()
    output:
    
    Hello, How are you

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top