public class VoiceEngine
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) VoiceEngine |
briefExample |
(package private) javax.speech.synthesis.SpeakableListener |
optionalListener |
(package private) javax.speech.synthesis.Synthesizer |
synthesizer |
Constructor and Description |
---|
VoiceEngine() |
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
ageToString(int age)
Helper method to convert age constants to strings
|
private void |
allocateSynthesizer()
The allocate method may take significant time to return depending on the
size and capabilities of the selected synthesizer.
|
private void |
createSynthesizer(javax.speech.synthesis.SynthesizerModeDesc modeDesc)
create a synthesiser with the required properties.
|
private void |
deallocateSynthesizer()
deallocate the synthesizer.
|
private void |
exit(java.lang.Exception e)
Helper method to ensure the synthesizer is always deallocated before
existing the VM.
|
private java.lang.String |
genderToString(int gender)
Helper method to convert gender constants to strings
|
private boolean |
isModeGeneral()
is the selected synthesizer capable of speaking general text
|
void |
listAllVoices()
List all the available synthesizers and voices.
|
private void |
printSelectedSynthesizerModeDesc()
Print all the properties of the selected synthesizer
|
private void |
resumeSynthesizer()
This method prepares the synthesizer for speech by moving it from the
PAUSED state to the RESUMED state.
|
private void |
selectVoice(javax.speech.synthesis.Voice voice)
Select voice supported by this synthesizer that matches the required
properties found in the voice object.
|
private void |
speakSpeakableSynchronously(javax.speech.synthesis.Speakable speakable,
javax.speech.synthesis.SpeakableListener optionalListener)
Speak the marked-up text provided by the Speakable object and wait for
synthesisers queue to empty.
|
void |
speakText(java.lang.String text) |
private void |
speakTextSynchronously(java.lang.String plainText,
javax.speech.synthesis.SpeakableListener optionalListener)
Speak plain text 'as is' and wait until the synthesizer queue is empty
|
javax.speech.synthesis.Synthesizer synthesizer
VoiceEngine briefExample
javax.speech.synthesis.SpeakableListener optionalListener
public void speakText(java.lang.String text)
private void selectVoice(javax.speech.synthesis.Voice voice)
voice
- required voice properties.private void resumeSynthesizer()
private void allocateSynthesizer()
private void deallocateSynthesizer()
private void exit(java.lang.Exception e)
e
- exception to print before exiting.private void createSynthesizer(javax.speech.synthesis.SynthesizerModeDesc modeDesc)
modeDesc
- required properties for the created synthesizerprivate boolean isModeGeneral()
private void speakSpeakableSynchronously(javax.speech.synthesis.Speakable speakable, javax.speech.synthesis.SpeakableListener optionalListener)
speakable
- optionalListener
- private void speakTextSynchronously(java.lang.String plainText, javax.speech.synthesis.SpeakableListener optionalListener)
plainText
- that will be spoken ignoring any markupoptionalListener
- will be notified of voice eventsprivate java.lang.String genderToString(int gender)
gender
- as defined by the Voice constantsprivate java.lang.String ageToString(int age)
age
- as defined by the Voice constantsprivate void printSelectedSynthesizerModeDesc()
public void listAllVoices()