How to SpeechBackground Stop Audio Prompt When Receiving a Response

I’m using the Asterisk External Application Protocol with the Speech to Text Engine. Here’s my current dialplan:

exten = 1,1,Answer
same = n,Wait(1)
same = n,SpeechCreate
same = n,SpeechBackground(my_audio,30)

Currently, the SpeechBackground application plays ‘my_audio,’ and when I start speaking, ‘my_audio’ continues to play without stopping to wait for me to finish. How can I make SpeechBackground stop ‘my_audio’ when I begin any response (speaking or pressing a key)? This behavior is similar to the Read application, which stops playing audio when I press the first key and waits for me to finish.

3 Likes

You might try sandwiching in SpeechStart() application between SpeechCreate() and SpeechBackground() applications per this example:

exten => 550,1,NoOp()
same => n,Answer()
same => n,SpeechCreate(my-speech-to-text)
same => n,SpeechStart()
same => n,SpeechBackground(hello-world)
same => n,Verbose(0,${SPEECH_TEXT(0)})
same => n,SpeechDestroy()
same => n,Hangup()

Also the Wait(1) seems superfluous.

I believe he just shorten it to post question. I work with him so yeah…Anyway… I tried it with PHP AGI but when user speak the SpeechBackground doesn’t stop. I don’t know if my aeap is not correctly config or that the application is not working as like it get written in the docs.

Here’s the link: SpeechBackground - Asterisk Documentation

Here’s my current dialplan:

exten => 1,1,Answer
same => n,SpeechCreate(my-speech-to-text)
same => n,SpeechStart()
same => n,SpeechBackground(my_audio,30)
same => n,SpeechDestroy()
same => n,Hangup()

How can I make SpeechBackground stop ‘my_audio’ when I begin any response (speaking)?
Im try use BackgroundDetect, but this not work because I can’t get full response

1 Like

It’s up to the res_speech_aeap module, and it doesn’t appear as though it has been implemented as of yet. It is responsible for setting a flag to indicate playback should stop when they start talking.

1 Like

So what you meant by that is the module is not supported that yet. And what is written in the docs is not correct. Am i right?

Note: English is not my first language so this is why i need to confirm back.

Yes. The documentation for SpeechBackground is generic, as speech is pluggable so different implementations can exist.

1 Like

Sorry to bother you again. But we really need this functionality in our application. So is there any work around like how to set the flag, etc

There’s noone actively working on it. How to set flags is standard in Asterisk code generally, and the module which reacts is res_speech.c, there’s also a silence detector API which could be used. You would have to piece it all together in the code though.

Can you link some of the external source you’re talking about. Because when i search for
“silence detector API asterisk”. The Google return nothing.

Silence detector is part of the DSP: https://github.com/asterisk/asterisk/blob/master/include/asterisk/dsp.h
Example implementation: https://github.com/asterisk/asterisk/blob/master/funcs/func_talkdetect.c
The res_speech module: https://github.com/asterisk/asterisk/blob/master/res/res_speech.c
The res_speech_aeap module: https://github.com/asterisk/asterisk/blob/master/res/res_speech_aeap.c

Like I said though, it’s up to you to piece it all together. I’m not going to tell you how to do that, because that’s the equivalent of asking someone else to do the work for you and it’s not a project I’m doing.

1 Like

Yes thank you, we didn’t expect you would give us the code. We will trying to piece this all together.

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