3

Text-To-Speech with Python Espeak

 3 years ago
source link: https://www.devdungeon.com/content/text-speech-python-espeak
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Text-To-Speech with Python Espeak

Submitted by NanoDano on Sat, 01/30/2016 - 23:14

NOTE: There is a better text-to-speech package that I would recommend for Python. It supports espeak, but also supports native Windows and Mac speech APIs. Check out my Text-to-speech in Python with pyttsx3 tutorial. It also covers how to use English and Russian voices but works in Windows.


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

Advertisement


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK