<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 18, 2021 at 4:46 PM mayamatakeshi <<a href="mailto:mayamatakeshi@gmail.com">mayamatakeshi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 18, 2021 at 3:59 PM mayamatakeshi <<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Mar 18, 2021 at 12:23 PM mayamatakeshi <<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 17, 2021 at 6:52 PM mayamatakeshi <<a href="mailto:mayamatakeshi@gmail.com" target="_blank">mayamatakeshi@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi, <div>I'm trying play_and_detect_speech with an ESL app but START-OF-INPUT doesn't interrupt the TTS being played.</div><div>Is this expected?</div><div>(<a href="https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools%3A+play_and_detect_speech" target="_blank">https://freeswitch.org/confluence/display/FREESWITCH/mod_dptools%3A+play_and_detect_speech</a> is not clear about it)</div><div>Or maybe I need to set some channel variable for this to work.</div></div></blockquote><div><br></div><div>Hi,</div><div><div>My app is a fork of <a href="https://github.com/plivo/plivoframework" target="_blank">https://github.com/plivo/plivoframework</a> </div><div></div></div><div>I debugged FS code and found the cause of the problem:</div><div>I verified that the DETECTED_SPEECH events (including the one with Speech-Type begin-speaking) were not being fired.</div><div>This was because my app was not setting this variable:</div><div>  <a href="https://freeswitch.org/confluence/display/FREESWITCH/fire_asr_events" target="_blank">https://freeswitch.org/confluence/display/FREESWITCH/fire_asr_events</a></div><div>Then I set fire_asr_events=true</div><div>but still the prompt didn't get interrupted by speech.</div><div>Then I checked how FS code was fetching (dequeuing) events and I realized it checks for divert_events.</div><div>Then I changed my app to send</div><div>  divert_events off</div><div>in the ESL socket</div><div>and after that it worked and FS stopped the prompt upon speech start.</div><div>However, it is not stopping the prompt when a DTMF digit is received (it was already this way before I did the changes).</div><div>So things are better but still there is something amiss.</div></div></div></blockquote><div><br></div><div><font face="monospace">OK. I found the reason:</font></div><div><font face="monospace">I was using '<span style="color:rgb(23,43,77)">playback_terminators=any'</span></font></div><div><font color="#172b4d" face="monospace">which reading the FS code shows will result in:</font></div><div><font face="monospace"><font color="#172b4d">  terminators = "</font>1234567890*#"</font></div><div><span style="color:rgb(23,43,77)"><font face="monospace">But I was sending DTMF 'a' so it was not causing the prompt to be terminated.</font></span></div><div><font face="monospace">Then I changed my test script to send '1' instead and then this caused the prompt to terminate.</font></div><div><font face="monospace">However, this also terminated the speech detection operation as FS sent STOP to the MRCP server.</font></div><div><font face="monospace">And the reason is because differently from begin-speaking, a terminator will set the operation as done (switch_ivr_async.c):</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">                      } else if (!strcasecmp(speech_type, "begin-speaking")) {            <br></font></div><font face="monospace">                          switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "(%s) START OF SPEECH\n", switch_channel_get_name(channel));<br>                          return SWITCH_STATUS_BREAK;<br>                      }<br><br>                      if (terminators && strchr(terminators, dtmf->digit)) {<br>                          switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "(%s) ACCEPT TERMINATOR %c\n", switch_channel_get_name(channel), dtmf->digit);<br>                          switch_channel_set_variable_printf(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "%c", dtmf->digit);<br>                          state->result = switch_core_session_sprintf(session, "DIGIT: %c", dtmf->digit);<br><font color="#0000ff">                          state->done = PLAY_AND_DETECT_DONE;<br></font>                          return SWITCH_STATUS_BREAK;<br></font><div><font face="monospace">                      }</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">This might be OK for someone but in my case  there is another issue that the termination of the speech detection is not notified to my app via ESL.</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">I am hoping to solve this by leaving the DTMF collection to be done by the MRCP server but currently the MRCP server I'm using (UniMRCP) doesn't report START-OF-INPUT for DTMF (I only get the RECOGNITION-COMPLETE after all digits are input). (my use case is to allow the user to speak some number sequence or dial it).</font></div></div></div></blockquote><div><br></div><div>Sorry, </div><div>checking again, there is some specific condition that causes UniMRCP to not send the START-OF-INPUT.</div><div>I'm not sure what it is yet but it may be by design or following something in the protocol that I am not aware of.</div></div></div></blockquote><div><br></div><div>Just closing this issue and leaving some final details in case someone gets into a similar problem:</div><div>  - I was testing with unimrcp server 1.6.0 and under some conditions this version would not send START-OF-INPUT upon DTMF detection</div><div>  - after updating to unimrcp server 1.7.0, the problem went away.</div><div><br></div><div>And in case someone needs to follow SIP/MRCP/DTMF flows, you can try my sngrep fork. Details here:</div><div>  <a href="https://github.com/irontec/sngrep/issues/78">https://github.com/irontec/sngrep/issues/78</a></div><div> </div><div>(it also supports UTF-8 which is particularly relevant to see the text in MRCP SPEAK, DEFINE-GRAMMAR and RECOGNITION-COMPLETE messages)<br></div><div><br></div><div>Here is a snapshot:</div><div><img src="cid:ii_kmis5t0d0" alt="sngrep.dtmf_and_mrcp.png" width="472" height="236"><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_quote"><div><font face="monospace"><br></font></div><div><font face="monospace">So I will switch to use detect_speech instead of play_and_detect_speech.</font></div><div><br></div></div></div></blockquote></div></div></blockquote><div><br></div><div>So, using play_and_detect_speech is viable for my needs as I can leave DTMF handling to unimrcp server.</div><div>I might eventually need to implement a solution using detect_speech like in case of max-number-of-digits which unimrcp server doesn't support at the moment. </div><div>But for now, play_and_detect_speech should suffice.</div><div><br></div><div> </div></div></div>