|
JSAPI 2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectVoice
public class Voice
Describes one output Voice
of a speech Synthesizer
.
Voice
objects can be used in selection of synthesis engines
through SynthesizerMode
.
From the SynthesizerProperties
object
(returned for a Synthesizer
with
the getSynthesizerProperties
method),
the current speaking Voice
of a Synthesizer
can be retrieved using the getVoice
method and
can be changed during operation with the setVoice
method.
Synthesizer
,
SynthesizerMode
,
getSynthesizerProperties
,
SynthesizerProperties
,
getVoice
,
setVoice
Field Summary | |
---|---|
static int |
AGE_CHILD
Constant representing the Voice of a child. |
static int |
AGE_DONT_CARE
Constant that will match with any age. |
static int |
AGE_MIDDLE_ADULT
Constant representing the Voice of a middle-aged adult. |
static int |
AGE_OLDER_ADULT
Constant representing the Voice of an older adult. |
static int |
AGE_SPECIFIC
Constant flag to limit an age value to a single value. |
static int |
AGE_TEENAGER
Constant representing the Voice of a teenager. |
static int |
AGE_YOUNGER_ADULT
Constant representing the Voice of a younger adult. |
static int |
GENDER_DONT_CARE
Ignore gender when performing a match of Voice s. |
static int |
GENDER_FEMALE
Female Voice . |
static int |
GENDER_MALE
Male Voice . |
static int |
GENDER_NEUTRAL
Neutral Voice that is neither male or female. |
static int |
VARIANT_DEFAULT
The default variant for a Voice . |
static int |
VARIANT_DONT_CARE
Ignore the variant when performing a match of Voice s. |
Constructor Summary | |
---|---|
Voice()
Constructs a Voice with locale , name ,
gender , age , and variant
set to "don't care" values. |
|
Voice(SpeechLocale locale,
String name,
int gender,
int age,
int variant)
Constructs a Voice with locale , name ,
gender , age , and variant . |
Method Summary | |
---|---|
boolean |
equals(Object obj)
Returns true if and only if the parameter is not null
and is a Voice with equal values. |
int |
getAge()
Gets the Voice age. |
int |
getGender()
Gets the Voice gender. |
String |
getName()
Gets the Voice name. |
SpeechLocale |
getSpeechLocale()
Gets the Voice SpeechLocale . |
int |
getVariant()
Gets the Voice variant. |
int |
hashCode()
Returns a hash code value for the object. |
boolean |
match(Voice require)
Determines whether this Voice has all the features
defined in the require object. |
String |
toString()
Returns a String representation of this Voice . |
Methods inherited from class Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int GENDER_DONT_CARE
match
of Voice
s.
Synthesizer
s never provide a Voice
with GENDER_DONT_CARE
.
match
,
getGender()
,
Constant Field Valuespublic static final int GENDER_FEMALE
Voice
.
getGender
,
Constant Field Valuespublic static final int GENDER_MALE
Voice
.
getGender
,
Constant Field Valuespublic static final int GENDER_NEUTRAL
getGender
,
Constant Field Valuespublic static final int AGE_DONT_CARE
match
with any age.
Synthesizer
s never return a Voice
with
AGE_DONT_CARE
.
match
,
getAge
,
Constant Field Valuespublic static final int AGE_CHILD
Voice
of a child.
This value will match
ages in the range of 0-12.
match
,
getAge()
,
Constant Field Valuespublic static final int AGE_TEENAGER
Voice
of a teenager.
This value will match
ages in the range of 13-19.
match
,
getAge()
,
Constant Field Valuespublic static final int AGE_YOUNGER_ADULT
Voice
of a younger adult.
This value will match
ages in the range of 20-39.
match
,
getAge()
,
Constant Field Valuespublic static final int AGE_MIDDLE_ADULT
Voice
of a middle-aged adult.
This value will match
ages in the range of 40-59.
match
,
getAge()
,
Constant Field Valuespublic static final int AGE_OLDER_ADULT
Voice
of an older adult.
This value will match
ages starting from 60.
match
,
getAge()
,
Constant Field Valuespublic static final int AGE_SPECIFIC
An age value without this flag indicates a preferred age.
match
,
getAge()
,
Constant Field Valuespublic static final int VARIANT_DONT_CARE
match
of Voice
s.
Synthesizer
s never provide a Voice
with VARIANT_DONT_CARE
.
Variants returned from a Synthesizer
begin
with VARIANT_DEFAULT
.
match
,
getVariant
,
VARIANT_DEFAULT
,
Constant Field Valuespublic static final int VARIANT_DEFAULT
Voice
.
Variants returned from a Synthesizer
begin
with VARIANT_DEFAULT
.
getVariant
,
Constant Field ValuesConstructor Detail |
---|
public Voice()
Voice
with locale
, name
,
gender
, age
, and variant
set to "don't care" values.
Voice(SpeechLocale, String, int, int, int)
public Voice(SpeechLocale locale, String name, int gender, int age, int variant) throws IllegalArgumentException
Voice
with locale
, name
,
gender
, age
, and variant
.
The getGender
method describes valid gender
values.
The getAge
method describes valid age
values.
The variant
must be a positive integer or
VARIANT_DONT_CARE
.
locale
- SpeechLocale
of the Voice
name
- name of the Voice
gender
- gender of the Voice
age
- age of the Voice
variant
- variant of the Voice
IllegalArgumentException
- if an invalid parameter value is suppliedgetSpeechLocale
,
getName
,
getGender
,
getAge
,
getVariant
,
Voice()
Method Detail |
---|
public boolean equals(Object obj)
true
if and only if the parameter is not null
and is a Voice
with equal values.
equals
in class Object
obj
- a Voice
object to compare
true
if the Voice
objects comparepublic int getAge()
Voice
age.
A Voice
from a Synthesizer
instance
returns one of the age range constants or
an age value limited to a specific value with the
AGE_SPECIFIC
flag.
A Voice
created programmatically may return one of the following:
AGE_SPECIFIC
flag representing
a specific age
In all cases, an age value is a non-negative integer representing
an age in years.
The maximum value of age is Short.MAX_VALUE
.
An age value may not be combined with age range constants,
but may be combined with the AGE_SPECIFIC
flag.
Voice
match
,
AGE_DONT_CARE
,
AGE_CHILD
,
AGE_TEENAGER
,
AGE_YOUNGER_ADULT
,
AGE_MIDDLE_ADULT
,
AGE_OLDER_ADULT
,
AGE_SPECIFIC
public int getGender()
Voice
gender.
Gender values may be OR'ed to select or match
a Voice
.
A Voice
from a Synthesizer
instance
returns a specific gender constant.
match
,
GENDER_DONT_CARE
,
GENDER_MALE
,
GENDER_FEMALE
,
GENDER_NEUTRAL
public int getVariant()
Voice
variant.
This can indicate a variation between otherwise identical
Voice
characteristics.
For example, if there are two male child voices then the variant
can be used to select the second one.
If the variant does not matter during Voice
selection,
use VARIANT_DONT_CARE
.
This value will match
any other variant value.
A Voice
from a Synthesizer
instance
returns a specific positive integer.
Variant values begin with VARIANT_DEFAULT
.
Voice
variantmatch
,
VARIANT_DEFAULT
,
VARIANT_DONT_CARE
public String getName()
Voice
name.
May return null
.
A null
or ""
String
in Voice
match
means don't care.
match
public int hashCode()
hashCode
in class Object
public SpeechLocale getSpeechLocale()
Voice
SpeechLocale
.
The SpeechLocale
includes the language, country,
and variant (for the language).
May return null.
A null
for Voice
match
means don't care.
SpeechLocale
for this Voice
match
public boolean match(Voice require)
Voice
has all the features
defined in the require
object.
String
s in require
which are null
are ignored.
All String
comparisons are exact matches (case-sensitive).
A null
SpeechLocale
in the require
object is ignored.
Otherwise, all non-null
String
s in the
require
SpeechLocale
must match.
GENDER_DONT_CARE
, AGE_DONT_CARE
, and
VARIANT_DONT_CARE
values in the require
object are ignored.
Gender constant values may be OR'ed in the require
object to match.
The getGender method lists the gender constants.
The age value of the require
object may be
AGE_SPECIFIC
-
matches only that age
Variant values in the require
object other than
VARIANT_DONT_CARE
must be equal to match.
The following example shows how to test for a male and/or neutral Voice:
Voice aVoice = ...;
Voice maleishVoice =
new Voice(null, null, Voice.GENDER_MALE | Voice.GENDER_NEUTRAL,
Voice.AGE_DONT_CARE, Voice.VARIANT_DONT_CARE);
if (aVoice.match(maleishVoice)) ...
require
- the required features to match this Voice
true
if all the require
d features matchGENDER_DONT_CARE
,
AGE_DONT_CARE
,
AGE_SPECIFIC
,
VARIANT_DONT_CARE
,
getGender
,
getAge
,
getVariant
public String toString()
String
representation of this Voice
.
toString
in class Object
String
representation of this Voice
|
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.