Thank you, you’re great. It helped to modify the line in app_speech_utils.c
as follows:
case AST_FRAME_DTMF:
if (dtmf_terminator != '\0' && f->subclass.integer == dtmf_terminator) {
done = 1;
} else {
quieted = 1;
if (ast_channel_stream(chan) != NULL) {
ast_stopstream(chan);
}
if (!started) {
/* Change timeout to be 5 seconds for DTMF input */
timeout = (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) ? ast_channel_pbx(chan)->dtimeoutms : 5000;
started = 1;
}
start = ast_tvnow();
snprintf(tmp, sizeof(tmp), "%c", f->subclass.integer);
strncat(dtmf, tmp, sizeof(dtmf) - strlen(dtmf) - 1);
/* If the maximum length of the DTMF has been reached, stop now */
if (max_dtmf_len && strlen(dtmf) == max_dtmf_len)
done = 1;
}
break;
to:
case AST_FRAME_DTMF:
break;
Then, go to /usr/src/asterisk-VERSION and run make && make install
as you said.
In the Dialplan, I have now added the following:
[cfd-hotline]
exten = 9000,1,Answer()
same => n,Set(SPYGROUP=9000)
same => n,Set(DENOISE(rx)=on)
same => n,Set(DEVICE_STATE(Custom:9000)=INUSE)
same => n,Wait(1)
; Start speech processing
same => n(start),SpeechCreate(my-speech-to-text)
same => n,SpeechStart()
same => n,Set(TIMEOUT(digit)=0) <— Important to prevent delay
same => n,SpeechBackground()
same => n,Verbose(1,Recognized text: ${SPEECH_TEXT(0)})
; Save the recognized text and convert it to lowercase
same => n,Set(SPEECH_RESULT=${SPEECH_TEXT(0)})
same => n,Set(SPEECH_RESULT=${TOLOWER(${SPEECH_RESULT})})
same => n,SpeechDestroy()
; Check if the result matches a greeting
same => n,Set(MATCH_RESULT=0)
; Match greetings with a regex
same => n,ExecIf($[”${SPEECH_RESULT}” =~ “^(a|lot|of|words|that|I|want|to|recognize)$”]?Set(MATCH_RESULT=1))
; If MATCH_RESULT is 1 (successful regex match), go to success
same => n,ExecIf($[”${MATCH_RESULT}” = “1”]?Goto(success))
; If no match - continue with regular processing
same => n,Goto(start)
…
The result is that DTMF is still recognized, but it is no longer considered during SpeechBackground. When a DTMF input is received, the call flow starts again at the label (start) and SpeechBackground() is called again.