Jsapi10SynthesizedOutput implements SynthesizedOutput, SpeakableListener,
        StreamableSynthesizedOutput { @Override public void queueSpeakable(final SpeakableText speakable, final String id, final DocumentServer server) throws NoresourceError, BadFetchError { if (synthesizer == null) { throw new NoresourceError("no synthesizer: cannot speak"); } sessionId = id; documentServer = server; synchronized (queuedSpeakables) { queuedSpeakables.offer(speakable); if (queuedSpeakables.size() > 1) { return; } } final Runnable runnable = new Runnable() { @Override public void run() { try { processNextSpeakable(); } catch (NoresourceError e) { notifyError(e); } catch (BadFetchError e) { notifyError(e); } } }; final Thread thread = new Thread(runnable); thread.start(); } Jsapi10SynthesizedOutput(final SynthesizerModeDesc defaultDescriptor); void open(); void close(); Synthesizer getSynthesizer(); DocumentServer getDocumentServer(); String getSessionid(); void addListener(final SynthesizedOutputListener outputListener); void removeListener(final SynthesizedOutputListener outputListener); @Override void queueSpeakable(final SpeakableText speakable, final String id,
            final DocumentServer server); void speakPlaintext(final String text); @Override boolean supportsBargeIn(); @Override void cancelOutput(final BargeInType type); boolean isOutputCanceled(); void waitEngineState(final long state); @Override void waitNonBargeInPlayed(); @Override void waitQueueEmpty(); void reachedMark(final String mark); void activate(); void passivate(); void connect(final ConnectionInformation connectionInformation); void disconnect(final ConnectionInformation connectionInformation); String getType(); void setType(final String resourceType); void setSynthesizedOutputConnectionHandler(
            final SynthesizedOutputConnectionHandler connectionHandler); URI getUriForNextSynthesisizedOutput(); void markerReached(final SpeakableEvent event); void speakableCancelled(final SpeakableEvent event); void speakableEnded(final SpeakableEvent event); void speakablePaused(final SpeakableEvent event); void speakableResumed(final SpeakableEvent event); void speakableStarted(final SpeakableEvent event); void topOfQueue(final SpeakableEvent event); void wordStarted(final SpeakableEvent event); boolean isBusy(); int readSynthesizerStream(final byte[] buffer, final int offset,
            final int length); void addSynthesizerStream(final InputStream input);  }
@Test public void testQueueSpeakable() throws JVoiceXMLEvent, Exception { final SsmlDocument ssml = new SsmlDocument(); final Speak speak = ssml.getSpeak(); speak.addText("this is a test"); final SpeakableText speakable1 = new SpeakableSsmlText(ssml); synthesizer.queueSpeakable(speakable1, sessionId, documentServer); synthesizer.waitQueueEmpty(); Assert.assertFalse(synthesizer.isBusy()); final int size = 3; listener.waitSize(size, TIMEOUT); Assert.assertEquals(size, listener.size()); SynthesizedOutputEvent start = listener.get(0); Assert.assertEquals(OutputStartedEvent.EVENT_TYPE, start.getEventType()); OutputStartedEvent startedEvent = (OutputStartedEvent) start; Assert.assertEquals(speakable1, startedEvent.getSpeakable()); SynthesizedOutputEvent stop = listener.get(1); Assert.assertEquals(OutputEndedEvent.EVENT_TYPE, start.getEventType()); OutputEndedEvent stoppedEvent = (OutputEndedEvent) stop; Assert.assertEquals(speakable1, stoppedEvent.getSpeakable()); SynthesizedOutputEvent empty = listener.get(2); Assert.assertEquals(QueueEmptyEvent.EVENT_TYPE, start.getEventType()); Assert.assertTrue(empty instanceof QueueEmptyEvent); }