RSS is an XML format that supports the syndication of news stories and similar content. There are several different formats for XML syndication that are referred to as RSS. Depending on the version, RSS can mean “Really Simple Syndication,” or “RDF Site Summary.” These different versions are the result of a bifurcated development process. A good overview of the history of RSS and a description of the different formats in use can be found on XML.com.
RSS has several characteristics that make it ideal for phone-based access. First, the various RSS formats are widely used – as an example, a listing of over 10,000 publicly available RSS feeds can be found at Syndic8.com. Second, the nature of RSS feeds is ideal for voice delivery – RSS feeds contain abbreviated information about a news item or event. Since it would be highly impractical to deliver the entire content of a news story or a detailed description of an event via VoiceXML, the abbreviated format of RSS fits the bill nicely. Using RSS to create “voice-enabled” news feeds is an easy way of creating a dynamic VoiceXML application.
Turning RSS into VoiceXML
Since RSS is an XML format, turning it into VoiceXML (another XML format) is a piece of cake with eXstensible Style Sheet Language Transformations (XSLT). In a nutshell, XSLT is a transformation vocabulary that specifies how to create new structured information from existing documents that are in XML format. In other words, XSLT is a language for changing XML documents (like RSS feeds) into other XML documents (like VoiceXML).
Converting RSS to HTML is relatively easy, and examples of how to do this through XSLT are numerous. This tutorial will show you how to turn an RSS 2.0 feed (say the feed provided by CNET.com news) into VoiceXML. It will also show you how to modify your XSLT file to improve the quality of the text-to-speech (TTS) generation that will allow callers to hear these news stories.
Getting Started — Building the Style Sheet
For some basic information on XSLT, readers are encouraged to review the XSLT tutorial on the W3Schools site With that out of the way, we’re ready to develop our RSS-to-VXML style sheet. Like most style sheets, it begins with the following:
<?xml version=“1.0” encoding=“UTF-8”?>
<xsl:stylesheet version=“1.0” xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no"/>
XSLT uses â€œtemplatesâ€ to transform parts of a source document into a result document. The template rules outlined with XSLT specify how the different parts of the source document are to be selected and transformed into new parts in a result document. For our purposes, we want to take the relevant sections of the RSS feed and present them to users in VoiceXML. As such, the next part of our XSLT file will look like the following:
XSLT uses “templates” to transform parts of a source document into a result document. The template rules
outlined with XSLT specify how the different parts of the source document are to be selected and transformed into new parts in a
result document. For our purposes, we want to take the relevant sections of the RSS feed and present them to users in VoiceXML. As such, the next part of our XSLT file will look like the
<vxml version=“2.0” xmlns=“http://www.w3.org/2001/vxml”>
Here are the latest headlines from See Net News Dot Com.
<xsl:value-of select="title" />
<break size="small" />
<xsl:value-of select="description" />
<break size="medium" />
This section of the style sheet essentially does two things. First, very simply, it tells the caller that this is a headline service providing stories from CNET News.com. I’ve opted to use the <voice> element to specify a specific characteristic of the TTS output. In this case, I’ve indicated that I want the output rendered using a female voice. I’ve done this by using the “gender” attribute, and setting it equal to “female.” This isn’t required, but I think it improves the overall listening experience for the caller. (I’ve opted to change to a “male” voice to read the actual headlines.) Notice also that the title of the service is spelled out phonetically to assist the TTS engine in pronouncing the words properly – we will discuss this in more detail later in this tutorial.
The second thing this code section does is loop through the source RSS document (using the XSLT <xsl:for-each> element) and presents the caller with the contents of each RSS news item. We do this by using the VoiceXML <prompt> element as a generic container for the text contained in the appropriate parts of the source document — namely, the title and description of each news item. We also use the <break> element to help the caller understand when a new item begins and ends.
Since some of these stories may pique the interest of our callers, we may want to provide the option of listening to them again. Before doing this, you may want to determine the number of stories that are typically included in the RSS feed you will be using. In RSS 0.91, various elements are restricted to 500 or 100 characters. There can be no more than 15 <items> in an RSS 0.91 <channel>. In addition, some RSS feeds that utilize a later version of RSS (e.g., 0.92, 2.0) may adhere to these limits to ensure backward compatibility. The CNET News.com feed that I use in this example typically only has 5 to 6 stories at a time.
To provide the option of listening to stories again I utilize one of the built in grammars provided for in the VoiceXML 2.0 specification. A boolean grammar recognizes a positive or negative response by the caller and can be structured like the following.
<field name=“repeat” type=“boolean”> <prompt>Do you want to hear these headlines again?</prompt>
Put it all together, and you now have an XSLT document that will transform an IT news feed into a VoiceXML document that can be accessed from any ordinary telephone, or cell phone.
Transforming the RSS Feed
An excellent tutorial on using PHP to carry out XSLT Transformations can be found on the Zend site. Similar tutorials for both Perl and Java Server Pages are also available. Pick your poison – then upload your XSLT file and any code needed to carry out the transformation to a web location. If your using an ASP to host your VoiceXML applications (there is typically a developer area where you can upload and test stuff), point it at the location of your files and you’ll be in business.
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License.