Realistic text to speech with Python that doesn’t require internet? [closed]

Try to use pyttsx3 2.5, according the documentation:

gTTS which works perfectly in python3 but it needs internet connection to work since it relies on google to get the audio data.But Pyttsx is completely offline and works seemlesly and has multiple tts-engine support.

Works for Python 2 and 3

To install it:

pip install pyttsx3

Using it should be as simple as:

import pyttsx3
engine = pyttsx3.init()
engine.say("I will speak this text")
engine.runAndWait()

Edit 1 – Changing the voice

To get a less robotic voice you can try to change the voice as follows:

engine.setProperty('voice', voice.id)

To get the available voices

voices = engine.getProperty('voices')

You can try the different available voices as explained in this question: Changing the voice with PYTTSX module in python.

Edit 2 – Selecting speech engine

The library supports the following engines:

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

If espeak is not very natural you can try sapi5 if you are on Windows or nsss if you are on Mac OS X.

You can specify the engine in the init method, e.g.:

pyttsx3.init(driverName="sapi5") 

More info here: http://pyttsx3.readthedocs.io/en/latest/engine.html

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)