Tropo WebAPI Development Guide Home  |  Frameset Home

  Answering Incoming Calls  |  TOC  |  Recording Audio  

Playing Audio Files


Playing audio on an inbound call is just as easy as using Text To Speech (TTS) - just provide the say with a link to an accessible audio file and Tropo will play it back:

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

post '/index.json' do

    t = Tropo::Generator.new

    t.say "http://www.phono.com/audio/troporocks.mp3"

    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("http://www.phono.com/audio/troporocks.mp3");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 
<?php

require 'tropo.class.php';

$tropo = new Tropo();
$tropo->say("http://www.phono.com/audio/troporocks.mp3");
$tropo->RenderJson();

?>
from itty import *
from tropo import Tropo

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

    t = Tropo()
    t.say(["http://www.phono.com/audio/troporocks.mp3"])
    return t.RenderJson()

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

{
   "tropo":[{"say":{"value":"http://www.phono.com/audio/troporocks.mp3"}}]
}

"Accessible audio file" can mean a file hosted completely external - on your server, from a hosting service, etc - or it can be a file hosted internally on our servers.

You can also play multiple audio files in the same say (or ask, or record, message, etc):

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

post '/index.json' do

    t = Tropo::Generator.new

    t.say "http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3"

    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("http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 
<?php

require 'tropo.class.php';

$tropo = new Tropo();
$tropo->say("http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3");
$tropo->RenderJson();

?>
from itty import *
from tropo import Tropo, Session

@post('/index.json')
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.say(["http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3"])
    return t.RenderJson()

run_itty(server='wsgiref', host='0.0.0.0', port=8888)
{
   "tropo":[{"say":{"value":"http://www.phono.com/audio/troporocks.mp3 http://www.phono.com/audio/holdmusic.mp3"}}]
}

You can also mix and match audio with text-to-speech:

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

post '/index.json' do

    t = Tropo::Generator.new

    t.say "http://www.phono.com/audio/troporocks.mp3 Here's some hold music! http://www.phono.com/audio/holdmusic.mp3"

    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("http://www.phono.com/audio/troporocks.mp3 Here's some hold music! http://www.phono.com/audio/holdmusic.mp3");
	
	response.end(TropoJSON(tropo));

}).listen(8000); 
<?php

require 'tropo.class.php';

$tropo = new Tropo();
$tropo->say("http://www.phono.com/audio/troporocks.mp3 Here's some hold music! http://www.phono.com/audio/holdmusic.mp3");
$tropo->RenderJson();

?>
from itty import *
from tropo import Tropo, Session

@post('/index.json')
def index(request):
    s = Session(request.body)
    t = Tropo()
    t.say(["http://www.phono.com/audio/troporocks.mp3 Here's some hold music! http://www.phono.com/audio/holdmusic.mp3"])
    return t.RenderJson()

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

{
   "tropo":[{"say":{"value":"http://www.phono.com/audio/troporocks.mp3 Here's some hold music! http://www.phono.com/audio/holdmusic.mp3"}}]
}

Want to record the user's input?

Next Step: Recording Audio



Additional Reading

To find out more about hosting audio files with us, read the Hosting Audio Files chapter.

We also offer generic voice prompts professionally recorded in US English for your use. These voice prompts are released under the LGPL opensource license. Feel free to download and use them for your own phone applications.


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

login
  Answering Incoming Calls  |  TOC  |  Recording Audio  

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