lexicon Element (Microsoft.Speech)
Specifies an external pronunciation lexicon file.
Required. Specifies the location of the pronunciation lexicon, which is a relative URI or an absolute URI.
Optional. Specifies the media type of the pronunciation lexicon document. Two values are currently supported.
A pronunciation lexicon is a collection of words or phrases together with their pronunciations, which consist of letters and characters from a supported phonetic alphabet. You can use lexicons to create custom pronunciations for specialized vocabulary in your application. Pronunciations specified in an external lexicon file take precedence over the pronunciations of the speech synthesizer's internal lexicon or dictionary. However, pronunciations specified inline in prompts using the token Element (Microsoft.Speech) take precedence over pronunciations specified in any lexicon. Inline pronunciations apply only to a single occurrence of a word. For more information, see Lexicons and Phonetic Alphabets (Microsoft.Speech).
The lexicon element is an immediate child of the grammar Element (Microsoft.Speech). In Microsoft.Speech, each grammar document can reference only one lexicon. This is a departure from the Speech Recognition Grammar Specification (SRGS) Version 1.0.
The lexicon element must be placed after the opening tag of the grammar element and before the first rule element in the grammar element.
The pronunciation information provided by a lexicon is specific to the single language declared in the xml:lang attribute of the grammar element, and is used only for content defined within the enclosing SRGS document.
The following grammar specifies a simple PLS lexicon that defines the pronunciation for a single word, "blue". Typically, you would use the sapi:pron attribute of the token Element (Microsoft.Speech) to specify a pronunciation for a single occurrence of a word. However, this example demonstrates how to attach a lexicon to an SRGS grammar and how the pronunciation defined in a lexicon may affect the results of speech recognition. A custom lexicon overrides the pronunciations in the speech recognition engine's internal lexicon and applies to all occurrences of the words it defines.
<?xml version="1.0" encoding="UTF-8"?> <grammar version="1.0" mode="voice" root="colors" xml:lang="en-US" tag-format="semantics/1.0" sapi:alphabet="x-microsoft-ups" xml:base="http://www.contoso.com/" xmlns="http://www.w3.org/2001/06/grammar" xmlns:sapi="http://schemas.microsoft.com/Speech/2002/06/SRGSExtensions"> <lexicon uri="C:\Test\Blue.pls" /> <rule id="colors" scope="public"> <one-of> <item> blue </item> <item> yellow </item> <item> red </item> </one-of> </rule> </grammar>
The following are the contents of the PLS lexicon file Blue.pls. The pronunciation is specified in the phoneme element using characters from the Universal Phone Set (UPS), and corresponds to the word spelling "blee".When this lexicon is linked to an SRGS grammar, as shown above, the speech recognition engine will recognize the speech input "blee", but will return "blue" as the recognized text. This grammar will probably not recognize the speech input "blue". If it does, it will be with much lower confidence than when recognizing the speech input "blee".
<?xml version="1.0" encoding="UTF-8"?> <lexicon version="1.0" xmlns="http://www.w3.org/2005/01/pronunciation-lexicon" alphabet="x-microsoft-ups" xml:lang="en-US"> <lexeme> <grapheme> blue </grapheme> <phoneme> B L I </phoneme> </lexeme> </lexicon>