Coders Packet

Convert Text to Speech Using Python

By Gautam Dhall

In this project we shall learn how to convert the text written by the user into speech or in voice audio using python.

Hello Everyone, in this project you will about how to convert the text written by the user into speech or in audio.

So let's begin.

First of all we need to install text to speech library, which is pyttsx3. This library helps in converting text to speech in python.

If you already have this library installed, good.

If you have not installed you can easily install it by 

1. Go to Command Prompt

2. Type pip install pyttsx3

After installing, we are good to go.

Step 1:

Importing the library

import pyttsx3

Step 2:

We need the text from the user what the user has to convert.

data = input("Enter the sentence which has to be converted : ")

Step 3:

engine = pyttsx3.init()
engine.say(data)
engine.runAndWait()

we have decleared an engine variable that will contain the initial of the pyttsx3 function.

In the next step the program will say the data and the data is stored.

the third and the final step in runAndWait. This act as print function. It will help in running our program and wait till the user command.

 

Full Code!

import pyttsx3
data = input("Enter the sentence which has to be converted : ")
engine = pyttsx3.init()
engine.say(data)
engine.runAndWait()

 

Thank You

Cheers!!

 

Download Complete Code

Comments

No comments yet

Download Packet

Reviews Report

Submitted by Gautam Dhall (gautamdhall5)

Download packets of source code on Coders Packet