Skip to main content

Python interface for Mary TTS

Project description

A pretty simple HTTP based interface to MaryTTS intended to make using this excellent TTS for waveform and IPA generation as convenient as possible.

Target audience are developers who would like to use MaryTTS as-is for speech synthesis in their Python application on GNU/Linux operating systems.

Constructive comments, patches and pull-requests are very welcome.

Examples

First, imports:

import wave import StringIO from marytts import MaryTTS

english (default) synthesis:

marytts = MaryTTS() wavs = marytts.synth_wav(‘Hello World!’) wav = wave.open(StringIO.StringIO(wavs)) print wav.getnchannels(), wav.getframerate(), wav.getnframes()

result:

1 16000 21520

try a different language:

marytts.locale = ‘de’ marytts.voice = ‘bits3’ wavs = marytts.synth_wav(‘Hallo Welt!’) wav = wave.open(StringIO.StringIO(wavs)) print wav.getnchannels(), wav.getframerate(), wav.getnframes()

result:

1 16000 16760

### List Available Voices

l = marytts.voices

result:

>>> l[0]
['upmc-pierre-hsmm', 'fr', 'male', 'hmm']
>>> l[1]
['dfki-pavoque-neutral-hsmm', 'de', 'male', 'hmm']
>>> l[2]
['cmu-slt-hsmm', 'en_US', 'female', 'hmm']
>>> l[3]
['cmu-rms-hsmm', 'en_US', 'male', 'hmm']
...

### Grapheme to Phoneme (G2P) Conversion

marytts.locale = ‘en_US’ marytts.voice = ‘cmu-rms-hsmm’ cs = marytts.g2p (‘Hello World!’)

result:

>>> cs
"h @ - ' l @U ' w r= l d"

### Synthesize Phonemes

wavs = marytts.synth_wav(“h @ - ‘ l @U ‘ w r= l d”, fmt=’xs’) wav = wave.open(StringIO.StringIO(wavs)) print wav.getnchannels(), wav.getframerate(), wav.getnframes()

result:

1 16000 21520

Requirements

  • Python 2.7

  • MaryTTS server running

License

My own code is LGPLv3 licensed unless otherwise noted in the script’s copyright headers.

Author

Guenter Bartsch <<guenter@zamia.org>>

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py-marytts-0.1.3.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

py_marytts-0.1.3-py2.py3-none-any.whl (6.1 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page