Overview | Package | Class | Tree | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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.generalA
DictationGrammar
is characterized by:
RuleGrammar
.
(Some vendors provide tools for constructing dictation grammars,
but these tools operate separate from the Java Speech API.)
A recognizer that supports dictation:
true
for the
RecognizerModeDesc.isDictationGrammarSupported
method
This value can be used to select a dictation recognizer.
SpeakerManager
interface).
The DictationGrammar
interface extends the
Grammar
interface. Thus, a DictationGrammar
provides all the Grammar
functionality:
Grammar.getName
method.
setEnabled
method inherited from Grammar
.
setActivationMode
method of Grammar
.
Note: a DictationGrammar
should never
have GLOBAL
activation mode.
Grammar
is tested by the isActive
method and the
GRAMMAR_ACTIVATED
and
GRAMMAR_DEACTIVATED
events.
Grammar.addGrammarListener
and
Grammar.removeGrammarListener
methods.
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").
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 |
public void setContext(String preceding, String following)
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.
public void setContext(String[] preceding, String[] following)
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.
public void addWord(String word)
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.
public void removeWord(String word)
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.
public String[] listAddedWords()
DictationGrammar
.public String[] listRemovedWords()
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