<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><title>RE: [Freeswitch-users] Am I using play_and_detect_speech correctly?</title><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0in;
        margin-right:0in;
        margin-bottom:0in;
        margin-left:.5in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
/* List Definitions */
@list l0
        {mso-list-id:2106614549;
        mso-list-type:hybrid;
        mso-list-template-ids:-1711009772 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-.25in;}
ol
        {margin-bottom:0in;}
ul
        {margin-bottom:0in;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>You need to send a detect_speech command with sendmsg + execute:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>sendmsg <uuid><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>call-command: execute<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>execute-app-name: detect_speech<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>execute-app-arg: grammar_name //e.g. unimrcp:nuance5-mrcp2-prod nuancegrm nuancegrm<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>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:<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>protected void handleEslEvent(ChannelHandlerContext ctx, EslEvent event) {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> if (event.getEventName().equals("DETECTED_SPEECH")) {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> if (event.getEventBodyLines().size() > 0) {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> final String uuid = event.getEventHeaders().get("Unique-ID");<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> stopSpeechDetection(uuid);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> //detected speech<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> StringBuilder bodyLines = new StringBuilder();<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> for (String line : event.getEventBodyLines()) {<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> bodyLines.append(line);<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> }<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> }<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> } <o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>}<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>private void stopSpeechDetection(CallSession call) { <o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'> // sendMessage(uuid, "detect_speech", "stop");<o:p></o:p></span></p><p class=MsoNormal style='margin-left:.5in'><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>}<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>g.luck!<o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] <b>On Behalf Of </b>Liu, Xingkun<br><b>Sent:</b> Wednesday, August 01, 2012 4:49 AM<br><b>To:</b> FreeSWITCH Users Help; FreeSWITCH Users Help<br><b>Subject:</b> Re: [Freeswitch-users] Am I using play_and_detect_speech correctly?<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><p style='margin-bottom:12.0pt'><span style='font-size:10.0pt'>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: <a href="mailto:freeswitch-users-bounces@lists.freeswitch.org">freeswitch-users-bounces@lists.freeswitch.org</a> 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. However, that scenario is not really tested, so try the<br>workaround first. 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. 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. 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 <<a href="mailto:x.liu@hw.ac.uk">x.liu@hw.ac.uk</a>> wrote:<br><br>> Hi Chris,<br>><br>> Okay, thanks! I will have tries to see how it works.<br>><br>> For the normal use of the app: play_and_detect_speech, will it resume<br>> previous ASR session,<br>> or will it stop previous session and restart a new session each time when<br>> I issue it via ESL?<br>><br>> For the app of detect_speech, I can first to start an ASR session by<br>> "detect_speech speechMod grammar grammarPath",<br>> then I can do "detect_speech pause", or "detect_speech resume" or<br>> "detect_speech stop".<br>> But for play_and_detect_speech, I am not sure how it works in terms of<br>> starting, pause, resume/restart sequence.<br>><br>> The play_and_detect_speech is a very good, useful app as it supports the<br>> barge-in. So we definitely need to use it.<br>><br>> Thanks!<br>><br>> Xing<br>><br>><br>><br>><br>><br>> On 07/31/2012 12:53 AM, Christopher Rienzo wrote:<br>><br>> You are using that APP in a way that hasn't been tested. Try to do<br>> "speech_detect pause" and see if that helps. It will reserve your ASR<br>> session for reuse while "speech_detect stop" will tear it down completely.<br>> If that doesn't work, open a jira ticket and attach a full call trace.<br>> It's difficult to understand exactly what is happening from your<br>> description.<br>><br>><br>> Chris<br>><br>><br>><br>> On Mon, Jul 30, 2012 at 5:38 PM, Liu, Xingkun <<a href="mailto:X.Liu@hw.ac.uk">X.Liu@hw.ac.uk</a>> wrote:<br>><br>>> Hello,<br>>><br>>> I am using play_and_detect_speech with Java ESL in my IVR applications.<br>>><br>>> Previously I call it again each time after I receive any recognition<br>>> event,<br>>> like recognition complete, no-input-timeout, or recognition-timeout,<br>>> it seems to work fine.<br>>><br>>> Now I have changed my app to issue play_and_detect_speech command based on<br>>> my available system utterances as well as the speech event.<br>>><br>>> I.e., I use a separate thread to constantly check if there is a system<br>>> utterance coming in<br>>> from another component of my application, if there is any utterance I<br>>> issue the command which will<br>>> speak the new utterance and listen to user input no matter whether or not<br>>> previous<br>>> command has finished. And if there is any speech event (recognition<br>>> result, timeout etc.)<br>>> the play_and_detect_speech command is also issued but with playing<br>>> silence.<br>>><br>>> Obviously the new command will stop the utterance speaking of the<br>>> previous command if it is not finished.<br>>><br>>> My question is<br>>><br>>> will the new play_and_detect_speech command also stop the previous ASR<br>>> listening<br>>> or will there be many ASR listening channel and sending speech data (or<br>>> silence) to ASR server?<br>>><br>>> Do I need to explicitly issue a "stop" commnad before issuing a new<br>>> play_and_detect_speech?<br>>> If yes, how to do that, by "detect_speech stop"?<br>>><br>>> Recently there is a network traffice problem (lots of connections /data<br>>> transportation to the ASR server machine)<br>>> when I am running my application. I am not sure if this is because of<br>>> other issues<br>>> or because of my new changes to the way of using play_and_detect_speech.<br>>><br>>> Please any one could shed a light on this?<br>>><br>>> Many thanks!<br>>><br>>> Xing<br>>><br>>><br>>> ------------------------------<br>>><br>>> *Heriot-Watt University is the Sunday Times Scottish University of the<br>>> Year 2011-2012.*<br>>><br>>> We invite research leaders and ambitious early career researchers to<br>>> join us in leading and driving research in key inter-disciplinary themes.<br>>> Please see <a href="http://www.hw.ac.uk/researchleaders">www.hw.ac.uk/researchleaders</a> for further information and how<br>>> to apply.<br>>><br>>> Heriot-Watt University is a Scottish charity registered under charity<br>>> number SC000278.<br>>><br>>> _________________________________________________________________________<br>>> Professional FreeSWITCH Consulting Services:<br>>> <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>>> <a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a><br>>><br>>> FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>>> <a href="http://www.cudatel.com">http://www.cudatel.com</a><br>>><br>>> Official FreeSWITCH Sites<br>>> <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>>> <a href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a><br>>> <a href="http://www.cluecon.com">http://www.cluecon.com</a><br>>><br>>> Join Us At ClueCon - Aug 7-9, 2012<br>>><br>>> FreeSWITCH-users mailing list<br>>> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>>> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>>> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>>> <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>>><br>>><br>><br>><br>> _________________________________________________________________________<br>> Professional FreeSWITCH Consulting Services:consulting@freeswitch.orghttp://www.freeswitchsolutions.com<br>><br>> FreeSWITCH-powered IP PBX: The CudaTel Communication Serverhttp://www.cudatel.com<br>><br>> Official FreeSWITCH Siteshttp://www.freeswitch.orghttp://wiki.freeswitch.orghttp://www.cluecon.com<br>><br>> Join Us At ClueCon - Aug 7-9, 2012<br>><br>> FreeSWITCH-users mailing <a href="mailto:listFreeSWITCH-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users">listFreeSWITCH-users@lists.freeswitch.orghttp://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>> 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><br>><br>><br>><br>> ------------------------------<br>><br>> *Heriot-Watt University is the Sunday Times Scottish University of the<br>> Year 2011-2012.*<br>><br>> We invite research leaders and ambitious early career researchers to join<br>> us in leading and driving research in key inter-disciplinary themes. Please<br>> see <a href="http://www.hw.ac.uk/researchleaders">www.hw.ac.uk/researchleaders</a> for further information and how to<br>> apply.<br>><br>> Heriot-Watt University is a Scottish charity registered under charity<br>> number SC000278.<br>><br>> _________________________________________________________________________<br>> Professional FreeSWITCH Consulting Services:<br>> <a href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</a><br>> <a href="http://www.freeswitchsolutions.com">http://www.freeswitchsolutions.com</a><br>><br>> FreeSWITCH-powered IP PBX: The CudaTel Communication Server<br>> <a href="http://www.cudatel.com">http://www.cudatel.com</a><br>><br>> Official FreeSWITCH Sites<br>> <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>> <a href="http://wiki.freeswitch.org">http://wiki.freeswitch.org</a><br>> <a href="http://www.cluecon.com">http://www.cluecon.com</a><br>><br>> Join Us At ClueCon - Aug 7-9, 2012<br>><br>> FreeSWITCH-users mailing list<br>> <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>> <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>> UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>> <a href="http://www.freeswitch.org">http://www.freeswitch.org</a><br>><br>></span><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div class=MsoNormal align=center style='text-align:center'><hr size=2 width="100%" align=center></div><p class=MsoNormal><br><b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>Heriot-Watt University is the Sunday Times Scottish University of the Year 2011-2012.</span></b><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'> </span><br><br><span style='font-size:10.0pt;font-family:"Arial","sans-serif"'>We invite research leaders and ambitious early career researchers to join us in leading and driving research in key inter-disciplinary themes. Please see <a href="http://www.hw.ac.uk/researchleaders">www.hw.ac.uk/researchleaders</a> for further information and how to apply. </span><br><br><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'>Heriot-Watt University is a Scottish charity registered under charity number SC000278. </span><o:p></o:p></p></div></body></html>