Answering Machine Screening With MixMonitor

Home » Asterisk Users » Answering Machine Screening With MixMonitor
Asterisk Users 2 Comments

I’m using asterisk 1.8 as an answering machine. I’d like to hear the calls it answers aloud in case I want to pick up and interrupt the call.

There are a few articles describing, for example, three-way calling a monitor phone set to auto-answer, but I couldn’t find anything that described how to just send the audio to a local speaker.

I am currently using MixMonitor to append the audio to a named pipe (“mkfifo /home/asterisk/var/soundpipe.au”), as follows (extensions.conf):

[from-pstn]
exten => s,1,Wait(20)
exten => s,2,Answer
exten => s,3,Wait(1)
exten => s,4,Set(TIMEOUT(response))
exten => s,5,MixMonitor(/home/asterisk/var/soundpipe.au,av(2))
exten => s,6,Background(/home/asterisk/sounds/main)

I wrote a small script to loop opening the named pipe and then copying to “/usr/bin/play” from the sox package.

MixMonitor uses the filename extension to determine what format to use for the audio data. I tried all of the formats common to both asterisk (“core show file formats”) and play (as described on the man page), except for “raw”. I’m not sure if “raw” is compatible with sox “play” – I need to determine bit rates and other parameters before I can try it.

I found that in all cases I tested, there was significant latency between the audio on the PSTN line vs. the audio played from the speakers, on the order of 3-10 seconds depending on the format specified. Based on some debug output from my pipe-reader script, it seemed that asterisk opened the write end of the pipe immediately but did not start writing data until the aforementioned delay had passed. “au” and “sln” had the lowest latency (3 seconds), so I’m using “au” for now.

Is there any way to reduce the startup latency and make MixMonitor write the audio stream to the output file immediately? I looked briefly at apps/app_mixmonitor.c and main/file.c but I don’t fully understand the code. Is mixmonitor forking an external conversion process to generate the audio data?

thanks for any insights!

2 thoughts on - Answering Machine Screening With MixMonitor

  • A local speaker connected to the Asterisk box itself? Console channel driver, chan_alsa (or chan_oss for old drivers).

    You’ll probably end up with kind of a Rube Goldbergish approach, probably something involving ChanSpy or a conferencebridge to take the place of mixmonitor.

  • Have you considered using chan_alsa or chan_oss?

    I don’t know much about it, but I’ve heard that you can use the sound card in the computer as a phone. If you only want to listen, you wouldn’t need a microphone.