Mod shell stream
From FreeSWITCH Wiki
Mod shell stream is a module to allow you to stream audio from an arbitrary shell command. You could use it to read audio from a database, from a soundcard, etc.
To use it, you call it from the dialplan like this:
<action application="playback" data="shell_stream:///tmp/moh"/>
Now, when this application is triggered, the command /tmp/moh is called with 2 arguments -r <rate> and -c <channelcount>, which in the usual case are 8000 and 1 respectively.
The contents of my sample /tmp/moh script is as follows:
#!/bin/sh cat /tmp/tt-weasels.wav | sox -t wav - $@ -t raw -
Which cats an audio file into sox on stdin and tells sox to output raw audio at 8000hz, 1 channel to stdout. You could of course replace the cat command with anything that outputs audio and use sox to process it into the requested raw output.
You can also pass arguments to the command, by doing something like this:
<action application="playback" data="shell_stream:///tmp/moh /tmp/tt-weasels.wav wav"/>
And the corresponding script becomes:
#!/bin/sh AUDIO=$1 TYPE=$2 shift 2 cat $AUDIO | sox -t $TYPE - $@ -t raw -
Basicially the sky is the limit, if you're willing to write the script or program to do what you need.