Jsapi10SynthesizedOutput implements SynthesizedOutput, SpeakableListener,
        StreamableSynthesizedOutput { @Override public void cancelOutput(final BargeInType type) throws NoresourceError { if (synthesizer == null) { throw new NoresourceError("No synthesizer: Cannot cancel output"); } if (!bargein || (type != bargeInType)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("bargein not active for current output"); } return; } if (LOGGER.isDebugEnabled()) { LOGGER.debug("cancelling current output..."); } outputCanceled = true; synchronized (queuedSpeakables) { try { synthesizer.cancelAll(); } catch (EngineStateError ee) { throw new NoresourceError(ee); } final Collection<SpeakableText> skipped = new java.util.ArrayList<SpeakableText>(); for (SpeakableText speakable : queuedSpeakables) { if (speakable.isBargeInEnabled(type)) { skipped.add(speakable); } else { break; } } queuedSpeakables.removeAll(skipped); if (queuedSpeakables.isEmpty()) { fireQueueEmpty(); synchronized (emptyLock) { emptyLock.notifyAll(); } } else { final Runnable runnable = new Runnable() { @Override public void run() { try { outputCanceled = false; processNextSpeakable(); } catch (NoresourceError e) { notifyError(e); } catch (BadFetchError e) { notifyError(e); } } }; final Thread thread = new Thread(runnable); thread.start(); } } if (LOGGER.isDebugEnabled()) { LOGGER.debug("...output cancelled."); } } 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 testCancelOutput() throws JVoiceXMLEvent, Exception { final SsmlDocument doc1 = new SsmlDocument(); final Speak speak1 = doc1.getSpeak(); speak1.addText("Test1"); final SpeakableText text1 = new SpeakableSsmlText(doc1, true, BargeInType.HOTWORD); ; final SsmlDocument doc2 = new SsmlDocument(); final Speak speak2 = doc2.getSpeak(); speak2.addText("Test2"); final SpeakableText text2 = new SpeakableSsmlText(doc2, true, BargeInType.SPEECH); final SsmlDocument doc3 = new SsmlDocument(); final Speak speak3 = doc3.getSpeak(); speak3.addText("Test3"); final SpeakableText text3 = new SpeakableSsmlText(doc3); synthesizer.queueSpeakable(text1, sessionId, documentServer); synthesizer.queueSpeakable(text2, sessionId, documentServer); synthesizer.queueSpeakable(text3, sessionId, documentServer); Thread.sleep(TIMEOUT); synthesizer.cancelOutput(BargeInType.SPEECH); synthesizer.waitQueueEmpty(); }