How do I determine when to use a Lexicon?
Last reviewed: 2/1/2012
HOW Article ID: H021201
The information in this article applies to:
- LexiconKit 4
Summary
The goal of lexicon management is to adjust to the end user manner of speaking for enhanced speech recognition accuracy and speech synthesis quality.
It is common for a recognizer to mismatch or a synthesizer to mispronounce phrases such as a person's name, product, part, or location because they are not pronounced phonetically as they are spelled.
To correct this problem, a predefined lexicon of pronunciations can help the recognizer match and synthesizer pronounce phrases correctly.
More Information
For applications where you know the domain of data in advance, you can test and prepare for these situations. You can create a lexicon to deploy with your application for a specific recognizer and/or synthesizer. Here's how:
-
Test grammars and speech recognition contexts in the Chant Developer Workbench using live or recorded audio. Track the results in the Output and Events windows. Identify consistent mismatches as candidate phrases for your application lexicon.
Compile and Test Grammars
Create a grammar with Chant GrammarKit as follows:
Select the File - New menu item or click the Standard toolbar button and select a grammar type to create one in a document window. Note if you do not see any grammar types listed in the menu, then you need to run the Chant Software Unlock utility to begin your evaluation, your GrammarKit evaluation has expired, or you need to register and unlock your licensed copy with a serial number.
Save your new grammar to a file by selecting the File - Save menu item or click the Standard toolbar button. You are prompted to confirm the file name.
A grammar consists of one or more rule elements. You must add at least one valid rule element to a grammar.
To open an existing grammar for editing with Chant GrammarKit, select the File - Open menu item or click the Standard toolbar button and select the grammar file type to launch the open file dialog. Note if you do not see any grammar file types listed in the menu, then you need to run the Chant Software Unlock utility to begin your evaluation, your GrammarKit evaluation has expired, or you need to register and unlock your licensed copy with a serial number.
To compile a grammar, select the Speech - Compile Grammar menu item or click the Speech toolbar button. Compilation messages are displayed in the Output window.
Compiler options may be specified for L&H BNF grammars. With BNF V1.0 grammars, the compiler options are flag values that can be combined. To select more than one option, sum the value of the options and enter in the combobox edit field.
To test the grammar, you must compile, load, and activate it. You may do this in one step by selecting the Speech - Activate Grammar menu item or by clicking the Speech toolbar button. You may say the various combinations of phrases supported by the rule(s). The recognition results are displayed in the Events window.
To test the grammar with a wave file, enter StartRecording $File in the command window and press the Enter key. You are prompted to select a file.
>StartRecording $File
To test the grammar with simulated recognition, enter StartRecording followed by the rule value to test in the command window and press the Enter key.
>StartRecording hello world
When you are finished testing the grammar, you may deactivate it by selecting the Speech - Deactivate Grammar menu item or by clicking the Speech toolbar button.
Create and Test Speech Recognition Context
A speech recognition context is a runtime object comprised of one or more vocabulary resources from which to recognize speech. Some recognizers load context binary instead of grammar binary for runtime efficiency and to support importing and exporting rules across grammars. The steps to create a context with Chant GrammarKit are as follows:
Select the File - New - Speech Recognition Context menu item or click the Standard toolbar button and select Speech Recognition Context to create one in a document window.
-
Select the Speech - Create Context... menu item, click the Speech toolbar button and select the speech engine API for which this context is based, or enter <recocontext and follow the IntelliPrompt suggestions will prompt you for the attribute in the declaration.
Save your new context to a file by selecting the File - Save menu item or click the Standard toolbar button. You are prompted to confirm the file name.
A context consists of one or more vocabulary resource elements. You must add at least one valid vocabulary resource element to a context.
You add vocabulary resources to contexts by adding the resource tag or by using the Add Resource function follows:
-
Select the Speech - Add Resource... menu item or click the Speech toolbar button to display the Add Resource dialog.
-
Select the vocabulary resource type to add to the context.
-
Enter the name (command vocabulary) or browse for the grammar file.
-
Select the grammar syntax of the vocabulary resource.
-
Select the compiler option if applicable.
-
Click the Add Resource button to insert the vocabulary resource declartion in the document.
-
-
Or type <csr in the document window and the IntelliPrompt suggestions will prompt you for the resource type followed by each of the attributes in the declaration.
Chant SpeechKit provides a way for you to test a context without having to write any software. To test the context it must be loaded, and activated.
To open an existing context for editing with Chant GrammarKit, select the File - Open - Speech Recognition Context menu item or click the Standard toolbar button and select Speech Recognition Context to launch the open file dialog.
Grammar resources must be precompiled before activating a context. To compile a grammar vocabulary resource, select the Speech - Compile Grammar menu item or click the Speech toolbar button. Compilation messages are displayed in the Output window.
To test the context, you must activate it. You may do this by selecting the Speech - Activate Context menu item or by clicking the Speech toolbar button. You may say the various combinations of phrases supported by the vocabulary resources. The recognition results are displayed in the Events window.
To test the context with a wave file, enter StartRecording $File in the command window and press the Enter key. You are prompted to select a file.
>StartRecording $File
To test the context with simulated recognition, enter StartRecording followed by the rule value to test in the command window and press the Enter key.
>StartRecording hello world
When you are finished testing the context, you may deactivate it by selecting the Speech - Deactivate Context menu item or by clicking the Speech toolbar button.
-
Create a recognizer lexicon with the targeted phrases and retest with grammars and speech recognition contexts.
Create New Lexicon
A lexicon is a collection of word pronunciations. The steps to create a lexicon with Chant LexiconKit are as follows:
-
Select the File - New menu item or click the Standard toolbar button and select Lexicon to create one in a document window.
-
Select the Speech - Create Lexicon... menu item or click the Speech toolbar button and select Lexicon to launch the create lexicon dialog.
-
Select the speech engine for which this lexicon is based.
-
Enter a unique lexicon name (no spaces).
-
Click the Create button to insert the lexicon declartion in the document.
-
-
Or type <lexicon in the document window and the IntelliPrompt suggestions will prompt you for each of the attributes in the declaration.
A lexicon consists of one or more word pronunciations. You must add at least one valid word pronunciation to a lexicon.
You add words and pronunciations to lexicons by adding the lexiconword tag or by using the Add Word function follows:
-
Select the Speech - Add Word... menu item or click the Speech toolbar button to display the Add Word dialog.
-
Select the speech engine for which this lexicon is based if not already selected.
-
Enter the word to add to the lexicon.
-
Select the part of speech for the word.
-
Click the Add Word button to insert the lexiconword declartion in the document.
-
-
Or type <lexiconword in the document window and the IntelliPrompt suggestions will prompt you for each of the attributes in the declaration.
-
To edit the pronunciation, highlight the pronunciation phonemes and select the Speech - Edit Phonemes... menu item or click the Speech toolbar button to display the Select Phoneme dialog.
-
Select the speech engine for which this lexicon is based if not already selected.
-
Select the desired phoneme.
-
Click the Select Phoneme button to insert the phoneme text in the document.
-
For words with multiple pronunciations, add a <lexiconword> entry for each pronunciation.
To add a word directly from a local lexicon, use the ChantLM AddPronunciation method. See LexiconKit documentation for more information.
-
-
Test TTS playback in the Chant Developer Workbench using the voices targeted for your application. Identify mispronunciations as candidate phrases for your application lexicon.
Testing TTS Playback
Within Chant Developer Workbench, you can open a synthesizer enumerator to perform command line testing and trace callback events. This enables you to model and test your synthesizer use before, during, and after integrating code in your applications.
Use the command line to invoke methods such as synthesizing text from a file or audio file playback. Trace synthesis events in the Events window.
For example, entering StartPlayback "Hello World" is the same as invoking ChantTTS.StartPlayback("Hello World"); in your application software.
Command Line IntelliPrompt: Test component methods with built-in prompts for method signatures. Simply begin typing and pop-ups guide you through parameter specification.
Browse recognition events in the Events window: Analyze event data to determine applicability of callbacks before integrating in applications.
You may control which callback events are fired and displayed in the Events window.
-
Create a synthesizer lexicon with identified phrases and retest with your TTS playback. See the Create New Lexicon section above.
-
Deploy the lexicons with your application and copy to target systems as part of your application installation.
You may export a lexicon as a binary (.dat), a self-extracting .exe file, or text file (.txt Cepstral only) for deployment with the following steps:
-
Open a lexicon document.
-
Select the Speech - Export Lexicon... menu item or click the Speech toolbar button to display the file save dialog.
-
Navigate to the desired directory.
-
Enter the file name for the exported lexicon. Use extension .dat for binary or .exe for self-extracting.
-
Click the Save button to export the lexicon.
-
-
See the Developer Workbench help file section Managing Lexicon for steps to create and edit lexicon pronunciations.
In application scenarios where you don’t know the domain of data in advance or the speech technology that will be present, you might want to support lexicon editing and augmentation as part of your application so user or site customization can be performed. Here's how:
-
Review the Create Lexicon Sample and the Edit Lexicon samples.
Create Lexicon Sample
Chant LexiconKit Developer Edition includes sample applications that illustrate lexicon management features for each of the component library formats. Look in the Samples directory of the component library you are using to locate the sample.
Build and launch the create lexicon sample application.
Create a lexicon using the sample application with the following steps:
- Select a speech engine such as Microsoft Anna.
- Enter a name for the lexicon to create (e.g., MSAnna). Lexicon names should not contain spaces.
- Enter the word such as tomato to add to the lexicon.
- Select the part of speech for the word you entered.
- Press the Add Word button. The sample application generates a default pronunciation and adds it to the lexicon.
- Enter the file name to which to save the lexicon such as msanna.exe. The .exe file extension indicates this lexicon is self-extracting.
- Press the Export Lexicon button to save the lexicon to the file.
Edit Lexicon Sample
Chant LexiconKit Developer Edition includes sample applications that illustrate lexicon management features for each of the component library formats. Look in the Samples directory of the component library you are using to locate the sample.
Build and launch the sample edit lexicon application.
Edit a lexicon using the sample application with the following steps:
- Enter the lexicon file name exported from the create sample. Click the ... button to locate the file in the Create sample directory.
- Select a speech engine associated with this lexicon.
- Press the Get Pronunciations to open and list the words in the lexicon.
- Select a word from the list to display its pronunciations.
- Select the pronunciation listed.
Edit the pronunciation using the sample application with the following steps:
- Highlight the phonemes in the textbox to edit.
- Click the Insert Phonemes button.
- Select the speech engine of the lexicon you are editing.
- Select phonemes from the dialog to edit.
- Press the Select Phoneme dialog button to insert the phonemes into the original pronunciation
Add the pronunciation using the sample application with the following steps:
- Press the the Add button to add the pronunciation list for this word.
- Press the the Save button to export the lexicon to the file and save the new pronunciation.
- Compile and run the applicable samples to become familiar with lexicon management processes: create, edit, export, and import.
- Review the sample code to determine which lexicon management processes you want to incorporate into your own application.
- Integrate the lexicon management code into your application.