${SPEECH_TEXT(0)} SpeechBackground wrond order

Hi everyone,

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.

What do you mean by “not played in the correct order”? We don’t really do anything with the results, the engine just puts the results.

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.

Sent to Asterisk using what?

using websocket

Using aeap? Something else?

yes, we use aeap

I don’t have any experience with multiple results, but the implementation for how it is handled is here[1].

[1] asterisk/res/res_speech_aeap.c at master · asterisk/asterisk · GitHub

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?

I don’t know what that really means, and don’t really have any additional input or insight.

FILO means LIFO, last in first out. They are saying that the structure is being loaded as a stack, but they are reading it as an array.

Hello !

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 ?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.