MarySynthesizedOutput implements SynthesizedOutput, SynthesizedOutputListener { @Override public void cancelOutput(final BargeInType bargeInType) { synthesisQueue.cancelOutput(bargeInType); } MarySynthesizedOutput(); @Override void queueSpeakable(final SpeakableText speakable,
            final String sessionId, final DocumentServer server); @Override void waitNonBargeInPlayed(); @Override void waitQueueEmpty(); @Override void activate(); @Override void close(); @Override String getType(); @Override void open(); @Override void passivate(); @Override void connect(final ConnectionInformation info); @Override void disconnect(final ConnectionInformation info); @Override void cancelOutput(final BargeInType bargeInType); boolean supportsBargeIn(); @Override void addListener(final SynthesizedOutputListener outputListener); @Override void removeListener(final SynthesizedOutputListener outputListener); void setType(final String resourceType); void outputStatusChanged(final SynthesizedOutputEvent event); @Override boolean isBusy(); void cancelAudioOutput(); void setAudioType(final String value); void setVoiceName(final String name); void setLang(final String lang); @Override void outputError(final ErrorEvent error);  }
@Test(timeout = 20000) public void testCancelOutput() throws Exception, JVoiceXMLEvent { final SsmlDocument doc1 = new SsmlDocument(); final Speak speak1 = doc1.getSpeak(); speak1.setXmlLang(Locale.US); speak1.addText("Test 1.Barge-in on."); final SpeakableSsmlText ssml1 = new SpeakableSsmlText(doc1, true, BargeInType.SPEECH); output.queueSpeakable(ssml1, sessionId, documentServer); LOGGER.info(ssml1.getSpeakableText() + " offered to queue"); synchronized (outputStartedLock) { while (!outputStarted) { outputStartedLock.wait(); } } Thread.sleep(DELAY); output.cancelOutput(BargeInType.SPEECH); synchronized (outputEndedLock) { while (!outputEnded) { outputEndedLock.wait(); } } final SsmlDocument doc2 = new SsmlDocument(); final Speak speak2 = doc2.getSpeak(); speak2.setXmlLang(Locale.US); speak2.addText("Test 2.Barge-in on."); final SpeakableSsmlText ssml2 = new SpeakableSsmlText(doc2, true, BargeInType.SPEECH); output.queueSpeakable(ssml2, sessionId, documentServer); LOGGER.info(ssml2.getSpeakableText() + " offered to queue"); synchronized (outputStartedLock) { while (!outputStarted) { outputStartedLock.wait(); } } Thread.sleep(DELAY); output.cancelOutput(BargeInType.SPEECH); synchronized (outputEndedLock) { while (!outputEnded) { outputEndedLock.wait(); } } SpeakableSsmlText plainText = new SpeakableSsmlText( "Test 3. Barge-in off.You can not skip this audio", Locale.US); output.queueSpeakable(plainText, sessionId, documentServer); LOGGER.info(plainText + " offered to queue"); synchronized (outputStartedLock) { while (!outputStarted) { outputStartedLock.wait(); } } Thread.sleep(DELAY); output.cancelOutput(BargeInType.SPEECH); synchronized (outputEndedLock) { while (!outputEnded) { outputEndedLock.wait(); } } plainText = new SpeakableSsmlText( "Test 4.Barge-in off.You can not skip this audio", Locale.US); output.queueSpeakable(plainText, sessionId, documentServer); LOGGER.info(plainText + " offered to queue"); synchronized (outputStartedLock) { while (!outputStarted) { outputStartedLock.wait(); } } Thread.sleep(DELAY); output.cancelOutput(BargeInType.SPEECH); synchronized (outputEndedLock) { while (!outputEnded) { outputEndedLock.wait(); } } final SsmlDocument doc3 = new SsmlDocument(); final Speak speak3 = doc3.getSpeak(); speak3.setXmlLang(Locale.US); speak3.addText("Test 5.Barge-in on. "); final SpeakableSsmlText ssml3 = new SpeakableSsmlText(doc3, true, BargeInType.SPEECH); output.queueSpeakable(ssml3, sessionId, documentServer); LOGGER.info(ssml3.getSpeakableText() + " offered to queue"); synchronized (outputStartedLock) { while (!outputStarted) { outputStartedLock.wait(); } } Thread.sleep(DELAY); output.cancelOutput(BargeInType.SPEECH); synchronized (outputEndedLock) { while (!outputEnded) { outputEndedLock.wait(); } } plainText = new SpeakableSsmlText( "Test 6.Barge-in off.You can not skip this audio", Locale.US); output.queueSpeakable(plainText, sessionId, documentServer); LOGGER.info(plainText + " offered to queue"); synchronized (outputStartedLock) { while (!outputStarted) { outputStartedLock.wait(); } } Thread.sleep(DELAY); output.cancelOutput(BargeInType.SPEECH); synchronized (outputEndedLock) { while (!outputEnded) { outputEndedLock.wait(); } } }