Back to Silas S. Brown's home page
lexconvert: a converter between the lexicon formats of different speech synthesizers
As a person with limited vision, I often use
speech synthesis software to read things.
Some uncommon words (such as names and places
in literature) are frequently pronounced
wrongly by speech synthesizers, but if the
synthesizer has a user-controlled pronunciation
dictionary (lexicon) then this can be used to
correct its pronunciation where
necessary. However, if you move to
a different speech synthesizer, you may find that your
corrections have to be re-done because the
lexicon format is different. This can be
a problem if you have many corrections and/or
don't know the new format.
To help, here is a Python program that
converts between the lexicon formats
of different English speech synthesizers.
It supports the pronunciation notations of
eSpeak, Festival (British version), Cepstral's UK-English voices,
Mac OS X, SAPI, SAMPA, Unicode IPA (used
on an increasing number of websites) and others.
Download lexconvert.py;
usage information is below.
lexconvert v0.1452 - convert between lexicons of different speech synthesizers
(c) 2007-2011 Silas S. Brown. License: GPL
Available pronunciation formats: festival, espeak, sapi, cepstral, mac, x-sampa, acapela-uk, cmu, bbcmicro, unicode-ipa, pinyin-approx
Use --convert <from-format> <to-format> to convert a user lexicon file. Expects Festival's .festivalrc to be in the home directory, or espeak's en_extra or Cepstral's lexicon.txt to be in the current directory.
For InfoVox/acapela, export the lexicon to acapela.txt in the current directory.
E.g.: python lexconvert.py --convert festival cepstral
Use --try <format> <pronunciation> to try a pronunciation with eSpeak (requires 'espeak' command),
e.g.: python lexconvert.py --try festival h @0 l ou1
or: python lexconvert.py --try unicode-ipa '\u02c8\u0279\u026adn\u0329' (for Unicode put '\uNNNN' or UTF-8)
(it converts to espeak format and then uses espeak to play it)
Use --trymac to do the same as --try but with Mac OS 'say' instead of 'espeak'
Use --phones2phones <format1> <format2> <phones in format1> to perform a one-off conversion of phones from format1 to format2.
Use --phones <format> <words> to convert 'words' to phones in format 'format'. espeak will be run to do the text-to-phoneme conversion, and the output will then be converted to 'format'.
E.g.: python lexconvert.py --phones unicode-ipa This is a test sentence.
Note that some commercial speech synthesizers do not work well when driven entirely from phones, because their internal format is different and is optimised for normal text.
Use --syllables <words> to attempt to break 'words' into syllables for music lyrics (uses espeak to determine how many syllables are needed)
Use --festival-dictionary-to-espeak <location> to convert the Festival Oxford Advanced Learners Dictionary (OALD) pronunciation lexicon to ESpeak.
You need to specify the location of the OALD file in <location>,
e.g. for Debian festlex-oald package: python lexconvert.py --festival-dictionary-to-espeak /usr/share/festival/dicts/oald/all.scm
or if you can't install the Debian package, try downloading http://ftp.debian.org/debian/pool/non-free/f/festlex-oald/festlex-oald_1.4.0.orig.tar.gz, unpack it into /tmp, and do: python lexconvert.py --festival-dictionary-to-espeak /tmp/festival/lib/dicts/oald/oald-0.4.out
In all cases you need to cd to the espeak source directory before running this. en_extra will be overwritten. Converter will also read your ~/.festivalrc if it exists. (You can later incrementally update from ~/.festivalrc using the --convert option; the entries from the system dictionary will not be overwritten in this case.) Specify --without-check to bypass checking the existing espeak pronunciation for OALD entries (much faster, but makes a larger file and in some cases compromises the pronunciation quality).
All material © Silas S. Brown unless otherwise stated.