<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7654.12">
<TITLE>RE: [Freeswitch-users] Am I using play_and_detect_speech correctly?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Thanks for your response, Hector!<BR>
<BR>
Yeah, I am using detect_speech via a similar way to yours.<BR>
<BR>
What I am more interested in is to use detect_speech app to handle user's barge-in.<BR>
<BR>
After Chris mentioned the barge-in can be also handled by detect_speech I gave it a further thinking.<BR>
Yeah, I could first &quot;speak&quot; the utterance and immediately resume ASR, then try to catch the begin_speaking event,<BR>
then stop the TTS -- using this way to handle the user barge-in.<BR>
(Chris, you may have a better idea, would you please let me know if you do?)<BR>
<BR>
One thing I am worry about is that stopping currently playing media or utterance seems not work for me.<BR>
When I recently try &quot;api uuid_break &lt;uuid&gt;&quot; it stopped currently playing music but also stopped playing following utterances<BR>
which I sent to TTS soon later on after uuid_break.<BR>
<BR>
Anyway I will try it further again and let you all know what I will get.<BR>
<BR>
Cheers,<BR>
<BR>
Xing<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: freeswitch-users-bounces@lists.freeswitch.org on behalf of Hector Geraldino<BR>
Sent: Wed 8/1/2012 16:52<BR>
To: FreeSWITCH Users Help<BR>
Subject: Re: [Freeswitch-users] Am I using play_and_detect_speech correctly?<BR>
<BR>
You need to send a detect_speech command with sendmsg + execute:<BR>
<BR>
sendmsg &lt;uuid&gt;<BR>
call-command: execute<BR>
execute-app-name: detect_speech<BR>
execute-app-arg: grammar_name //e.g. unimrcp:nuance5-mrcp2-prod nuancegrm nuancegrm<BR>
<BR>
This will trigger an DETECTED_SPEECH event (you need to add this event to your filters, in case you're filtering the events). The detected speech will be part of the bodyLines of the event. I'm using Java ESL client libraries (org.freeswitch.esl.client) and my code looks like:<BR>
<BR>
protected void handleEslEvent(ChannelHandlerContext ctx, EslEvent event) {<BR>
&nbsp;&nbsp;&nbsp; if (event.getEventName().equals(&quot;DETECTED_SPEECH&quot;)) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (event.getEventBodyLines().size() &gt; 0) {<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; final String uuid = event.getEventHeaders().get(&quot;Unique-ID&quot;);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stopSpeechDetection(uuid);<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //detected speech<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StringBuilder bodyLines = new StringBuilder();<BR>
<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (String line : event.getEventBodyLines()) {<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bodyLines.append(line);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>
&nbsp;&nbsp;&nbsp; }<BR>
}<BR>
<BR>
private void stopSpeechDetection(CallSession call) {<BR>
&nbsp;&nbsp;&nbsp; // sendMessage(uuid, &quot;detect_speech&quot;, &quot;stop&quot;);<BR>
}<BR>
<BR>
g.luck!<BR>
<BR>
From: freeswitch-users-bounces@lists.freeswitch.org [<A HREF="mailto:freeswitch-users-bounces@lists.freeswitch.org">mailto:freeswitch-users-bounces@lists.freeswitch.org</A>] On Behalf Of Liu, Xingkun<BR>
Sent: Wednesday, August 01, 2012 4:49 AM<BR>
To: FreeSWITCH Users Help; FreeSWITCH Users Help<BR>
Subject: Re: [Freeswitch-users] Am I using play_and_detect_speech correctly?<BR>
<BR>
<BR>
Hi Chris,<BR>
<BR>
Many thanks for your info and suggestions!<BR>
<BR>
Would you please tell me a bit more or any clue about the idea of using detect_speech APP to handle<BR>
barge-in over ESL? It is an interesting idea to try but for now I don't have any clue how it could be<BR>
done over Java ESL without touching or modifying detect_speech APP codes.<BR>
<BR>
Thanks again!<BR>
<BR>
Best regards,<BR>
<BR>
Xing<BR>
<BR>
<BR>
<BR>
<BR>
-----Original Message-----<BR>
From: freeswitch-users-bounces@lists.freeswitch.org&lt;<A HREF="mailto:freeswitch-users-bounces@lists.freeswitch.org">mailto:freeswitch-users-bounces@lists.freeswitch.org</A>&gt; on behalf of Christopher Rienzo<BR>
Sent: Tue 7/31/2012 13:44<BR>
To: FreeSWITCH Users Help<BR>
Subject: Re: [Freeswitch-users] Am I using play_and_detect_speech correctly?<BR>
<BR>
I looked over the code again last night and verified that<BR>
play_and_detect_speech should try to stop detection before loading the<BR>
grammar.&nbsp; However, that scenario is not really tested, so try the<BR>
workaround first.&nbsp; If that doesn't work, open a jira ticket with detailed<BR>
logs so it can be fixed.<BR>
<BR>
You can use the detect_speech APP to do everything over ESL.&nbsp; It is a lot<BR>
more work, but once you figure it out, you have the freedom to do whatever<BR>
you want, including handling barge-in.&nbsp; play_and_detect_speech is designed<BR>
to handle the typical use case.<BR>
<BR>
Chris<BR>
<BR>
<BR>
<BR>
On Tue, Jul 31, 2012 at 3:59 AM, x.liu &lt;x.liu@hw.ac.uk&lt;<A HREF="mailto:x.liu@hw.ac.uk">mailto:x.liu@hw.ac.uk</A>&gt;&gt; wrote:<BR>
<BR>
&gt;&nbsp; Hi Chris,<BR>
&gt;<BR>
&gt; Okay, thanks! I will have tries to see how it works.<BR>
&gt;<BR>
&gt; For the normal use of the app: play_and_detect_speech, will it resume<BR>
&gt; previous ASR session,<BR>
&gt; or will it stop previous session and restart a new session each time when<BR>
&gt; I issue it via ESL?<BR>
&gt;<BR>
&gt; For the app of detect_speech, I can first to start an ASR session by<BR>
&gt; &quot;detect_speech speechMod grammar grammarPath&quot;,<BR>
&gt; then I can do &quot;detect_speech pause&quot;, or &quot;detect_speech resume&quot; or<BR>
&gt; &quot;detect_speech stop&quot;.<BR>
&gt; But for play_and_detect_speech, I am not sure how it works in terms of<BR>
&gt; starting, pause, resume/restart sequence.<BR>
&gt;<BR>
&gt; The play_and_detect_speech is a very good, useful app as it supports the<BR>
&gt; barge-in. So we definitely need to use it.<BR>
&gt;<BR>
&gt; Thanks!<BR>
&gt;<BR>
&gt; Xing<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; On 07/31/2012 12:53 AM, Christopher Rienzo wrote:<BR>
&gt;<BR>
&gt; You are using that APP in a way that hasn't been tested.&nbsp; Try to do<BR>
&gt; &quot;speech_detect pause&quot; and see if that helps.&nbsp; It will reserve your ASR<BR>
&gt; session for reuse while &quot;speech_detect stop&quot; will tear it down completely.<BR>
&gt;&nbsp; If that doesn't work, open a jira ticket and attach a full call trace.<BR>
&gt;&nbsp; It's difficult to understand exactly what is happening from your<BR>
&gt; description.<BR>
&gt;<BR>
&gt;<BR>
&gt;&nbsp; Chris<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; On Mon, Jul 30, 2012 at 5:38 PM, Liu, Xingkun &lt;X.Liu@hw.ac.uk&lt;<A HREF="mailto:X.Liu@hw.ac.uk">mailto:X.Liu@hw.ac.uk</A>&gt;&gt; wrote:<BR>
&gt;<BR>
&gt;&gt;&nbsp; Hello,<BR>
&gt;&gt;<BR>
&gt;&gt; I am using play_and_detect_speech with Java ESL in my IVR applications.<BR>
&gt;&gt;<BR>
&gt;&gt; Previously I call it again each time after I receive any recognition<BR>
&gt;&gt; event,<BR>
&gt;&gt; like recognition complete, no-input-timeout, or recognition-timeout,<BR>
&gt;&gt; it seems to work fine.<BR>
&gt;&gt;<BR>
&gt;&gt; Now I have changed my app to issue play_and_detect_speech command based on<BR>
&gt;&gt; my available system utterances as well as the speech event.<BR>
&gt;&gt;<BR>
&gt;&gt; I.e., I use a separate thread to constantly check if there is a system<BR>
&gt;&gt; utterance coming in<BR>
&gt;&gt; from another component of my application, if there is any utterance I<BR>
&gt;&gt; issue the command which will<BR>
&gt;&gt; speak the new utterance and listen to user input no matter whether or not<BR>
&gt;&gt; previous<BR>
&gt;&gt; command has finished. And if there is any speech event (recognition<BR>
&gt;&gt; result, timeout etc.)<BR>
&gt;&gt; the play_and_detect_speech command is also issued but with playing<BR>
&gt;&gt; silence.<BR>
&gt;&gt;<BR>
&gt;&gt; Obviously the new command will stop the utterance speaking of the<BR>
&gt;&gt; previous command if it is not finished.<BR>
&gt;&gt;<BR>
&gt;&gt; My question is<BR>
&gt;&gt;<BR>
&gt;&gt; will the new play_and_detect_speech command also stop the previous ASR<BR>
&gt;&gt; listening<BR>
&gt;&gt; or will there be many ASR listening channel and sending speech data (or<BR>
&gt;&gt; silence) to ASR server?<BR>
&gt;&gt;<BR>
&gt;&gt; Do I need to explicitly issue a &quot;stop&quot; commnad before issuing a new<BR>
&gt;&gt; play_and_detect_speech?<BR>
&gt;&gt; If yes, how to do that, by &quot;detect_speech stop&quot;?<BR>
&gt;&gt;<BR>
&gt;&gt; Recently there is a network traffice problem (lots of connections /data<BR>
&gt;&gt; transportation to the ASR server machine)<BR>
&gt;&gt; when I am running my application. I am not sure if this is because of<BR>
&gt;&gt; other issues<BR>
&gt;&gt; or because of my new changes to the way of using play_and_detect_speech.<BR>
&gt;&gt;<BR>
&gt;&gt; Please any one could shed a light on this?<BR>
&gt;&gt;<BR>
&gt;&gt; Many thanks!<BR>
&gt;&gt;<BR>
&gt;&gt; Xing<BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;&gt; ------------------------------<BR>
&gt;&gt;<BR>
&gt;&gt;&nbsp; *Heriot-Watt University is the Sunday Times Scottish University of the<BR>
&gt;&gt; Year 2011-2012.*<BR>
&gt;&gt;<BR>
&gt;&gt;&nbsp; We invite research leaders and ambitious early career researchers to<BR>
&gt;&gt; join us in leading and driving research in key inter-disciplinary themes.<BR>
&gt;&gt; Please see www.hw.ac.uk/researchleaders&lt;<A HREF="http://www.hw.ac.uk/researchleaders">http://www.hw.ac.uk/researchleaders</A>&gt; for further information and how<BR>
&gt;&gt; to apply.<BR>
&gt;&gt;<BR>
&gt;&gt;&nbsp; Heriot-Watt University is a Scottish charity registered under charity<BR>
&gt;&gt; number SC000278.<BR>
&gt;&gt;<BR>
&gt;&gt; _________________________________________________________________________<BR>
&gt;&gt; Professional FreeSWITCH Consulting Services:<BR>
&gt;&gt; consulting@freeswitch.org&lt;<A HREF="mailto:consulting@freeswitch.org">mailto:consulting@freeswitch.org</A>&gt;<BR>
&gt;&gt; <A HREF="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</A><BR>
&gt;&gt;<BR>
&gt;&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR>
&gt;&gt; <A HREF="http://www.cudatel.com">http://www.cudatel.com</A><BR>
&gt;&gt;<BR>
&gt;&gt; Official FreeSWITCH Sites<BR>
&gt;&gt; <A HREF="http://www.freeswitch.org">http://www.freeswitch.org</A><BR>
&gt;&gt; <A HREF="http://wiki.freeswitch.org">http://wiki.freeswitch.org</A><BR>
&gt;&gt; <A HREF="http://www.cluecon.com">http://www.cluecon.com</A><BR>
&gt;&gt;<BR>
&gt;&gt; Join Us At ClueCon - Aug 7-9, 2012<BR>
&gt;&gt;<BR>
&gt;&gt; FreeSWITCH-users mailing list<BR>
&gt;&gt; FreeSWITCH-users@lists.freeswitch.org&lt;<A HREF="mailto:FreeSWITCH-users@lists.freeswitch.org">mailto:FreeSWITCH-users@lists.freeswitch.org</A>&gt;<BR>
&gt;&gt; <A HREF="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>
&gt;&gt; UNSUBSCRIBE:<A HREF="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</A><BR>
&gt;&gt; <A HREF="http://www.freeswitch.org">http://www.freeswitch.org</A><BR>
&gt;&gt;<BR>
&gt;&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; _________________________________________________________________________<BR>
&gt; Professional FreeSWITCH Consulting Services:consulting@freeswitch.orghttp://www.freeswitchsolutions.com<BR>
&gt;<BR>
&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Serverhttp://www.cudatel.com<BR>
&gt;<BR>
&gt; Official FreeSWITCH Siteshttp://www.freeswitch.orghttp://wiki.freeswitch.orghttp://www.cluecon.com<BR>
&gt;<BR>
&gt; Join Us At ClueCon - Aug 7-9, 2012<BR>
&gt;<BR>
&gt; FreeSWITCH-users mailing listFreeSWITCH-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users&lt;<A HREF="mailto:listFreeSWITCH-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users">mailto:listFreeSWITCH-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A>&gt;<BR>
&gt; UNSUBSCRIBE:<A HREF="http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org">http://lists.freeswitch.org/mailman/options/freeswitch-usershttp://www.freeswitch.org</A>&lt;<A HREF="http://lists.freeswitch.org/mailman/options/freeswitch-usershttp:/www.freeswitch.org">http://lists.freeswitch.org/mailman/options/freeswitch-usershttp:/www.freeswitch.org</A>&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt;<BR>
&gt; ------------------------------<BR>
&gt;<BR>
&gt;&nbsp; *Heriot-Watt University is the Sunday Times Scottish University of the<BR>
&gt; Year 2011-2012.*<BR>
&gt;<BR>
&gt;&nbsp; We invite research leaders and ambitious early career researchers to join<BR>
&gt; us in leading and driving research in key inter-disciplinary themes. Please<BR>
&gt; see www.hw.ac.uk/researchleaders&lt;<A HREF="http://www.hw.ac.uk/researchleaders">http://www.hw.ac.uk/researchleaders</A>&gt; for further information and how to<BR>
&gt; apply.<BR>
&gt;<BR>
&gt;&nbsp; Heriot-Watt University is a Scottish charity registered under charity<BR>
&gt; number SC000278.<BR>
&gt;<BR>
&gt; _________________________________________________________________________<BR>
&gt; Professional FreeSWITCH Consulting Services:<BR>
&gt; consulting@freeswitch.org&lt;<A HREF="mailto:consulting@freeswitch.org">mailto:consulting@freeswitch.org</A>&gt;<BR>
&gt; <A HREF="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</A><BR>
&gt;<BR>
&gt; FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR>
&gt; <A HREF="http://www.cudatel.com">http://www.cudatel.com</A><BR>
&gt;<BR>
&gt; Official FreeSWITCH Sites<BR>
&gt; <A HREF="http://www.freeswitch.org">http://www.freeswitch.org</A><BR>
&gt; <A HREF="http://wiki.freeswitch.org">http://wiki.freeswitch.org</A><BR>
&gt; <A HREF="http://www.cluecon.com">http://www.cluecon.com</A><BR>
&gt;<BR>
&gt; Join Us At ClueCon - Aug 7-9, 2012<BR>
&gt;<BR>
&gt; FreeSWITCH-users mailing list<BR>
&gt; FreeSWITCH-users@lists.freeswitch.org&lt;<A HREF="mailto:FreeSWITCH-users@lists.freeswitch.org">mailto:FreeSWITCH-users@lists.freeswitch.org</A>&gt;<BR>
&gt; <A HREF="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>
&gt; UNSUBSCRIBE:<A HREF="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</A><BR>
&gt; <A HREF="http://www.freeswitch.org">http://www.freeswitch.org</A><BR>
&gt;<BR>
&gt;<BR>
<BR>
________________________________<BR>
<BR>
Heriot-Watt University is the Sunday Times Scottish University of the Year 2011-2012.<BR>
<BR>
We invite research leaders and ambitious early career researchers to join us in leading and driving research in key inter-disciplinary themes. Please see www.hw.ac.uk/researchleaders&lt;<A HREF="http://www.hw.ac.uk/researchleaders">http://www.hw.ac.uk/researchleaders</A>&gt; for further information and how to apply.<BR>
<BR>
Heriot-Watt University is a Scottish charity registered under charity number SC000278.<BR>
<BR>
</FONT>
</P>

<br>
<hr>
<br>
<font face="arial, helvetica" size="-1">
<b>Heriot-Watt University is the Sunday Times Scottish University of the Year 2011-2012.</b>
</font>
<br><br>
<font face="arial,helvetica" size="-1">
We invite research leaders and ambitious early career researchers to 
join us in leading and driving research in key inter-disciplinary themes. 
Please see www.hw.ac.uk/researchleaders for further information and how 
to apply. 
</font>
<br><br>
<font face="arial,helvetica" size="-2">
Heriot-Watt University is a Scottish charity registered under charity number SC000278.
<br>
</font>
</BODY>
</HTML>