Intro to the Asterisk Dialplan: Phoneoke

In Redial, we’ve started working with Asterisk to create our own phone systems. In class, we share a common phone number and each have our own extension, which, when dialed, runs our code. After looking through the available Asterisk commands, I decided I wanted to have the caller record their voice and have Asterisk play it back, except mixed with a backing track (in this case, the chorus to TLC’s Waterfalls). Here’s what that sounds like (with apologies to TLC):

After the caller records his voice, I use Asterisk’s System command to runĀ SoX, a command line tool that mixes the caller’s voice with the backing track and converts it to the correct format for playback. A few issues I ran in to concerning playback:

  • Asterisk’s Playback command requires no file extension on the end. I was adding .wav and this caused errors.
  • Despite both the caller’s recording and my backing track being in the correct format for playback, the mixed file wasn’t and playback would fail. After mixing the files with sox -m /path/to/file1.wav /path/to/file2.wav /path/to/mix.wav, I then had to run sox /path/to/mix.wav -t raw -r 8000 -e signed-integer -b 16 -c 1 /path/to/remix.sln to ensure that the audio file’s properties met Asterisk’s requirements (8000 Hz, 16 bit, etc). Those two commands could probably be combined into one and I will look in to that as this project continues.

Since the application will probably be short-lived as I continue to experiment with it, I’m going to leave the phone number and extension out of this post and save it for later (though you can probably find it by following the right links…).