|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jvoicexml.implementation.jsapi10.Jsapi10SynthesizedOutput
public final class Jsapi10SynthesizedOutput
Audio output that uses the JSAPI 1.0 to address the TTS engine.
Handle all JSAPI calls to the TTS engine to make JSAPI transparent to the interpreter.
The queued SpeakableTexts are maintained in a list. Once a speakable
has ended (this is detected via the speakableEnded(SpeakableEvent)
method) this implementation processes the next SpeakableText from
the queue.
SSML is supported via SSMLSpeakStrategys.
This implementation offers 2 ways to overcome the lack in JSAPI 1.0 not to be able to stream audio data.
SpokenInputConnectionHandler andStreamableSynthesizedOutput.
Note that these ways are not fully tested and might be changed towards the JSAPI 2 way.
| Constructor Summary | |
|---|---|
Jsapi10SynthesizedOutput(SynthesizerModeDesc defaultDescriptor)
Constructs a new audio output. |
|
| Method Summary | |
|---|---|
void |
activate()
|
void |
addListener(SynthesizedOutputListener outputListener)
|
void |
addSynthesizerStream(InputStream input)
Reads from the given output stream and adds the result to the list of streams. |
void |
cancelOutput()
|
void |
close()
|
void |
connect(ConnectionInformation connectionInformation)
|
void |
disconnect(ConnectionInformation connectionInformation)
|
DocumentServer |
getDocumentServer()
Retrieves the document server. |
String |
getSessionid()
Retrieves the Id of the current session. |
Synthesizer |
getSynthesizer()
Retrieves the encapsulated synthesizer. |
String |
getType()
|
URI |
getUriForNextSynthesisizedOutput()
|
boolean |
isBusy()
|
boolean |
isOutputCanceled()
Checks if there was a request to cancel the current output. |
void |
markerReached(SpeakableEvent event)
|
void |
open()
|
void |
passivate()
|
void |
queueSpeakable(SpeakableText speakable,
String id,
DocumentServer server)
Checks the type of the given speakable and forwards it either as for SSML output or for plain text output. |
void |
reachedMark(String mark)
A mark in an SSML output has been reached. |
int |
readSynthesizerStream(byte[] buffer,
int offset,
int length)
Reads up to length bytes of data from the synthesizer
stream into the given buffer. |
void |
removeListener(SynthesizedOutputListener outputListener)
|
void |
setSynthesizedOutputConnectionHandler(SynthesizedOutputConnectionHandler connectionHandler)
Sets a custom connection handler. |
void |
setType(String resourceType)
Sets the type of this resource. |
void |
speakableCancelled(SpeakableEvent event)
|
void |
speakableEnded(SpeakableEvent event)
|
void |
speakablePaused(SpeakableEvent event)
|
void |
speakableResumed(SpeakableEvent event)
|
void |
speakableStarted(SpeakableEvent event)
|
void |
speakPlaintext(String text)
Speaks a plain text string. |
boolean |
supportsBargeIn()
|
void |
topOfQueue(SpeakableEvent event)
|
void |
waitEngineState(long state)
Blocks the calling thread until the Engine is in a specified state. |
void |
waitNonBargeInPlayed()
|
void |
waitQueueEmpty()
|
void |
wordStarted(SpeakableEvent event)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Jsapi10SynthesizedOutput(SynthesizerModeDesc defaultDescriptor)
defaultDescriptor - the default synthesizer mode descriptor.| Method Detail |
|---|
public void open()
throws NoresourceError
open in interface ExternalResourceNoresourceErrorpublic void close()
close in interface ExternalResourcepublic Synthesizer getSynthesizer()
public DocumentServer getDocumentServer()
public String getSessionid()
public void addListener(SynthesizedOutputListener outputListener)
addListener in interface ObservableSynthesizedOutputpublic void removeListener(SynthesizedOutputListener outputListener)
removeListener in interface ObservableSynthesizedOutput
public void queueSpeakable(SpeakableText speakable,
String id,
DocumentServer server)
throws NoresourceError,
BadFetchError
queueSpeakable in interface SynthesizedOutputNoresourceError
BadFetchError
public void speakPlaintext(String text)
throws NoresourceError,
BadFetchError
text - String containing the plain text to be spoken.
NoresourceError - No recognizer allocated.
BadFetchError - Recognizer in wrong state.public boolean supportsBargeIn()
supportsBargeIn in interface OutputDevice
public void cancelOutput()
throws NoresourceError
cancelOutput in interface OutputDeviceNoresourceErrorpublic boolean isOutputCanceled()
true if there was a request to cancel the current
output.
public void waitEngineState(long state)
throws InterruptedException
All state bits specified in the state parameter must be set in order for the method to return, as defined for the testEngineState method. If the state parameter defines an unreachable state (e.g. PAUSED | RESUMED) an exception is thrown.
The waitEngineState method can be called successfully in any Engine state.
state - State to wait for.
InterruptedException - If another thread has interrupted this thread.public void waitNonBargeInPlayed()
waitNonBargeInPlayed in interface SynthesizedOutputpublic void waitQueueEmpty()
waitQueueEmpty in interface SynthesizedOutputpublic void reachedMark(String mark)
mark - Name of the mark.public void activate()
activate in interface ExternalResourcepublic void passivate()
passivate in interface ExternalResource
public void connect(ConnectionInformation connectionInformation)
throws IOException
connect in interface RemoteConnectableIOExceptionpublic void disconnect(ConnectionInformation connectionInformation)
disconnect in interface RemoteConnectablepublic String getType()
getType in interface ExternalResourcepublic void setType(String resourceType)
resourceType - type of the resourcepublic void setSynthesizedOutputConnectionHandler(SynthesizedOutputConnectionHandler connectionHandler)
connectionHandler - the connection handler.
public URI getUriForNextSynthesisizedOutput()
throws NoresourceError
getUriForNextSynthesisizedOutput in interface SynthesizedOutputNoresourceErrorpublic void markerReached(SpeakableEvent event)
markerReached in interface SpeakableListenerpublic void speakableCancelled(SpeakableEvent event)
speakableCancelled in interface SpeakableListenerpublic void speakableEnded(SpeakableEvent event)
speakableEnded in interface SpeakableListenerpublic void speakablePaused(SpeakableEvent event)
speakablePaused in interface SpeakableListenerpublic void speakableResumed(SpeakableEvent event)
speakableResumed in interface SpeakableListenerpublic void speakableStarted(SpeakableEvent event)
speakableStarted in interface SpeakableListenerpublic void topOfQueue(SpeakableEvent event)
topOfQueue in interface SpeakableListenerpublic void wordStarted(SpeakableEvent event)
wordStarted in interface SpeakableListenerpublic boolean isBusy()
isBusy in interface ExternalResourceisBusy in interface OutputDevice
public int readSynthesizerStream(byte[] buffer,
int offset,
int length)
throws IOException
length bytes of data from the synthesizer
stream into the given buffer.
readSynthesizerStream in interface StreamableSynthesizedOutputbuffer - the buffer into which the data is read.offset - the start offset in array buffer at which the
data is written.length - the maximum number of bytes to read.
-1 if there is no more data because the end of the stream
has been reached.
IOException - Error reading from the stream..
public void addSynthesizerStream(InputStream input)
throws IOException
input - stream to read from.
IOException - Error reading from the given stream.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||