Adding or Improving a Language


Considerations Before Preparation

Most of the work doesn’t need any programming knowledge, but, to get immediate feedback, by running and testing eSpeak, you should be able to build it.

You also have to understand the language main concepts, be aware of its features, and have to have patience and attention to detail. Wikipedia is a good source of basic phonetic information, e.g. about [vowels] (http://en.wikipedia.org/wiki/Vowel) and consonants.

In many cases it should be fairly easy to add a rough implementation of a new language, hopefully enough to be intelligible. After that it’s a gradual process of improvement.

Language Tag

The language is identified using the BCP 47 language tag. The list of valid tags originate from various standards and have been combined into the IANA Language Subtag Registry.

These language tags are used to specify the language, such as:

Language Family

The languages are grouped by the closest language family the language belongs. These language families are defined in ISO 639-5. See also Wikipedia’s [List of language families] (https://en.wiktionary.org/wiki/Wiktionary:List_of_families) for more details.

For example, the Celtic languages (Welsh, Irish Gaelic, Scottish Gaelic, etc.) are listed under the cel language family code.

Accent (optional)

If necessary, the language tags are also used to specify the accent or dialect of a language, such as:

Configuration Files

To add new language, you have to create or edit following files:

path/file action
Makefile.am edit
phsource/phonemes edit
phsource/ph_french create
dictsource/fr_list create
dictsource/fr_rules create
dictsource/fr_extra create (optional)
espeak-ng-data/lang/roa/fr create

where:

Makefile.am File

Makefile.am is build configuration file.

Search for configuration of existing languages (e.g. English) and add similar lines for your language in following sections. E.g. for French:

phsource/phonemes.stamp: \
...
  phsource/ph_french \
...

dictionaries: \
...
  espeak-ng-data/fr_dict \
...

fr: espeak-ng-data/fr_dict
dictsource/fr_extra:
  touch dictsource/fr_extra
espeak-ng-data/fr_dict: src/espeak-ng phsource/phonemes.stamp dictsource/fr_list dictsource/fr_rules dictsource/fr_extra
  cd dictsource && ESPEAK_DATA_PATH=$(PWD) LD_LIBRARY_PATH=../src:${LD_LIBRARY_PATH} ../src/espeak-ng --compile=fr && cd ..
...

Note, that you don’t need to add fr_extra reference in the last group, if your language doesn’t have this file.

Phonemes File

Open file phsource/phonemes and add following lines into it, to make it call your new, e.g. ph_french file:

...
phonemetable fr base
include ph_french
...

Language File

E.g. espeak-ng-data/lang/roa/fr is the language file for French. This gives the language name and may set some options.

Each language needs a language file in espeak-ng-data/lang grouped by the language family. The filename of the default voice for a language should be the same as the language code (e.g. fr for French).

The simplest voice file would contain just 2 lines to give the language name (from the IANA Language Subtag Registry and language code, e.g.:

name French
language fr

This language code specifies which phoneme table and dictionary to use (i.e. phonemetable fr and espeak-ng-data/fr_dict) to be used. If needed, these can be overridden by phonemes and dictionary attributes in the voice file. For example you may want to start the implementation of a new language by using the phoneme table of an existing language.

Details of the contents of language files are given in Voices.

Phoneme Definition File

E.g. phsource/ph_french is the phoneme definition file for French. This contains phoneme definitions for the vowels and consonants which the language uses. Usually it will contain mostly vowels. Most consonants will be inherited from the common phoneme definitions in the master phoneme file: phsource/phonemes.

You must first decide on the set of phonemes (vowel and consonant sounds) for the language. These should be defined in a phoneme definition file ph_french, where ph_french is the name of your language. A reference to this file is then included at the end of the master phoneme file, phsource/phonemes, e.g.:

phonemetable fr base
include ph_french

This example defines a phoneme table fr which inherits the contents of phoneme table base. Its contents are found in the file ph_french.

The base phoneme table contains definitions of a basic set of consonants, and also some “control” phonemes such as stress marks and pauses. These are defined in phsource/phonemes. The phoneme table for a language will inherit these, or alternatively it may inherit the phoneme table of another language which in turn inherits the base phoneme table.

The phonemes file for the language defines those additional phonemes which are not inherited (generally the vowels and diphthongs, plus any additional consonants that are needed), or phonemes whose definitions differ from the inherited version (eg. the redefinition of a consonant).

Details of phonemes files are given in Phoneme Tables.

To build the phoneme files, run:

espeak-ng --compile-phonemes

or:

make phsource/phonemes.stamp

For many languages, the consonant phonemes which are already available in eSpeak, together with the available vowel files which can be used to define vowel phonemes, will be sufficient. At least for an initial implementation.

Dictionary Files

There are usually two dictionary files, e.g. for French:

Details of the contents of the dictionary files are given in Dictionary.

The fr_rules and fr_list files are compiled to produce the espeak-ng-data/fr_dict file, which eSpeak uses when it is speaking.

Once the language’s phonemes have been defined, then pronunciation dictionary data can be produced in order to translate the language’s source text into phonemes. This consists of two source files: fr_rules (the spelling to phoneme rules) and fr_list (an exceptions list, and attributes of certain words). The corresponding compiled data file is espeak-ng-data/fr_dict which is produced from the fr_rules and fr_list sources by the command:

espeak-ng --compile=fr

or by:

make fr

Program Code

The behaviour of the eSpeak program is controlled by various options such as:

The function SetTranslator() at the start of the source code file tr_languages.c recognizes the language code and sets the appropriate options. For a new language, you would add its language code and the required options in SetTranslator(). However, this may not be necessary during testing because most of the options can also be set in the voice file in espeak-ng-data/lang (see Voices).

Compiling Rules File for Debugging

When espeak-ng is invoked with -X parameter, it shows more detailed trace of chosen language rules for pronunciation. This trace can show line numbers also, if language is compiled with --compile-debug option.

To do this, go to espeak-ng project root folder, then:

cd dictsource
../src/espeak-ng --compile-debug=en

When invoked in following way:

espeak-ng -ven -X "Test."

It will show:

Translate 'test'
  1  5965:  t [t]

  1  2104:  e [E]

  1  5725:  s [s]

  1  5965:  t [t]

 t'Est

Improving a Language

Listen carefully to the eSpeak voice. Try to identify what sounds wrong and what needs to be improved.

For most of the eSpeak languages, I do not speak or understand the language, and I do not know how it should sound. I can only make improvements as a result of feedback from speakers of that language. If you want to help to improve a language, listen carefully and try to identify individual errors, either in the spelling-to-phoneme translation, the position of stressed syllables within words, or the sound of phonemes, or problems with rhythm and vowel lengths.