Text-To-Speech with Python Espeak

Install espeak and the python-espeak package in Ubuntu with apt-get.

sudo apt-get install espeak python-espeak

Next, download the Russian dictionary pack from http://espeak.sourceforge.net/data/. Download the version that matches your installed version. If you need to check what version you have installed use apt-cache.

apt-cache show espeak

After downloading the zip file, unzip it to get the dictionary file. Move it in to the espeak-data folder and overwrite the existing # and unzip it and replace the existing ru_dict file.

wget http://espeak.sourceforge.net/data/ru_dict-48.zip
unzip ru_dict-48.zip
sudo mv ru_dict-48 /usr/lib/x86_64-linux-gnu/espeak-data/ru_dict

In Python 2, You must specify the encoding in the first or second line to allow Cyrillic Characters.

# -*- coding: utf-8 -*-
from espeak import espeak

espeak.set_voice("ru")

espeak.synth("где хакер")

while espeak.is_playing:
pass