The only thing that relates to the number 3, in that code, is $count, but that is only referenced for the number of iterations, and there is nothing that would distinguish iteration two from iteration 3.
There is one branch that has included code which isn’t visible
(It also appears that it tries to read the same information three times, even if it gets it on the first attempt.)
From the output debug below:
Quest 1 requires key pres, question 2 voice response, question 3 key press
first it plays the welcome message, then After the first and second question in the sound file it did wait for the delay after the beep, but in the third question it did not wait. Note that I end the call after the fail to wait in this question three.
Also am seeing the number 99981 in this debug output? Strange that this number is recorded as my key-press in question 6. please note that question 4 and 5 requires voice response.
I notice that when I comments out this two lines below which record and process the voice response with google Speech To Text, all the key press works fine.
$agi->record_file("/var/lib/asterisk/agi-bin/survey_sound/aans.$countquest",“wav”,’’,-1,null,true,2);
include(‘voicetotext_survey.php’);
Here is the output debug:
<SIP/john-00000000>AGI Rx << ANSWER
<SIP/john-00000000>AGI Tx >> 200 result=0
> 0x7fa6d8005e50 – Strict RTP learning complete - Locking on source address 192.168.43.1:34080
<SIP/john-00000000>AGI Rx << EXEC Playback /path-to-sound-file/1
– AGI Script Executing Application: (Playback) Options: (/path-to-sound-file/1)
– <SIP/john-00000000> Playing ‘/path-to-sound-file/1.slin’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=0
<SIP/john-00000000>AGI Rx << EXEC Playback /path-to-sound-file/1
– AGI Script Executing Application: (Playback) Options: (/path-to-sound-file/1)
– <SIP/john-00000000> Playing ‘/path-to-sound-file/1.slin’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=0
<SIP/john-00000000>AGI Rx << GET DATA beep 3000 2
– <SIP/john-00000000> Playing ‘beep.gsm’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=2 (timeout)
<SIP/john-00000000>AGI Rx << EXEC Playback /path-to-sound-file/1
– AGI Script Executing Application: (Playback) Options: (/path-to-sound-file/1)
– <SIP/john-00000000> Playing ‘/path-to-sound-file/1.slin’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=0
<SIP/john-00000000>AGI Rx << RECORD FILE /path-to-sound-file/aans.2 wav “” -1 BEEP s=2
– <SIP/john-00000000> Playing ‘beep.gsm’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=99981 (timeout) endpos=38080
<SIP/john-00000000>AGI Rx << Transcript: number 2 number 2 test number 2
<SIP/john-00000000>AGI Tx >> 510 Invalid or unknown command
<SIP/john-00000000>AGI Rx << Confidence: 0.70415837
<SIP/john-00000000>AGI Tx >> 510 Invalid or unknown command
<SIP/john-00000000>AGI Rx << EXEC Playback /path-to-sound-file/1
– AGI Script Executing Application: (Playback) Options: (/path-to-sound-file/1)
– <SIP/john-00000000> Playing ‘/path-to-sound-file/1.slin’ (language ‘en’)
[Jul 22 08:20:47] WARNING[2336]: db.c:332 ast_db_put: Couldn’t execute statment: SQL logic error
<SIP/john-00000000>AGI Tx >> 200 result=0
<SIP/john-00000000>AGI Rx << GET DATA beep 3000 2
– <SIP/john-00000000> Playing ‘beep.gsm’ (language ‘en’)
<SIP/john-00000000>AGI Rx << EXEC Playback /path-to-sound-file/no_key_press
– AGI Script Executing Application: (Playback) Options: (/path-to-sound-file/no_key_press)
– <SIP/john-00000000> Playing ‘/path-to-sound-file/no_key_press.slin’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=0
<SIP/john-00000000>AGI Rx << EXEC Playback /path-to-sound-file/1
– AGI Script Executing Application: (Playback) Options: (/path-to-sound-file/1)
– <SIP/john-00000000> Playing ‘/path-to-sound-file/1.slin’ (language ‘en’)
<SIP/john-00000000>AGI Tx >> 200 result=0
<SIP/john-00000000>AGI Rx << GET DATA beep 3000 2
<SIP/john-00000000>AGI Tx >> 511 Command Not Permitted on a dead channel or intercept routine
– <SIP/john-00000000>AGI Script /var/lib/asterisk/agi-bin/agifile.php completed, returning 4
== Spawn extension (phones, 888, 3) exited non-zero on ‘SIP/dav-00000000’Preformatted text
The AGI protocol is a request/response protocol that uses STDOUT and STDIN.
You (your AGI library) write a request ('GET DATA beep 3000 2') to STDOUT and you read a response ('200 result=2 (timeout)') from STDIN. Lather, rinse, repeat.
When you write a ‘status’ message to STDOUT, you violate that protocol ('510 Invalid or unknown command').
You can use the '$agi->verbose()' command to write a message to the Asterisk console.
Or, you can use 'syslog()' to write a message to the system error log. For PHP, I use something like:
So to fix the problem, is it that I should capture all the messages that causes the “ 510 Invalid or unknown command” like the “Transcript: number 2 number 2 test number 2” message in a variable `` highlighted by @david551aboveand put inside the verbose function like this:
After I use the message (in a variable) like put in database, then I put the variable in the verbose function like this:
I finally have it fixed without the verbose function, i just comment out the two php printf function in the script i put in the include function.
Thanks again @sedwards and @david551