Voice RSS – Let your blog speak – Part I January 19, 2009

How often have you thought that it would be a cool idea to hear your favorite RSS feeds? If you are a blogger or a webmaster, wouldn’t it be a nice addition to have your blogs be spoken to the reader?

Well, think no more. Code below shows a simple implementation of an Voice RSS Reader.
Here are the key steps of this application:


This example demonstrates advanced usage of the prompt API. In particular, check out:

Enjoy the simplicity of VoicePHP. In Part II, we will enhance this application using ASR (automatic speech recognition).

<?php
include_once ("rssutils.php");

// Feed Provider Name & URL (Below list in alphabetical order)
$rss = array (
    array(
'Giga Om''http://feedproxy.google.com/ommalik'),
    array(
'New York Times''http://www.nytimes.com/services/xml/rss/nyt/Americas.xml'),
    array(
'Plugged In''http://feedproxy.google.com/pluggd'),
    array(
'Read Write Web''http://feeds2.feedburner.com/readwriteweb'),
    array(
'Tech Crunch''http://feedproxy.google.com/TechCrunch'),
    array(
'USA Today''http://rssfeeds.usatoday.com/usatoday-NewsTopStories')
    );

$feedcount count($rss);

$prompttext '';
for(
$i 1$i <= $feedcount$i++) 
    
$prompttext .= "press $i to hear news from {$rss[$i-1][0]}, ";

$prompttext .= 'press 0 to exit';
echo 
"Welcome to the Voice PHP demo of voice RSS reader.";
$choice '';
$loop_count 3;
while(
$loop_count) {
    
setvoiceoption("voicetype"'female');
    
$choice prompt($prompttext13"dtmf:1");
    
    if(
$choice == '0'
        break;

    if(
$choice $feedcount) {
        echo 
"Invalid choice, try again";
        
$loop_count--;
        continue;
    }
    

    
speak_rss($rss[$choice-1][0], $rss[$choice-1][1]);
    break;
}

echo 
"Thank you for trying out Voice PHP demo.";

function 
speak_rss ($name$url) {
    
// Get RSS feeds from the selected feed using a helper function
    
if (false == get_rss($url5512, &$result)) {    
        return;
    }
    
$loop_count 3;
    while(
$loop_count) {
        
setvoiceoption("voicetype"'female');
        echo(
"Reading news title from $name now. At any time, 
              press 1 to get details on the news, 
              press 0 to exit."
);
                
        for(
$count=0$count count($result); $count++) {

            
$choice '';
            
$voicetype = ($count&1)?"female":"male";
            
setvoiceoption("voicetype"$voicetype);
            
            
$choice prompt($result[$count]['title'], 11"dtmf:1");

            if(
$choice == '1'
                
$choice prompt($result[$count]['description'], 11"dtmf:1");
                
            if(
$choice == '0'
                return;                
        }                
        
sleep(1);
        
$loop_count--;
    }            
// End of function speak_rss

?>

Download source code


Try It Now!

Click the button below or call +15672449192 to run the application.

Does'nt it look easy? Try VoicePHP for yourself and feel free to modify the above script. VoicePHP is easy and accessible from your free TringMe account. More details at http://voicephp.com/howitworks.html

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments

2 Comments so far
  1. links for 2009-01-20 | stuart henshall January 20, 2009 12:08 pm

    [...] TringMe launches a new VoicePHP blog with a code example a day. Yusuf and his team are doing a great job developing examples so even someone like me with a basic code understanding can work out how it's working and the power of applications we could put VoicePHP to. (tags: voip voicephp tringme) [...]

  2. [...] is an example running at the site for you to check out! Tags: Voice RSS Reader, Tringme, voicePHP Snap Voip Copyright © 2005-2008 [...]

© Copyright TringMe., All rights reserved. - Blog powered by Wordpress - Designed by Speckyboy