|
JSAPI 2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface VocabularyManager
Interface for management of Word
s used by a speech Engine
.
The VocabularyManager
for an Engine
is returned by the
getVocabularyManager
method of the Engine
interface.
Engine
s are not required support a VocabularyManager
-
the getVocabularyManager
method may return null
.
Word
s, corresponding to normal words in written text,
are provided to the VocabularyManager
with optional information about their spoken form,
grammatical role, pronunciation, and audio pronunciation.
The VocabularyManager
typically provides a speech Engine
with
information on problematic words - usually words for which the Engine
is unable to properly derive a pronunciation.
The getPronunciations
method provides a way to test pronunciations
for debugging purposes.
Example uses include adding pronunciations for medical terms,
pronunciations for game terminology (e.g. "Klingon"
), or
simply compensating for a very small dictionary.
Word
s in the VocabularyManager
can improve
the accuracy of recognition and affect the quality of synthesis.
Engine
,
getVocabularyManager
,
Word
,
getPronunciations
Method Summary | |
---|---|
void |
addWord(Word word)
Adds a Word to this VocabularyManager . |
void |
addWords(Word[] words)
Adds an array of Word s to this VocabularyManager . |
String[] |
getPronunciations(String text,
SpeechLocale locale)
Returns the pronunciations corresponding to plain text for
the given locale . |
Word[] |
getWords(String text,
SpeechLocale locale)
Returns Word s matching the specified
written-form text and locale . |
void |
removeWord(Word word)
Removes a Word from the VocabularyManager . |
void |
removeWords(Word[] words)
Removes an array of Word s from the VocabularyManager . |
Method Detail |
---|
void addWord(Word word) throws EngineStateException, SecurityException
Word
to this VocabularyManager
.
Word
s added by the application take priority over words
with the same written-form text already known
to an Engine
internally.
Word
s added multiple times with the same written-form text
are considered in order of addition with the most recent having
highest priority.
In this case, the Engine
may use one or more
of the pronunciations.
Added Word
s remain for the lifetime
of the VocabularyManager
.
However, they may be removed by the removeWord
method.
Subsequent use of the corresponding written-form text will
behave as it did before the Word
was added
to the VocabularyManager
.
word
- a Word
object to add
EngineStateException
- when not in the standard Conditions for Operation
SecurityException
- if the application does not have permissionaddWords(Word[])
,
removeWord
javax.speech.VocabularyManager.update
void addWords(Word[] words) throws EngineStateException, SecurityException
Word
s to this VocabularyManager
.
The addWord(Word)
method provides additional detail.
words
- an array of Word
objects to add
EngineStateException
- when not in the standard Conditions for Operation
SecurityException
- if the application does not have permissionaddWord(Word)
javax.speech.VocabularyManager.update
String[] getPronunciations(String text, SpeechLocale locale) throws EngineStateException
text
for
the given locale
.
The returned pronunciations use the
International Phonetic Alphabet subset of Unicode.
An empty array is returned if pronunciations cannot be provided.
This method provides access to pronunciations that will be used. Pronunciations are determined as follows:
Word
s that match and include pronunciations
The input text
is expected to be simple plain text
(for example, a word or short phrase that may be found in a lexicon).
The text
is not expected to contain any markup or
punctuation between words such as periods or commas.
The text
may contain characters such as hyphens and apostrophes
where expected within words.
The locale
parameter specifies the SpeechLocale
of this Word
.
It may be null
or partially specified.
The description of getSpeechLocale
provides more detail.
Limited lexical text normalization is performed on the text
.
For example, the input "100"
may result in the pronunciations
corresponding to "one hundred"
.
text
- plain text for the requested pronunciationslocale
- the requested SpeechLocale
text
or an empty array
EngineStateException
- when not in the standard Conditions for OperationgetSpeechLocale
,
getPronunciations
,
getSupportsLetterToSound
Word[] getWords(String text, SpeechLocale locale) throws EngineStateException
Word
s matching the specified
written-form text
and locale
.
Returns a zero-length array if there are no matches.
The text
and locale
parameters are compared with the
corresponding written-form text and SpeechLocale
of each Word
.
null
text
and locale
parameters are
ignored in matching.
If the locale
parameter is non-null
,
all String
s in the locale
must match each returned Word
.
This method only returns Word
s that have been added by the
addWord
or addWords
methods -
it does not provide access to the Engine
's internal lexicon
or pronunciations.
text
- requested written-form textlocale
- requested SpeechLocale
Word
objects
EngineStateException
- when not in the standard Conditions for OperationgetText
,
getSpeechLocale
,
addWord
,
addWords
,
getPronunciations
void removeWord(Word word) throws EngineStateException, IllegalArgumentException, SecurityException
Word
from the VocabularyManager
.
Only Word
s added with addWord
or addWords
may be removed.
Subsequent use of the corresponding written-form text
by an Engine
will behave as it did before the Word
was added to the VocabularyManager
.
word
- a Word
object to remove
EngineStateException
- when not in the standard Conditions for Operation
IllegalArgumentException
- if Word
is not known to the
VocabularyManager
.
SecurityException
- if the application does not have permissionremoveWords(Word[])
,
addWord
,
addWords
javax.speech.VocabularyManager.update
void removeWords(Word[] words) throws EngineStateException, IllegalArgumentException, SecurityException
Word
s from the VocabularyManager
.
The removeWord(Word)
method provides additional detail.
To remove a set of words for a given written-form text it is often useful to also use getWords:
removeWords(getWords("matching", null));
words
- an array of Word
s to remove
EngineStateException
- when not in the standard Conditions for Operation
IllegalArgumentException
- a Word is not known to the VocabularyManager.
SecurityException
- if the application does not have permissionremoveWord(Word)
,
getWords
javax.speech.VocabularyManager.update
|
JSAPI 2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaTM Speech API 2.0,
Final Release v2.0.6.
© 2008, Conversay and Sun Microsystems.