Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

Interface javax.speech.recognition.DictationGrammar


public abstract interface DictationGrammar
extends Grammar
Provides access to the dictation capabilities of a Recognizer. If a recognizer supports dictation, it provides a DictationGrammar which is obtained through the getDictationGrammar method of the Recognizer.

A DictationGrammar is named with the same convention as a RuleGrammar and will typically reflect the language and domain it supports. The grammar name is obtained through the Grammar.getName method. For example, the general general dictation for US English from Acme speech company might be called:

      com.acme.dictation.english.us.general
A DictationGrammar is characterized by: A dictation grammar is built into a recognizer (if supported). Moreover, a recognizer provides a single dictation grammar. Applications cannot create or directly modify the grammar beyond the relatively simple methods provided by this interface. By comparison, an application can change any part of a RuleGrammar. (Some vendors provide tools for constructing dictation grammars, but these tools operate separate from the Java Speech API.)

A recognizer that supports dictation:

DictationGrammar Extends Grammar

The DictationGrammar interface extends the Grammar interface. Thus, a DictationGrammar provides all the Grammar functionality:

Context

Dictation recognizers can use the current textual context to improve recognition accuracy. Applications should use either of the setContext methods to inform the recognizer each time the context changes. For example, when editing this sentence with the cursor after the word "sentence", the preceding context is "When editing this sentence" and the following context is "with the cursor after...". Any time the text context changes, the application should inform the recognizer.

Applications should provide a minimum of 3 or 4 words of context (when it's available). Different recognizers process context differently. Some recognizers can take advantage of several paragraphs of context others look only at a few words.

One form of setContext takes one string each for preceding and following context (as in the example above). The other form of setContext takes an array each of strings for preceding and following context. Arrays should be provided if the surrounding context is made of tokens from previous recognition results. When possible, providing tokens is the preferred method because recognizers are able to use token information more reliably and more efficiently.

Word Lists

Words can be added to and removed from the DictationGrammar using the addWord and removeWord methods. Lists of the added and removed words are available through the listAddedWords and listRemovedWords methods. In a speaker-adaptive system (SpeakerManager supported) word data is stored as part of the speaker's data.

Adding a word allows a recognizer to learn new words. Removing a word is useful when a recognizer consistently misrecognizes similar sounding words. For example, if each time a user says "grammar", the recognizer hears "grandma", the user can remove grandma (assuming they don't want to use the word "grandma").

See Also:
SpeakerManager, Recognizer, Grammar

Method Summary
void addWord(String word)
          Add a word to the DictationGrammar.
String[] listAddedWords()
          List the words that have been added to the DictationGrammar.
String[] listRemovedWords()
          List the words that have been removed from the DictationGrammar.
void removeWord(String word)
          Remove a word from the DictationGrammar.
void setContext(String preceding, String following)
          Provide the recognition engine with the current textual context.
void setContext(String[] preceding, String[] following)
          Provide the recognition engine with the current textual context with arrays of the previous and following tokens.
 

Method Detail

setContext

public void setContext(String preceding,
                       String following)
Provide the recognition engine with the current textual context. Dictation recognizers use the context information to improve recognition accuracy. (Context is discussed above.)

When dictating a sequence of words, the recognizer updates its context. The app does not need to inform the recognizer when results arrive. Instead it should call setContext for events such as cursor movement, cut, paste etc.

The preceding or following context may be null if there is no preceding or following context. This is appropriate for a new document or in situations where context is not clear.

The alternative setContext, that accepts arrays of tokens for context, should be used when the current context includes tokens from previous results.

See Also:
setContext(String[], String[])

setContext

public void setContext(String[] preceding,
                       String[] following)
Provide the recognition engine with the current textual context with arrays of the previous and following tokens. Dictation recognizers use the context information to improve recognition accuracy. (Context is discussed above.)

When dictating a sequence of words, the recognizer updates its context. The app does not need to inform the recognizer when results arrive. Instead it should call setContext for events such as cursor movement, cut, paste etc.

The preceding or following context may be null if there is no preceding or following context. This is appropriate for a new document or in situations where context is not clear.

See Also:
setContext(String, String)

addWord

public void addWord(String word)
Add a word to the DictationGrammar. The addWord method can undo the effects of an removeWord call.

A change in a DictationGrammar is applied to the recognition process only after changes have been committed.

See Also:
commitChanges

removeWord

public void removeWord(String word)
Remove a word from the DictationGrammar. The removeWord method can undo the effects of an addWord call.

A change in a DictationGrammar is applied to the recognition process only after changes have been committed.

See Also:
commitChanges

listAddedWords

public String[] listAddedWords()
List the words that have been added to the DictationGrammar.

listRemovedWords

public String[] listRemovedWords()
List the words that have been removed from the DictationGrammar.

Overview | Package | Class | Tree | Index | Help
PREV CLASS | NEXT CLASS FRAMES  | NO FRAMES
SUMMARY:  INNER | FIELD | CONSTR | METHOD DETAIL:  FIELD | CONSTR | METHOD

JavaTM Speech API
Copyright 1997-1998 Sun Microsystems, Inc. All rights reserved
Send comments to javaspeech-comments@sun.com