Open danjenkins opened 4 years ago
Hi @SubhashPeshwa - I found I had to get some sound out of Asterisk first before I could hear anything from Dialogflow. Try this:
exten => 1002,1,Verbose(1, "")
same => n,Playback(hello-world)
same => n,Stasis(dialogflow)
same => n,Hangup()
@danjenkins
I've been experimenting around with this a bit, although I'm completely new to Asterisk/ARI or even websockets.
I am using same configuration/infra as you've mentioned. I was also able to get the audio from dialogflow but somehow the SIP wouldn't play that.
What worked for me was extracting this piece of code from Line 77 - 80 out of the inner block and then replacing address/port variables manually. In my case I changed Port to 7777 and address to 192.168.. (address of FreePBX virtualBox)
Replacing this:- `
this.once(`data-${port}`, (audio, rinfo) => {
this.log.info(`Audio Stream started from port ${port}`);
stream.outWStream.on('data', (audioData) => {
//this.log.info('sending audio back to asterisk', audioData.length, rinfo.port, rinfo.address);
this.socket.send(audioData, rinfo.port, rinfo.address);
});
});
this.on(`data-${port}`, (data) => {
stream.inRStream.write(data);
});
`
with this:
`
this.once(`data-${port}`, (audio, rinfo) => {
this.log.info(`Audio Stream started from port ${port}`);
// COMMENTING OUT THIS PART
//stream.outWStream.on('data', (audioData) => {
// //this.log.info('sending audio back to asterisk', audioData.length, rinfo.port, rinfo.address);
// this.socket.send(audioData, rinfo.port, rinfo.address);
//});
});
// ADDING IT HERE
stream.outWStream.on('data', (audioData) => {
//this.log.info('sending audio back to asterisk', audioData.length, rinfo.port, rinfo.address);
this.socket.send(audioData, <PORT>, <ADDRESS>);
});
this.on(`data-${port}`, (data) => {
stream.inRStream.write(data);
});
`
Doing this somehow returned the audio from the dialogflow back to the SIP phone and I was able to hear the response. Not really sure how it worked!
Interesting @abhioshar ! Odd... because that code works for at least 4 other people other than me.... :S
so just to remind myself.... because I test with a sip phone I get audio straight away. PSTN might not be the case.
so basically I need to take the source port I send over MQTT and make a stream straight away and setup the read/write - dont wait for the audio from Asterisk before making it
@digitaltoast in your testing were you doing it from the PSTN?
I think this is all related to the accepted codecs ( https://github.com/nimbleape/asterisk-dialogflow-rtp-audioserver/issues/16) - see what you get for allowing all, and then allowing only ulaw/alaw/something else. I have a feeling this is going to lead us toward an Asterisk bug report regarding RTP...
Something late to answer, but I leave something that may be the solution. Asterisk needs to open the RTP channel, sometimes sending a sound (even silence), it can work.
we can also put a response in the dial plan.
exten => 1002,1,Verbose(1, "")
same => n,Answer()
same => n,Stasis(dialogflow)
same => n,Hangup()
issue from @SubhashPeshwa
Hi folks,
Apologies for commenting on a closed thread, but I'm facing the issue with the static sound being returned back from dialogflow too. I've been trying to debug this from the last few days but to no avail!
Some context:-
Asterisk version: 16.6.2 running on FreePBX on a Virtualbox instance (Bridged not NAT) The audioserver running on host Speech enabled - 16 bit linear, not MP3 or OGG Opus On dialing the extension linked to the stasis, the stasis event is fired, the rtp-audio server is invoked, dialogflow sends a response as well! But there's no audio response back to the X-Lite SIP phone.
I thought I'd isolate the issue one at a time and started with the rt-audioserver. When the response file is stored as a wav, it's just static. I even tried uploading the sln file to aserisk and playing it as part of the dialplan, still static.
I have a sneaking suspicion that even though it's static sound when saved as a file, it's not really the root cause of the audio not being played back to SIP phone. I should at least get back some static noise then.
I'm really out of ideas and hence the post here. Apologies in advance if this turns out to be something silly.
Any pointers would be massively appreciated!
Here are some log files:-
ari-logfile.txt
df-reesponse.txt
Asterisk Config:-
exten => 1002,1,Verbose(1, "") same => n,Stasis(dialogflow) same => n,Hangup()
1002 is a pjsip extension