JSAPI 2.0

javax.speech
Class Word

Object
  extended by Word

public class Word
extends Object

Provides a standard representation of words used by speech Engines. A Word object provides the following information:

The written-form text must be specified. The other properties are optional and are hints to the speech Engine.

Typically, one of the optional properties is specified. If more than one is specified, they are considered in the following precedence order from most to least specific:

  1. Audio
  2. Pronunciation
  3. Spoken-form text
  4. Written-form text
Each of these are considered in the context of the SpeechLocale.

The Word class allows the specification of multiple pronunciations and multiple grammatical categories. If supplied, pronunciations must be appropriate to each category. Otherwise, separate Word objects should be created. For example, consider the different verb and noun pronunciations in "they will record a record".

Words are added through the VocabularyManager. In some applications, the pronunciation may be derived through acoustics and the written-form text may be less useful than the pronunciation. In this case, the Word may be created with the ACOUSTIC category.

See Also:
VocabularyManager, getVocabularyManager, ACOUSTIC

Field Summary
static long ABBREVIATION
          Grammatical category of Word is an abbreviation or acronym.
static long ACOUSTIC
          Grammatical category of Word is an acoustically-derived pronunciation.
static long ADJECTIVE
          Grammatical category of Word is adjective.
static long ADVERB
          Grammatical category of Word is adverb.
static long AUXILIARY
          Grammatical category of Word is auxiliary.
static long CARDINAL
          Grammatical category of Word is cardinal.
static long CONJUNCTION
          Grammatical category of Word is conjunction.
static long CONTRACTION
          Grammatical category of Word is contraction.
static long DETERMINER
          Grammatical category of Word is determiner.
static long DONT_CARE
          Grammatical category of Word doesn't matter.
static long NOUN
          Grammatical category of Word is noun.
static long OTHER
          Grammatical category of Word not otherwise specified.
static long PREPOSITION
          Grammatical category of Word is preposition.
static long PRONOUN
          Grammatical category of word is pronoun.
static long PROPER_ADJECTIVE
          Grammatical category of Word is proper adjective.
static long PROPER_NOUN
          Grammatical category of Word is proper noun.
static long UNKNOWN
          Grammatical category of Word is unknown.
static long VERB
          Grammatical category of Word is verb.
 
Constructor Summary
Word(String text, String[] pronunciations, String spokenForm, AudioSegment audioSegment, long categories)
          Constructs a Word object.
Word(String text, String[] pronunciations, String spokenForm, AudioSegment audioSegment, long categories, SpeechLocale locale)
          Constructs a Word object with SpeechLocale information.
 
Method Summary
 AudioSegment getAudioSegment()
          Gets the AudioSegment for this Word.
 long getCategories()
          Gets the categories of this Word.
 String[] getPronunciations()
          Gets the pronunciations of this Word.
 SpeechLocale getSpeechLocale()
          Gets the Word SpeechLocale.
 String getSpokenForm()
          Gets the spoken-form text of this Word.
 String getText()
          Gets the written-form text of this Word.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final long UNKNOWN
Grammatical category of Word is unknown. This value implies that no other category flag is set.

See Also:
getCategories, Constant Field Values

DONT_CARE

public static final long DONT_CARE
Grammatical category of Word doesn't matter.

See Also:
getCategories, Constant Field Values

OTHER

public static final long OTHER
Grammatical category of Word not otherwise specified.

See Also:
getCategories, Constant Field Values

NOUN

public static final long NOUN
Grammatical category of Word is noun. English examples: "car", "house", "elephant".

See Also:
getCategories, Constant Field Values

PROPER_NOUN

public static final long PROPER_NOUN
Grammatical category of Word is proper noun. English examples: "Yellowstone", "Singapore".

See Also:
getCategories, Constant Field Values

PRONOUN

public static final long PRONOUN
Grammatical category of word is pronoun. English examples: "me", "I", "they".

See Also:
getCategories, Constant Field Values

VERB

public static final long VERB
Grammatical category of Word is verb. English examples: "run", "debug", "integrate".

See Also:
getCategories, Constant Field Values

ADVERB

public static final long ADVERB
Grammatical category of Word is adverb. English examples: "slowly", "loudly", "barely", "very", "never".

See Also:
getCategories, Constant Field Values

ADJECTIVE

public static final long ADJECTIVE
Grammatical category of Word is adjective. English examples: "red", "mighty", "very", "first", "eighteenth".

See Also:
getCategories, Constant Field Values

PROPER_ADJECTIVE

public static final long PROPER_ADJECTIVE
Grammatical category of Word is proper adjective. English examples: "British", "Brazilian".

See Also:
getCategories, Constant Field Values

AUXILIARY

public static final long AUXILIARY
Grammatical category of Word is auxiliary. English examples: "have", "do", "is", "shall", "must", "cannot".

See Also:
getCategories, Constant Field Values

DETERMINER

public static final long DETERMINER
Grammatical category of Word is determiner. English examples: "the", "a", "some", "many", "his", "her".

See Also:
getCategories, Constant Field Values

CARDINAL

public static final long CARDINAL
Grammatical category of Word is cardinal. English examples: "one", "two", "million".

See Also:
getCategories, Constant Field Values

CONJUNCTION

public static final long CONJUNCTION
Grammatical category of Word is conjunction. English examples: "and", "or", "since", "if".

See Also:
getCategories, Constant Field Values

PREPOSITION

public static final long PREPOSITION
Grammatical category of Word is preposition. English examples: "of", "for".

See Also:
getCategories, Constant Field Values

CONTRACTION

public static final long CONTRACTION
Grammatical category of Word is contraction. English examples: "don't", "can't".

See Also:
getCategories, Constant Field Values

ABBREVIATION

public static final long ABBREVIATION
Grammatical category of Word is an abbreviation or acronym. English examples: "Mr.", "USA".

See Also:
getCategories, Constant Field Values

ACOUSTIC

public static final long ACOUSTIC
Grammatical category of Word is an acoustically-derived pronunciation. This is not a true grammatical category, but provides information useful for deciding how to use this Word.

In this case, the pronunciation is more useful than the written-form text. For example, the written-form text might be "<NameDialerEntry3>", but the pronunciation might represent "Bill Smith".

See Also:
getText, getPronunciations, getAudioSegment, getCategories, Constant Field Values
Constructor Detail

Word

public Word(String text,
            String[] pronunciations,
            String spokenForm,
            AudioSegment audioSegment,
            long categories)
     throws IllegalArgumentException
Constructs a Word object. This constructor uses null for SpeechLocale.

The Word constructor with the SpeechLocale parameter provides more details.

Parameters:
text - the written-form text of the Word
pronunciations - a set of pronunciations for the Word
spokenForm - the spoken-form text of the Word
audioSegment - a recorded AudioSegment for the Word
categories - grammatical categories for this Word
Throws:
IllegalArgumentException - if the written-form text is null
See Also:
Word(String, String[], String, AudioSegment, long, SpeechLocale)

Word

public Word(String text,
            String[] pronunciations,
            String spokenForm,
            AudioSegment audioSegment,
            long categories,
            SpeechLocale locale)
     throws IllegalArgumentException
Constructs a Word object with SpeechLocale information. This information can improve the performance of speech Engines.

The written-form text represents the Word visually and must be specified. All other values may be null (or UNKNOWN for categories).

The locale parameter specifies the SpeechLocale of this Word. It may be null or partially specified. See getSpeechLocale for details.

The preamble defines a precedence order for Engines using the different kinds of information.

Parameters:
text - the written-form text of the Word
pronunciations - a set of pronunciations for the Word
spokenForm - the spoken-form text of the Word
audioSegment - a recorded AudioSegment for the Word
categories - grammatical categories for this Word
locale - the SpeechLocale of this Word
Throws:
IllegalArgumentException - if the written-form text is null
See Also:
getText, getPronunciations, getSpokenForm, getAudioSegment, getCategories, getSpeechLocale, UNKNOWN
Method Detail

getAudioSegment

public AudioSegment getAudioSegment()
Gets the AudioSegment for this Word. The value may be null if it is not available.

Audio may be available for the Word in speaker dependent systems or when the pronunciation is derived from audio.

The audio may be used as feedback to the user.

Returns:
the AudioSegment for this Word
See Also:
ACOUSTIC

getCategories

public long getCategories()
Gets the categories of this Word. Value may be UNKNOWN or an OR'ed set of the categories defined by this class. For example, a Word may be classified as both a noun and a verb:
 Word w = new Word("running", null, null, null, Word.NOUN | Word.VERB);
 
The category information is a guide to the Word's grammatical role. Engines can use this information to improve performance in areas such as accuracy, phrasing and accenting.

Returns:
the set of categories for this Word
See Also:
ABBREVIATION, ACOUSTIC, ADJECTIVE, ADVERB, AUXILIARY, CARDINAL, CONJUNCTION, CONTRACTION, DETERMINER, DONT_CARE, NOUN, OTHER, PREPOSITION, PRONOUN, PROPER_ADJECTIVE, PROPER_NOUN, VERB, UNKNOWN

getPronunciations

public String[] getPronunciations()
Gets the pronunciations of this Word. The pronunciation Strings use the Unicode IPA subset. Returns null if no pronunciations were specified.

Speech Engines should handle most words of the language they support. However, providing pronunciations with Words can provide missing information and improve Engine performance in cases such as domain-specific or foreign words.

Returns:
the pronunciations of this word
See Also:
ACOUSTIC

getSpokenForm

public String getSpokenForm()
Gets the spoken-form text of this Word. Returns null if the spoken-form text is not defined.

The spoken-form text of a Word is useful for mapping the written-form text to words that are likely to be handled by a speech Engine. The following examples show corresponding written- and spoken-form text:

Returns:
the spoken-form text of this Word
See Also:
getText

getText

public String getText()
Gets the written-form text of this Word. The written-form text represents the Word visually.

Returns:
the written-form text of this Word
See Also:
getSpokenForm

getSpeechLocale

public SpeechLocale getSpeechLocale()
Gets the Word SpeechLocale. The SpeechLocale includes the language, country, and variant (for the language).

If partially specified, an Engine uses the most complete match from among possible Word choices. The SpeechLocale may be null to more conveniently support mono-lingual Engines.

Returns:
the SpeechLocale for this Word

JSAPI 2.0

JavaTM Speech API 2.0, Final Release v2.0.6.
© 2008, Conversay and Sun Microsystems.

Free Web Hosting