I’m currently working with Asterisk’s speech recognition feature and have written a dialplan to play back recognized speech segments. However, I’m having an issue where the recognized text segments are not played in the correct order.
Here is the relevant portion of my dialplan:
exten => 123456,1,NoOp(fddfdfdfg)
same => n,NoOp(test voice assistant)
same => n,Set(stopMarker=stop)
same => n,Answer()
same => n,SpeechCreate(my-speech-to-text)
same => n(continue),SpeechStart()
same => n(return),SpeechBackground(silence/1)
same => n,Set(counter=0)
same => n,Background(${SPEECH_TEXT(${counter})})
same => n(loop),Set(counter=$[${counter}+1])
same => n,GotoIf($[ "${SPEECH_TEXT(${counter})}x" != "x" ]?playback:return)
same => n(playback),Background(${SPEECH_TEXT(${counter})})
same => n,Goto(loop)
same => n,GotoIf($[ "${SPEECH_TEXT(0)}" != "${stopMarker}" ]?continue)
same => n,SpeechDestroy()
same => n,Hangup()
so only first chunk is playing corrent and next looks like asterisk rewrite order.
Despite the fact that the recognized speech segments are sent to Asterisk in the correct order, they are played back in reverse. The first segment is played correctly, but after that, instead of playing the second recognized segment, it jumps to the last one. Then, the next-to-last segment is played instead of the third, and so on.
Thank you. for now it’s clearly.
the issue that we`re trying to play audio parts from the SPEECH_TEXT array from the 0 to the last element.
But the data appears to that array in FILO mode. Because of that we have this situation:
Were playing first part, while we playing it, backend pushing more data to SPEECH_TEXT array, when were finishing, were getting to element uder index 1 which is before last in list and then were getting through the list of files from end to beginning.
Can we get not FILO but FIFO structure ? maybe it’s more true?
Yes, the goal is to have an ability to play all audiofiles that comes to SPEECH_TEXT one by one.
So we`re getting first one, its places to 0-s array element. While we playing it, we have 3 or 4 or more files comes into that array in the backgfround and to have correct audio flow, we need to go down throught the Array. For that newly appears records must be in 1-st, 2-nd 3rd and so on element. In that case we can just play one by one each next element without any issue.
Is it an option, to change order of coming responses to SPEECH_TEXT fropm stack structure to queue structure ?