Python : Making text to speech converter in Python with pyttsx3 module

Hello Friends,

Today in this article we are going to do some fun. We will translate the string into speech with the help of pyttsx3 module.

So let’s start

First we will download pyttsx3 with pip

pip install pyttsx3

Code : Python program to convert text to speech 

# Importing pyttsx3
Import pyttsx3

# Gets a reference to an engine instance that will use the given driver
engine = pyttsx3.init()

# say method on the engine that passing input text to be spoken
engine = say("Python is awesome")

# run and wait method, it processes the voice commands

Output :

It will say Python is awesome

Saving voice to a file

import pyttsx3

engine = pyttsx3.init()
# Method to save file
engine.save_to_file("Python is awesome", "D:\pyhon1.mp3")



Python mp3 file

Changing speech rate

import pyttsx3

engine = pyttsx3.init()

rate = engine.getProperty('rate')
engine.setProperty('rate', rate+100)

engine.save_to_file("Python is awesome","D:\python2.mp3")


Use cases of text to speech conversion

  • Used for blind people who can’t see but can listen
  • “Text to Speech” option is a very good idea when needing to make sure the information will be communicated correctly.
  • It is used in metros and buses.

For more details on pyttsx3 – you will get all the details in this documentation –

Thank You for reading 📖

Have a nice day!!

You may also like...

2 Responses

  1. Yogesh Meher says:

    Nice article Sayyam!!! Keep it up

  2. Sayyam Sabadra says:

    Thanks uncle

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: