Package com.sun.speech.freetts.audio
Class MultiFileAudioPlayer
java.lang.Object
com.sun.speech.freetts.audio.MultiFileAudioPlayer
- All Implemented Interfaces:
AudioPlayer
Streams audio to multiple files, one per utterance.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a default audio player for an AudioFileFormat of type WAVE.MultiFileAudioPlayer(String baseName, AudioFileFormat.Type type) Constructs a MultiFileAudioPlayer -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin(int size) Starts the output of a set of data.voidcancel()Cancels currently playing audiovoidclose()Closes this audio playerbooleandrain()Waits for all queued audio to be playedbooleanend()Marks the end of a set of data.Gets the audio format for this playerlonggetTime()Gets the amount of played since the last markfloatReturns the current volume.voidpause()Pauses audio outputvoidreset()Prepares for another batch of output.voidResets the audio clockvoidresume()Resumes audio outputvoidsetAudioFormat(AudioFormat format) Sets the audio format for this playervoidsetVolume(float volume) Sets the current volume.voidShows metrics for this audio playervoidStarts the first sample timertoString()Returns the name of this audioplayerbooleanwrite(byte[] audioData) Writes the given bytes to the audio streambooleanwrite(byte[] bytes, int offset, int size) Writes the given bytes to the audio stream
-
Constructor Details
-
MultiFileAudioPlayer
public MultiFileAudioPlayer()Creates a default audio player for an AudioFileFormat of type WAVE. Reads the "com.sun.speech.freetts.AudioPlayer.baseName" property for the base filename to use, and will produce files of the form <baseName>1.wav. The default value for the base name is "freetts". -
MultiFileAudioPlayer
Constructs a MultiFileAudioPlayer- Parameters:
baseName- the base name of the audio filetype- the type of audio output
-
-
Method Details
-
setAudioFormat
Sets the audio format for this player- Specified by:
setAudioFormatin interfaceAudioPlayer- Parameters:
format- the audio format- Throws:
UnsupportedOperationException- if the line cannot be opened with the given format
-
getAudioFormat
Gets the audio format for this player- Specified by:
getAudioFormatin interfaceAudioPlayer- Returns:
- format the audio format
-
pause
public void pause()Pauses audio output- Specified by:
pausein interfaceAudioPlayer
-
resume
public void resume()Resumes audio output- Specified by:
resumein interfaceAudioPlayer
-
startFirstSampleTimer
public void startFirstSampleTimer()Starts the first sample timer- Specified by:
startFirstSampleTimerin interfaceAudioPlayer
-
cancel
public void cancel()Cancels currently playing audio- Specified by:
cancelin interfaceAudioPlayer
-
reset
public void reset()Prepares for another batch of output. Larger groups of output (such as all output associated with a single FreeTTSSpeakable) should be grouped between a reset/drain pair.- Specified by:
resetin interfaceAudioPlayer
-
close
public void close()Closes this audio player- Specified by:
closein interfaceAudioPlayer
-
getVolume
public float getVolume()Returns the current volume.- Specified by:
getVolumein interfaceAudioPlayer- Returns:
- the current volume (between 0 and 1)
-
setVolume
public void setVolume(float volume) Sets the current volume.- Specified by:
setVolumein interfaceAudioPlayer- Parameters:
volume- the current volume (between 0 and 1)
-
begin
public void begin(int size) Starts the output of a set of data. Audio data for a single utterance should be grouped between begin/end pairs.- Specified by:
beginin interfaceAudioPlayer- Parameters:
size- the size of data between now and the end
-
end
public boolean end()Marks the end of a set of data. Audio data for a single utterance should be groupd between begin/end pairs.- Specified by:
endin interfaceAudioPlayer- Returns:
- true if the audio was output properly, false if the output was cancelled or interrupted.
-
drain
public boolean drain()Waits for all queued audio to be played- Specified by:
drainin interfaceAudioPlayer- Returns:
- true if the audio played to completion, false if the audio was stopped
-
getTime
public long getTime()Gets the amount of played since the last mark- Specified by:
getTimein interfaceAudioPlayer- Returns:
- the amount of audio in milliseconds
-
resetTime
public void resetTime()Resets the audio clock- Specified by:
resetTimein interfaceAudioPlayer
-
write
public boolean write(byte[] audioData) Writes the given bytes to the audio stream- Specified by:
writein interfaceAudioPlayer- Parameters:
audioData- audio data to write to the device- Returns:
trueof the write completed successfully,falseif the write was cancelled.
-
write
public boolean write(byte[] bytes, int offset, int size) Writes the given bytes to the audio stream- Specified by:
writein interfaceAudioPlayer- Parameters:
bytes- audio data to write to the deviceoffset- the offset into the buffersize- the size into the buffer- Returns:
trueof the write completed successfully,falseif the write was cancelled.
-
toString
Returns the name of this audioplayer -
showMetrics
public void showMetrics()Shows metrics for this audio player- Specified by:
showMetricsin interfaceAudioPlayer
-