After hearing about Asterisk for the millionth time I finally decided to take the leap from boys’ VoIP (Skype) to mens’ VoIP by setting up my own PBX. It took a couple of days for me to learn the basics, but this page will detail my adventures with the *.

My extensions.conf is available here.

Slashdot RSS Feed Reader (ISN 7001*939 / sip:slashdot@sip.uberpipe.co.uk)

Ext 7001 Pri 1
PHP script fetches RSS feed from /., each line is the innerXML from the //ITEM[]/TITLE tag from the RSS feed, with the word “break” appended to each line to signify EOL (otherwise, sentences would run together as the feed gets read to the listener). This is the passed into Flite’s standard input for speech synthesis.

The get_slashdot_news.php script looks like this (very simple):

<?
        $sd_rss_feed = "http://rss.slashdot.org/Slashdot/slashdot";
        $sd_sxml = new SimpleXMLElement(file_get_contents($sd_rss_feed));
        foreach($sd_sxml->item as $item){
                $outstr .= $item->title . ". break.\r\n";
        }
        echo $outstr;
?>

The output looks like this:

cmn@ubercdn-tcsov:/etc/asterisk$ php /usr/share/agi-scripts/get_slashdot_news.php
BBC's Open Player Claims Not Followed Through. break.
Debian's Testing Branch Nears Completion. break.
reCAPTCHA Hard At Work, Rescuing Fading Texts. break.
Netflix Woes Mean a Gap In Shipments. break.
Using Photographs To Enhance Videos. break.
What Will Linux Be Capable Of, 3 Years Down the Road?. break.
30% of Americans Want "Balanced" Blogging. break.
Slashdot's Disagree Mail. break.
Violent Video Gaming Comes To the Wii. break.
Slashdot Announces Idle Section. break.
Americans Refusing To Wait For Mainstream EVs. break.
The Evolution of Sega. break.
Literacy Bridge Founder Answers Your Questions. break.
Psystar "Definitely Still Shipping" Mac Clones. break.
Intel Releases USB 3.0 Controller Interface Spec. break.

extensions.conf:

exten => 7001,1,System(php /usr/share/agi-scripts/get_slashdot_news.php | flite - /tmp/sdnewsout_tmp.wav)

Ext 7001 Pri 2

Output from fLite is encoded using Sox. GSM and uLaw/aLaw voice codecs only carry voice in 1 channel 8kHz 16bit SBC/SL, whereas the output from Flite is 16kHz unsigned 16-bit PCM. Also specified was a 45-bit sampling window (-qs; see man sox) so that Sox would resample the file in the quickest possible time at the expense of stop-band rejection accuracy (very high/low frequencies can “leak” into the passband, accounting for some wierd artefacts from time to time).

extensions.conf:

exten => 7001,2,System(sox /tmp/sdnewsout_tmp.wav -r 8000 -c 1 -s -w /tmp/sdnewsout.gsm resample -ql )

Ext 7001 Pri 3 & 4

The final resampled .gsm file is finally copied into Asterisk’s sound library in /var/lib/asterisk/sounds/, and then played to the caller via Asterisk’s Playback() application.

extensions.conf:

exten => 7001,3,System(cp /tmp/sdnewsout.gsm /var/lib/asterisk/sounds/)
exten => 7001,4,Playback(sdnewsout)

Hmm, looking at the feeds (on the sidebar of this page) I want to do a Twitter version now. This could be quite awesome.

Post a Comment

*
*