Tropo WebAPI Development Guide Home  |  Frameset Home

  Advanced Grammar (SRGS/GRXML)  |  TOC  |  Advanced Audio Concepts  

Manipulating Say with SSML


There are many cases when you need or just want to control the pitch, volume and intonation of your prompts and responses. To make this easy, Tropo natively supports a standard called the Synthesized Speech Markup Language (SSML).

SSML is an international standard from the W3C for controlling the pace, tone, pitch and all around sound of computer-generated voices. Here’s a script that repeats the same sentence four times; each at a gradually lower speed:

require 'tropo-webapi-ruby'
require 'sinatra'

post '/index.json' do
  
  t = Tropo::Generator.new
  
  t.say "One potato, two potato, three potato, four. One potato, two potato, three potato, four."
  
  t.response

end
var http = require('http');
var tropo_webapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {
	
	var tropo = new TropoWebAPI();

	tropo.say("One potato, two potato, three potato, four. One potato, two potato, three potato, four.");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 
<?php

require('tropo.class.php');

$tropo = new Tropo();
$tropo->say("One potato, two potato, three potato, four. One potato, two potato, three potato, four.");
$tropo->RenderJson();

?>
from itty import *
from tropo import Tropo

@post('/index.json')
def index(request):

    t = Tropo()
    t.say("One potato, two potato, three potato, four. One potato, two potato, three potato, four.")
    return t.RenderJson()

run_itty(server='wsgiref', host='0.0.0.0', port=8888)

{
   "tropo":[
      {
         "say":[
            {
               "value":"One potato, two potato, three potato, four. One potato, two potato, three potato, four."
            }
         ]
      }
   ]
}

say-as


In addition to controlling pitch, volume and intonation, there are also times when you need to control how the Text to Speech engine interprets text, especially numbers. The SSML say-as element allows you to define whether the text should be interpreted as currency, digits, number, date, and time. While most of the options are self-explanatory, it may help to note that digits will interpret the text as individual numbers instead of one complete number ('1234' will be interpreted as 'one, two, three, four') while number will interpret the text as a complete value ('1234' will sound like 'one thousand two hundred thirty four'). Here's a code example displaying the use of say-as:

require 'tropo-webapi-ruby'
require 'sinatra'

post '/index.json' do
  
  t = Tropo::Generator.new
  
  t.say "<?xml version='1.0'?>USD51.33"
  t.say "<?xml version='1.0'?>12345678"
  t.say "<?xml version='1.0'?>1234.5678"
  t.say "<?xml version='1.0'?>20110205"
  t.say "<?xml version='1.0'?>12:00p"
    
  t.response

end
var http = require('http');
var tropo_webapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {
	
	var tropo = new TropoWebAPI();

	tropo.say("<?xml version='1.0'?>USD51.33");
	tropo.say("<?xml version='1.0'?>12345678");
	tropo.say("<?xml version='1.0'?>1234.5678");
	tropo.say("<?xml version='1.0'?>20110205");
	tropo.say("<?xml version='1.0'?>12:00p");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 
<?php

require('tropo.class.php');

$tropo = new Tropo();

$tropo->say("<?xml version='1.0'?>USD51.33");
$tropo->say("<?xml version='1.0'?>12345678");
$tropo->say("<?xml version='1.0'?>1234.5678");
$tropo->say("<?xml version='1.0'?>20110205");
$tropo->say("<?xml version='1.0'?>12:00p");

$tropo->RenderJson();

?>
from itty import *
from tropo import Tropo

@post('/index.json')
def index(request):

    t = Tropo()
    t.say("<?xml version='1.0'?>USD51.33")
    t.say("<?xml version='1.0'?>12345678")
    t.say("<?xml version='1.0'?>1234.5678")
    t.say("<?xml version='1.0'?>20110205")
    t.say("<?xml version='1.0'?>12:00p")
    return t.RenderJson()

run_itty(server='wsgiref', host='0.0.0.0', port=8888)

{
   "tropo":[
      {
         "say":[
            {"value":"<?xml version='1.0'?>USD51.33"}
         ]
      },
      {
         "say":[
            {"value":"<?xml version='1.0'?>12345678"}
         ]
      },
      {
         "say":[
            {"value":"<?xml version='1.0'?>1234.5678"}
         ]
      },
      {
         "say":[
            {"value":"<?xml version='1.0'?>20110205"}
         ]
      },
      {
         "say":[
            {"value":"<?xml version='1.0'?>12:00p"}
         ]
      }
   ]
}

Next Step: Advanced Audio Concepts



Additional Reading

To learn more about SSML and related technologies, check out the W3C site at http://www.w3.org/TR/speech-synthesis/.


  ANNOTATIONS: EXISTING POSTS
0 posts - click the button below to add a note to this page

login
  Advanced Grammar (SRGS/GRXML)  |  TOC  |  Advanced Audio Concepts  

© 2012 Voxeo Corporation  |  Voxeo IVR  |  VoiceXML & CCXML IVR Developer Site