User dictionaries

You can create application-specific user dictionaries to improve recognition accuracy of words and phrases that are giving you problems—for example, when application users have non-standard or heavily accented pronunciations. You can also create dictionaries that supplement the system dictionary vocabulary by adding terms that may be particular to your application.

Each user dictionary is an XML text file that maps the text to be returned by Recognizer for different user pronunciations, with the pronunciations expressed in a phonemic alphabet. The phonemic alphabet used depends on the language; refer to the Language Supplement in the language pack for details.

Note: Each Language Supplement is located in: %SWISRSDK%\documentation\languages.

You may discover the need for a user dictionary after testing; for example, if the parseTool utility fails to parse your test sentences. A dictionary may also be indicated during early stages of application deployment when you analyze call logs. For example, if you experience many false rejections and unnecessary confirmations, a dictionary can tune pronunciations of problematic words.

Carefully used, the user dictionary is an excellent way to tune pronunciations for an application. However, too much dictionary use frequently reduces accuracy by overriding the system dictionary, which is tuned for high accuracy.

Importing a user dictionary

To import a dictionary, use the <lexicon> element in a main grammar header:

<lexicon uri="http://myuri/my_user_dict.xml"/>

The SRGS specification allows a "type" attribute with <lexicon>, but the specification does not define its contents. Recognizer ignores this property.

You can include SWI properties in the URI after a question mark:

<lexicon uri="user_dict.xml?SWI.type=backup"/>

(For more on the SWI.type parameter, see Dictionary precedence.)

User dictionaries are local to the grammar where they are defined. If two or more grammars are active at one time, each can define different dictionary sets.

You can use the xml:lang attribute to specify the language of the dictionary in the <lexicon> element, though that will already be specified in the dictionary itself.

Format of pronunciation dictionaries

A simple user dictionary file appears below:

<?xml version="1.0" encoding="UTF-8" ?>
<lexicon xml:lang="en-US" 
  alphabet="application/sampa;localization=nuance">
 <entry key="tomato">
  <definition value="t @ m Q t @W" />
  <definition value="t @ m e Y t @W" />
 </entry>
 <entry key="George">
  <definition value="d Z O r d Z" />
 </entry>
 <entry key="record">
  <definition value="r e k @ r d" part="noun" />
  <definition value="r I k O r d" part="verb" />
 </entry>
</lexicon>

The components of the file are described below.

Dictionary precedence

When Recognizer loads a grammar, it also loads needed pronunciations for that grammar. To determine the pronunciations, Recognizer searches for dictionary entries using the following precedence scheme:

  1. Primary dictionaries are searched first. Recognizer searches all of them and loads all the pronunciations found. When you define a user dictionary, it is a primary dictionary by default.
  2. Backup dictionaries are searched when the previous dictionaries have not yielded a match. As with primary dictionaries, there can be more than one backup. By default, the system dictionary is a backup dictionary.
  3. Automatic dictionaries are searched when a pronunciation is not found in primary or backup dictionaries. Recognizer uses text-to-phoneme rules to generate the pronunciation. The diagnostic log reports each instance of a generated pronunciation; it is recommended that you investigating to ensure the pronunciations are correct.

Compiling a user dictionary

To improve runtime performance, you can compile user dictionaries with the make_dict tool. This tool is stored in the %SWISRSDK%\bin directory. The command format is:

make_dict InputDict OutputDict -language LangCode

Where:

  • The InputDict is the input XML dictionary.
  • The OutputDict is the resulting binary dictionary.
  • The LangCode is the default language for the dictionary.

See make_dict.