I’m developing an Asterisk-based application that receives audio from a caller, processes it through a Speech-to-Text engine, and sends back generated audio from a Text-to-Speech engine.
I’ve read several posts and Asterisk documentation on this topic but still can’t get it to work correctly.
Current Implementation:
I’m using a Mixing Bridge with three channels: a PJSIP channel, an out_external_media channel, and an in_external_media channel.
out_external_media channel: This operates on port 9000, where another server captures the audio and saves it as a WAV file. This part works well—I can hear the caller’s audio clearly in the saved file.
in_external_media channel: This operates on port 9001, where another server generates audio and sends it back over port 9001. However, this part does not work—the caller doesn’t hear any audio. (All ports are open on the firewall, so I don’t believe this is a firewall issue. In a previous configuration, I did hear white noise on the caller side, so audio can pass in this direction.)
Asterisk Configuration Files:
/etc/asterisk/extensions.conf
[general]
static=yes
writeprotect=no
clearglobalvars=no
[from-trunk]
; Handle incoming calls from the trunk and route to ARI app
exten => s,1,NoOp(Incoming call to ARI app)
same => n,Stasis(hello-world) ; ARI app name as defined in your Python app
same => n,Hangup() ; Ensure proper call cleanup
Could you please help identify any misconfigurations or suggest solutions for getting audio output to work on the in_external_media channel? Thanks for your assistance!
There is no snoop channels at all.
Receiving audio from Asterisk works well, just sending back audio is not working for me - i.e. the caller doesn’t hear the audio
I face a simillar issue when the duration of the audio being injected is less than 5sec. Audio of 10 sec goes fine. What is the duration of audio that you are injecting ?
I face a simillar issue when the duration of the audio being injected is less than 5sec. Audio of 10 sec goes fine. What is the duration of audio that you are injecting ?
Unfortunately, I still can’t hear the audio on the caller’s side. I’m sending audio every 20ms in 160-byte chunks (172 bytes with a 12-byte header). I’ve also muted the PJSIP channel, so audio isn’t being sent from the PJSIP to the bridge.
One odd thing is that in the Asterisk CLI, I see the following log:
Sent RTP packet to 127.0.0.1:9001 (type 00, seq 012804, ts 1003360, len 000160)
It appears as though the audio is going in the opposite direction (from PJSIP to the external channel).
Here are my channels and bridges:
core show channels
Channel Location State Application(Data)
UnicastRTP/127.0.0.1:9001-0x55d9ac7bc560 s@default:1 Up Stasis(hello-world)
Snoop/1730987233.346-0000000f s@default:1 Up Stasis(hello-world)
PJSIP/siptrunk-00000035 s@from-trunk:2 Up Stasis(hello-world)
bridge show all
Bridge-ID Chans Type Technology Duration
f1625f10-1c9f-43e6-8b3e-64b933b6581d 3 stasis softmix 00:00:35
bridge show f1625f10-1c9f-43e6-8b3e-64b933b6581d
Id: f1625f10-1c9f-43e6-8b3e-64b933b6581d
Type: stasis
Technology: softmix
Subclass: stasis
Creator: Stasis
Name:
Video-Mode: talker
Video-Source-Id:
Num-Channels: 3
Num-Active: 3
Duration: 00:00:43
Channel: PJSIP/siptrunk-00000035
Channel: UnicastRTP/127.0.0.1:9001-0x55d9ac7bc560
Channel: Snoop/1730987233.346-0000000f