RK

rajan

Founder & Programmer at HackersFriend March 27, 2020, 4:47 p.m. ⋅ 619 views

Python - Text to Speech by using pyttsx3


pyttsx3 is python library for text-to-speech. It works offline and is very easy to use. It s compatible with both Python 2 and 3.  In this article I'll show you how to use for text-to-speech.

On windows, It uses follwing TTS engines as per OS:

  • sapi5 – SAPI5 on Windows
  • nsss – NSSpeechSynthesizer on Mac OS X
  • espeak – eSpeak on every other platform

On windows, there are 2 voices, one is male and another is female. You can switch between them.

Let's install all required libraries first:

pip install pypiwin32

 

pip install -U pyttsx3==2.71

 

Now, here is how to write your first text-to-speech program:

import pyttsx3 

# get an engine instance
engine = pyttsx3.init() 

# Pass what we want it to say
engine.say('Hello buddy. Welcome to HackersFriend')

# run and wait method, it processes it
engine.runAndWait() 

After runnig this, you system should speak "Hello buddy. Welcome to HackersFriend".

 



Go back to feed

HackersFriend Updates





View more


Events


Nov. 28, 2018, 5:30 p.m.

Python from zero to hero

place Delhi

View details


Aug. 13, 2018, 5:30 p.m.

Python from zero to hero

place Bangalore ( HackersFriend office BTM Layout)

View details