Extracting received audio/bytes out of Asterisk


I’m trying to receive a message via VoIP.
Is there a way to get the received data after the speech decoder? So Asterisk don’t play any beep tones but I get the bytes instead?
Any help is really appreciated!


Are we talking DTMF here? On most VoIP configurations, there is no modulation step, and demodulation happens when PSTN connects into VoIP.

I’m fairly sure that DTMF is not forwarded if it matches a feature code, and I don’t think it is regenerated if the code eventually doesn’t match. Otherwise you have to misconfigure the outgoing side to stop the DTMF being forwarded, which is operating outside specification.

A feature code could trigger logic that reads the DTMF with the channels temporarily unbridged.

Also, if demodulation does happen anywhere in the system, some tone is likely to leak through before the system detects that it has a tone.


Hi thanks for your fast replay!
I don’t mean DTMF, sorry for not mentioning that. I have one side that takes some bytes and uses a speech encoder so that it can be send over a “normal” voice channel. Now I want to receive that message with my Asterisk server and decode it with a script.
EDIT: sorry I didn’t meant demolutation I meant speech decoder


Asterisk doesn’t have any inbuilt facility for demodulating anything but DTMF and the slow modem signalling used for alarm systems. You can bolt on fax demodulation.

I don’t know what you mean by a speech encoder, and therefore don’t understand where the beeps come from. Can you provide details of the published specification to which the encoder complies. Also, note that many VoIP codecs do not provide a 3.1kHz audio, service, as required by most devices sending data over phone lines; they only provide a speech service. Even DTMF won’t work over a speech service, which is one reason for RFC 2833.

Googling “speech encoder” results on hits for sending speech over a data channel, not data over a speech or audio channel.


The message is converted into waveform symbols which are suitable for transmission through speech codecs, that is what I meant with speech encoder/decoder so I’m having a speech like waveform that Asterisk trys to interpret as speech. That is also what I meant with beep tones.
Is it possible to record the received audio with the ChanSpy() application, maybe that is a good way to start?


You can record with Monitor or MixMonitor. You won’t get the original waveform, of course, and you will need to use a signed linear format to get a waveform at all (A-law and Mu-Law will be close, but on a sort of logarithmic scale).

Hopefully, if the modulation is suitable for current day speech channels, the waveform you get will still demodulate, but you will need to do the demodulation. Theoretically a speech channel might only work for human spoken language, so the only 100% coding is to code the message as real speech.

Monitor and MixMonitor will still forward to the destination.

You can also use Record.

I don’t see what advantage ChanSpy gives you. You still need to run a recording application.

You can, of course, use AGI to capture the stream in real time,


Hi David,
after some testing I think the record application is the best way to start, thanks!
Is there a way to use the data that the Record application is collecting instead of saving it as a audiofile? I don’t really understand where and how it gets the data.


Record captures the individual frames in the same way that Dial does, but record sends them to a file whereas Dial send them to the outgoing channel.

AGI provides facilities for real time caputre.


Hi David,
could you tell me which facilities there are for real time capture please? And how to use them?


David has already provided the functionality that exists within Asterisk to do recording and spying. Outside of Asterisk packet captures can be done of the RTP as it flows.


Hi Jcolp,

thanks for your answer! I’m afraid I’m a real Asterisk newbie, but I have this project in a course where I have to transmit audio data to and from Asterisk. This should be done using SIP/RTP but I really have no idea how to do that. May I ask if you could explain how to capture the RTP flow? Or guide me to a manual or so? This would be great!

Edit: I found this paper and I basically need to do exacly the same what the “Ecall worker” from germany’s pilot (Page 33+) does. Unfurtunately it is only briefly explained.


Asterisk does not provide a mechanism to record/store low level RTP traffic. The functionality David mentioned is what is available in Asterisk to record only the audio portion of the stream. I can’t really provide a guide on their usage because they are single applications you invoke in your dialplan logic, there is nothing else to them. Where they go, their values, etc, all depend on you. They are documented on the wiki as to what they take with MixMonitor being an example[1].

I’m not really sure there’s anything else of value I can add to this thread.

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Application_MixMonitor


OK thank you, I’ll try to get something done with these applications