|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.speech.freetts.Voice
Performs text-to-speech using a series of
UtteranceProcessors
. It is the main conduit to the FreeTTS
speech synthesizer. It can perform TTS on ASCII text,
a JSML document, an InputStream
, or a
FreeTTSSpeakable
, by invoking the method speak
.
Before a Voice can perform TTS, it must have a
Lexicon
, from which it gets the vocabulary, and
an AudioPlayer
, to which it sends the synthesized output.
Example (using the CMUDiphoneVoice
,
CMULexicon
and JavaClipAudioPlayer
):
Voice voice = new CMUDiphoneVoice(); // sets the Lexicon voice.setLexicon(new CMULexicon()); // sets the AudioPlayer voice.setAudioPlayer(new JavaClipAudioPlayer()); // loads the Voice voice.allocate(); // start talking voice.speak("I can talk forever without getting tired!");
A user can override the AudioPlayer to use by defining the "com.sun.speech.freetts.voice.defaultAudioPlayer" system property. The value of this property must be the name of a class that implements the AudioPlayer interface, and which also has a no-arg constructor.
VoiceManager
,
VoiceDirectory
Field Summary | |
static java.lang.String |
DATABASE_NAME
Constant that describes the name of the unit database used by this voice. |
static java.lang.String |
DEFAULT_AUDIO_PLAYER
Feature name for the default AudioPlayer class to use. |
static java.lang.String |
DEFAULT_AUDIO_PLAYER_DEFAULT
The default class to use for the DEFAULT_AUDIO_PLAYER. |
static java.lang.String |
FEATURE_JOIN_TYPE
Feature name for the join type string. |
static java.lang.String |
FEATURE_SILENCE
Feature name for the silence phone string. |
static java.lang.String |
PROP_PREFIX
Prefix for System property names. |
Constructor Summary | |
Voice()
Creates a new Voice. |
|
Voice(java.lang.String name,
Gender gender,
Age age,
java.lang.String description,
java.util.Locale locale,
java.lang.String domain,
java.lang.String organization)
Creates a new Voice like above, except that it also stores the properties of the voice. |
Method Summary | |
void |
addFeatureProcessor(java.lang.String name,
FeatureProcessor fp)
Adds a language/voice specific Feature Processor to the set of FeatureProcessors supported by this voice. |
void |
allocate()
Allocate this Voice. |
static OutputQueue |
createOutputThread()
Creates an output thread that will asynchronously output utterances that are generated by this voice (and other voices). |
void |
deallocate()
Shuts down the voice processing. |
void |
dump(java.io.PrintWriter output,
int pad,
java.lang.String title)
Dumps the voice in textual form. |
void |
dumpProcessors(java.io.PrintWriter output,
int pad,
java.lang.String title)
Dumps the voice processors. |
void |
endBatch()
Ends a batch of utterances. |
void |
error(java.lang.String message)
Sends the given error message to stderr and also throws an error exception. |
Age |
getAge()
Get the age of this voice. |
protected abstract UtteranceProcessor |
getAudioOutput()
Returns the AudioOutput processor to be used by this voice. |
AudioPlayer |
getAudioPlayer()
Gets the audio player associated with this voice. |
AudioPlayer |
getDefaultAudioPlayer()
Gets the default audio player for this voice. |
java.lang.String |
getDescription()
Get the description of this voice. |
java.lang.String |
getDomain()
Get the domain of this voice. |
float |
getDurationStretch()
Gets the duration Stretch |
FeatureProcessor |
getFeatureProcessor(java.lang.String name)
Returns a language/voice specific Feature Processor. |
FeatureSet |
getFeatures()
Returns the feature set associated with this voice. |
Gender |
getGender()
Get the gender of this voice. |
Lexicon |
getLexicon()
Gets the lexicon for this voice. |
java.util.Locale |
getLocale()
Get the locale of this voice. |
java.lang.String |
getName()
Get the name of this voice. |
java.lang.String |
getOrganization()
Gets the organization which created this voice. |
OutputQueue |
getOutputQueue()
Returns the output queue associated with this voice. |
java.lang.String |
getPhoneFeature(java.lang.String phone,
java.lang.String featureName)
Given a phoneme and a feature name, returns the feature. |
float |
getPitch()
Retreives the baseline pitch. |
float |
getPitchRange()
Gets the pitch range. |
float |
getPitchShift()
Gets the pitch shift. |
float |
getRate()
Gets the rate of speech. |
protected java.net.URL |
getResource(java.lang.String resource)
Get a resource for this voice. |
java.lang.String |
getRunTitle()
Gets the title for this run. |
java.lang.String |
getStyle()
Gets the voice style. |
abstract Tokenizer |
getTokenizer()
Returns the tokenizer associated with this voice. |
java.util.List |
getUtteranceProcessors()
Return the list of UtteranceProcessor instances. |
float |
getVolume()
Gets the volume. |
java.lang.String |
getWaveDumpFile()
Gets the dumpfile for this voice. |
boolean |
isDetailedMetrics()
Gets the state of the detailedMetrics mode. |
boolean |
isDumpRelations()
Gets the state of the dumpRelations mode. |
boolean |
isDumpUtterance()
Gets the state of the dumpUtterance mode. |
boolean |
isLoaded()
Returns true if this voice is loaded. |
boolean |
isMetrics()
Gets the state of the metrics mode. |
boolean |
isVerbose()
Gets the state of the verbose mode. |
void |
load()
Deprecated. As of FreeTTS 1.2, replaced by allocate() . |
protected abstract void |
loader()
Loads voice specific data. |
void |
log(java.lang.String message)
Prints the given message to System.out if "verbose"
operation is enabled. |
protected java.lang.StringBuffer |
processNode(org.w3c.dom.Node n,
java.lang.StringBuffer buf)
Adds text for just this node and returns any text that might be needed to undo the effects of this node after it is processed. |
void |
processUtterance(Utterance u)
Processes the given Utterance by passing it to each UtteranceProcessor managed by this Voice. |
protected void |
setAge(Age age)
Set the age of this voice. |
void |
setAudioPlayer(AudioPlayer player)
Sets the audio player associated with this voice. |
protected void |
setDescription(java.lang.String description)
Set the description of this voice. |
void |
setDetailedMetrics(boolean detailedMetrics)
Sets the state of the detailedMetrics mode. |
protected void |
setDomain(java.lang.String domain)
Set the domain of this voice. |
void |
setDumpRelations(boolean dumpRelations)
Sets the state of the dumpRelations mode. |
void |
setDumpUtterance(boolean dumpUtterance)
Sets the state of the dumpUtterance mode. |
void |
setDurationStretch(float stretch)
Sets the duration stretch |
protected void |
setGender(Gender gender)
Set the gender of this voice. |
void |
setLexicon(Lexicon lexicon)
Sets the lexicon to be used by this voice. |
protected void |
setLoaded(boolean loaded)
Sets the loaded state |
protected void |
setLocale(java.util.Locale locale)
Set the locale of this voice. |
void |
setMetrics(boolean metrics)
Sets the metrics mode. |
protected void |
setName(java.lang.String name)
Set the name of this voice. |
protected void |
setOrganization(java.lang.String organization)
Sets the organization which created this voice. |
void |
setOutputQueue(OutputQueue queue)
Sets the output queue for this voice. |
void |
setPitch(float hertz)
Sets the baseline pitch. |
void |
setPitchRange(float range)
Sets the pitch range. |
void |
setPitchShift(float shift)
Sets the pitch shift |
void |
setRate(float wpm)
Sets the rate of speech. |
void |
setRunTitle(java.lang.String runTitle)
Sets the title for this run. |
void |
setStyle(java.lang.String style)
Sets the voice style. |
void |
setVerbose(boolean verbose)
Sets the verbose mode. |
void |
setVolume(float vol)
Sets the volume. |
void |
setWaveDumpFile(java.lang.String waveDumpFile)
Sets the dumpfile for this voice. |
boolean |
speak(org.w3c.dom.Document doc)
Speaks the given document. |
boolean |
speak(FreeTTSSpeakable speakable)
Speak the given queue item. |
boolean |
speak(java.io.InputStream inputStream)
Speaks the input stream. |
boolean |
speak(java.lang.String text)
Speaks the given text. |
void |
startBatch()
Starts a batch of utterances. |
java.lang.String |
toString()
Returns the name of this Voice. |
void |
warn(java.lang.String message)
Sends the given warning message to stderr. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String DATABASE_NAME
public static final java.lang.String PROP_PREFIX
public static final java.lang.String FEATURE_SILENCE
public static final java.lang.String FEATURE_JOIN_TYPE
public static final java.lang.String DEFAULT_AUDIO_PLAYER
public static final java.lang.String DEFAULT_AUDIO_PLAYER_DEFAULT
Constructor Detail |
public Voice()
createOutputThread()
public Voice(java.lang.String name, Gender gender, Age age, java.lang.String description, java.util.Locale locale, java.lang.String domain, java.lang.String organization)
name
- the name of the voicegender
- the gender of the voiceage
- the age of the voicedescription
- a human-readable string providing a
description that can be displayed for the users.locale
- the locale of the voicedomain
- the domain of this voice. For example,organization
- the organization which created the voice
"general", "time", or
"weather".Voice()
Method Detail |
public boolean speak(java.lang.String text)
text
- the text to speak
true
if the given text is spoken properly;
otherwise false
public boolean speak(org.w3c.dom.Document doc)
doc
- the JSML document to speak
true
if the given document is spoken properly;
otherwise false
public boolean speak(java.io.InputStream inputStream)
inputStream
- the inputStream to speak
true
if the given input stream is spoken properly;
otherwise false
public boolean speak(FreeTTSSpeakable speakable)
speakable
- the item to speak
true
if the utterance was spoken properly,
false
otherwisepublic void load()
allocate()
.
public void allocate()
createOutputThread()
, if
one is not already created. It then calls the loader()
method to load Voice-specific data, which include utterance processors.
public boolean isLoaded()
true
if the voice is loaded;
otherwise false
protected void setLoaded(boolean loaded)
loaded
- the new loaded state
otherwise false
public void processUtterance(Utterance u) throws ProcessException
processUtterance
in interface UtteranceProcessor
u
- the Utterance to process
ProcessException
- if an exception occurred while performing
operations on the Utterancepublic static OutputQueue createOutputThread()
public abstract Tokenizer getTokenizer()
public java.util.List getUtteranceProcessors()
public FeatureSet getFeatures()
public void startBatch()
endBatch()
public void endBatch()
startBatch()
public void setOutputQueue(OutputQueue queue)
Utterances are placed on the queue to be output by an output thread. This queue is usually created via a call to 'createOutputThread' which creates a thread that waits on the queue and sends the output to the audio player associated with this voice. If the queue is null, the output is rendered in the calling thread.
queue
- the output queuepublic OutputQueue getOutputQueue()
protected abstract void loader() throws java.io.IOException
java.io.IOException
protected java.lang.StringBuffer processNode(org.w3c.dom.Node n, java.lang.StringBuffer buf)
n
- the node to traverse in depth-first orderbuf
- the buffer to append text to
String
containing text to undo the
effects of the nodepublic void dump(java.io.PrintWriter output, int pad, java.lang.String title)
dump
in interface Dumpable
output
- where to send the formatted outputpad
- the initial paddingtitle
- the title to print when dumping outpublic void dumpProcessors(java.io.PrintWriter output, int pad, java.lang.String title)
output
- where to send the formatted outputpad
- the initial paddingtitle
- the title to print when dumping outpublic FeatureProcessor getFeatureProcessor(java.lang.String name)
name
- the name of the processor
public void addFeatureProcessor(java.lang.String name, FeatureProcessor fp)
name
- the name of the processorfp
- the processorpublic void log(java.lang.String message)
System.out
if "verbose"
operation is enabled.
setVerbose(boolean)
,
isVerbose()
public void warn(java.lang.String message)
public void error(java.lang.String message)
public boolean isVerbose()
public void setVerbose(boolean verbose)
verbose
- true if verbose mode should be onpublic boolean isMetrics()
public void setMetrics(boolean metrics)
metrics
- true if metrics mode should be onpublic boolean isDetailedMetrics()
public void setDetailedMetrics(boolean detailedMetrics)
detailedMetrics
- true if detailedMetrics mode should be onpublic boolean isDumpUtterance()
public void setDumpUtterance(boolean dumpUtterance)
dumpUtterance
- true if dumpUtterance mode should be onpublic boolean isDumpRelations()
public void setDumpRelations(boolean dumpRelations)
dumpRelations
- true if dumpRelations mode should be onpublic void setRunTitle(java.lang.String runTitle)
runTitle
- the title for the runpublic java.lang.String getRunTitle()
public java.lang.String getPhoneFeature(java.lang.String phone, java.lang.String featureName)
phone
- the phoneme of interestfeatureName
- the name of the feature of interest
public void deallocate()
public void setPitch(float hertz)
hertz
- the baseline pitch in hertzpublic float getPitch()
public void setPitchRange(float range)
range
- the range in hertzpublic float getPitchRange()
public void setPitchShift(float shift)
shift
- the pitch shift (1.0 is no shift)public float getPitchShift()
public void setDurationStretch(float stretch)
stretch
- the duration stretch (1.0 is no stretch)public float getDurationStretch()
public void setRate(float wpm)
wpm
- words per minutepublic float getRate()
public void setVolume(float vol)
vol
- the volume (0 to 1.0)public float getVolume()
public Lexicon getLexicon()
public void setLexicon(Lexicon lexicon)
lexicon
- the lexicon to usepublic void setWaveDumpFile(java.lang.String waveDumpFile)
waveDumpFile
- the dumpfilepublic java.lang.String getWaveDumpFile()
public void setAudioPlayer(AudioPlayer player)
player
- the audio playerpublic AudioPlayer getDefaultAudioPlayer() throws java.lang.InstantiationException
java.lang.InstantiationException
DEFAULT_AUDIO_PLAYER
,
getAudioPlayer()
public AudioPlayer getAudioPlayer()
getDefaultAudioPlayer()
protected java.net.URL getResource(java.lang.String resource)
protected void setName(java.lang.String name)
name
- the name to assign this voicepublic java.lang.String getName()
public java.lang.String toString()
protected void setGender(Gender gender)
gender
- the gender to assignpublic Gender getGender()
protected void setAge(Age age)
age
- the age to assignpublic Age getAge()
protected void setDescription(java.lang.String description)
description
- the human readable description to assignpublic java.lang.String getDescription()
protected void setLocale(java.util.Locale locale)
locale
- the locale of this voice.public java.util.Locale getLocale()
protected void setDomain(java.lang.String domain)
domain
- the domain of this voice. For example,
"general", "time", or
"weather".public java.lang.String getDomain()
public void setStyle(java.lang.String style)
style
- the stile of this voice.public java.lang.String getStyle()
protected void setOrganization(java.lang.String organization)
organization
- the name of the organizationpublic java.lang.String getOrganization()
protected abstract UtteranceProcessor getAudioOutput() throws java.io.IOException
java.io.IOException
- if an IO error occurs while getting
processor
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |