Skip to content

Specifying message language

Jean-Philippe Gariépy edited this page Dec 2, 2013 · 1 revision

For each message turn, you can set the language field:

Dialogue.java:

//Play a synthesis message in another language
Message message = new Message("synthesis-french-message",
                              new SpeechSynthesis("Ceci est un message."));
message.setLanguage("fr-CA");
DialogueUtils.doTurn(message, context);

This can also be done globally at the VoiceXML level:

Dialogue.java:

//Alternatively, you can change the default VoiceXML language. This is done in the context.
//This will change the language for all up coming message for which no language has been set. 
context.setLanguage("fr-CA");

Message otherMessage = new Message("synthesis-french-message",
                                   new SpeechSynthesis("Ceci est un autre message."));
DialogueUtils.doTurn(otherMessage, context);

Message yetAnotherMessage = new Message("synthesis-french-message",
                                        new SpeechSynthesis("Et encore un."));
DialogueUtils.doTurn(yetAnotherMessage, context);

Running this example

You can download or browse the complete code for this example at GitHub.This is a complete working application that you can build and run for yourself.

You can also clone the Rivr Cookbook repository and checkout this example:

git clone -b message-language git@github.com:nuecho/rivr-cookbook.git

Then, to build and run it:

cd rivr-cookbook

./gradlew jettyRun

The VoiceXML dialogue should be available at http://localhost:8080/rivr-cookbook/dialogue

To stop the application, press Control-C in the console.