pgbennett.speech
Class Speaker

java.lang.Object
  extended by pgbennett.speech.Speaker
All Implemented Interfaces:
SpeechInterface

public class Speaker
extends java.lang.Object
implements SpeechInterface

Implements a text to speech interface


Constructor Summary
Speaker()
          Creates a Speaker object that outputs to a sound card, on Windows systems only.
Speaker(java.lang.String fileName)
          Creates a Speaker object that outputs to a wave file.
 
Method Summary
 boolean close()
          Close file or sound output device
protected  void finalize()
           
 java.lang.String[] getVoiceList()
           
static java.lang.String[] getVoices()
           
 boolean init()
           
static void main(java.lang.String[] args)
          main method runs a test of all functions
 boolean setRate(int rate)
          Sets the rate (speed) of output speech
 void setVoice(java.lang.String voiceName)
           
 boolean setVolume(int volume)
          Set output volume for text, default is 100
 boolean speak(java.lang.String strInput)
          Converts the given input text to speech.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Speaker

public Speaker()
        throws javax.sound.sampled.UnsupportedAudioFileException
Creates a Speaker object that outputs to a sound card, on Windows systems only.

Throws:
javax.sound.sampled.UnsupportedAudioFileException

Speaker

public Speaker(java.lang.String fileName)
        throws javax.sound.sampled.UnsupportedAudioFileException
Creates a Speaker object that outputs to a wave file.

Parameters:
fileName - File name for output wave file.
Throws:
javax.sound.sampled.UnsupportedAudioFileException
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
main method runs a test of all functions

Throws:
java.lang.Exception

init

public boolean init()
Specified by:
init in interface SpeechInterface

speak

public boolean speak(java.lang.String strInput)
Converts the given input text to speech. Text can optionally contain XML tags for controlling the speech. To use XML tags there must be an XML tag at the front of the string even if it is a dummy field name or an empty tag.

Specified by:
speak in interface SpeechInterface
Parameters:
strInput - String with words to convert to speech

setRate

public boolean setRate(int rate)
Sets the rate (speed) of output speech

Specified by:
setRate in interface SpeechInterface
Parameters:
rate - Rate, valid values are from -10 to 10

setVolume

public boolean setVolume(int volume)
Set output volume for text, default is 100

Specified by:
setVolume in interface SpeechInterface
Parameters:
volume - Volume from 0 to 100

close

public boolean close()
Close file or sound output device

Specified by:
close in interface SpeechInterface

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

setVoice

public void setVoice(java.lang.String voiceName)
Specified by:
setVoice in interface SpeechInterface

getVoices

public static java.lang.String[] getVoices()

getVoiceList

public java.lang.String[] getVoiceList()
Specified by:
getVoiceList in interface SpeechInterface