nimbleape/asterisk-dialogflow-rtp-audioserver

concurrent audio and distortion

0x1stvan opened this issue · 4 comments

When integrating Dialogflow with Asterisk for voice interactions, there an issue where audio playback becomes distorted. This occurs specifically when a new transcript is added while the previous Dialogflow audio is still playing. The old audio continues to play concurrently with the new audio, resulting in an overlap that causes distortion.

Hey @0x1stvan - Is this something you can make a pull request for? Need to clear the buffer when receiving new audio from dialogflow to clear down the previous unplayed audio - this isn't something we're working on currently unless someone wants to pay for consultancy on it.

Hey @0x1stvan - Is this something you can make a pull request for? Need to clear the buffer when receiving new audio from dialogflow to clear down the previous unplayed audio - this isn't something we're working on currently unless someone wants to pay for consultancy on it.

Hi @danjenkins , thanks for the quick reply. Tried to fix it, but i'm not really familiar with nodejs, if you can add me a hint how to do it i can create a pull request if working.

Can you please take a quick look to this issue also?
#20

It looks like this bug still there, setting singleutterance to true causes crash

Yeah I need to look into the single utterance thing but ultimately I haven't looked at this app in a while.

On how to clear down the audio....

https://github.com/nimbleape/asterisk-dialogflow-rtp-audioserver/blob/master/lib/DialogFlowConnector.js#L178

Thats holding all of the previous timeouts but its a local variable to that function... so make it attached to the class so that you can then call

this.timeouts.forEach((ref) => {
                        clearTimeout(ref);
                    });

On line 178. instead of making an empty array you'll be clearing down the set of timeout refs

Thanks @danjenkins , added PR #39, can you check it?