Skip to main content

This is a modified version of python-espeak (previous version here). It is a Python binding over the eSpeak speech synthesizer C library and does not simply make calls to the espeak binary.

Changes

Some highlights of the modifications.

  • File output instead of only playback (espeak.init(playing=False)).
  • Support for multiple instances of speakers (the espeak.Espeak class). They have to take turns and not simultaneously speak.
  • Easily setup multiple callbacks (espeak.add_callback).
  • Wave file content sent through callbacks (for playing=False only since this is how the C library works).
  • Slightly more uniform bindings in some places (espeak.const).
  • Optional start and end position for synthesis.

Unfortunately some of the renamings make this version not backwards compatible. (Maybe this library should be named differently. I will try to contact the original author about that. Their email "rainct ubuntu com" seems defunct.) The big one is that espeak.init() now has to be called before anything else.

Compatibility

This library should (still) work with both Python 2 and 3.

Installation

Requires espeak and its libraries to be installed espeak/speak_lib.h should be in your include path somewhere. Install with

python setup.py install

or python setup.py build to get the library in the build without installation.

Examples

Simple usage

import espeak
espeak.init()
speaker = espeak.Espeak()
speaker.say("Hello world")
speaker.rate = 300
speaker.say("Faster hello world")

See espeak.const['parameter'] for all the values other than rate that can be changes.

Callback usage

def print_callback(*args):
    print args

import espeak
espeak.init()
speaker = espeak.Espeak()
speaker.add_callback(print_callback)
speaker.say("Hello world")

This should print something like

('', 2, 1, 0, 0, None)
('', 0, 1, 0, 0, None)
('', 1, 1, 5, 0, None)
('', 0, 1, 5, 0, None)
('', 1, 7, 5, 0, None)
('', 0, 7, 5, 0, None)
('', 5, 11, 0, 0, None)
('', 0, 11, 0, 0, None)

Callback format

The arguments of callback functions are wave_file_fragment, event, current_pos, length, num_samples, name.

  • event can be reverse looked up in (or compare to) espeak.const['event'].
  • wave_file_fragment is a piece of a wave file (only in playback=False mode, otherwise its always the empty string).
  • current_pos is event->text_position from speak_lib the C library
  • length is event->length from speak_lib
  • num_samples is event->length from speak_lib
  • name is either
    • (event->id).name for play and mark events,
    • event->id.number (for sample_rate events) or
    • None otherwise.

Licence

GPL v3. See COPYING for full text.

Metadata

Release files for python-espeak 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-espeak 0.6.3
File Size Uploaded
python-espeak-0.6.3.tar.gz 9.1 kB Details

Release files / python-espeak-0.6.3.tar.gz

Download URL python-espeak-0.6.3.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8bef6a647227693630fbe0d89f4aaaae6c984c543bdb3ee747447b512c4c2436
BLAKE2b-256 checksum
How to use checksums
595b45437090dbd71ee9f586dc7f650c6e8c4815bd8bff9b2923d4db5b9120ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

0.6.3 This release

1 release file

0.6.2

1 release file

0.6

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page