cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
329
Views
0
Helpful
0
Comments
cdnadmin
Community Member
This document was generated from CDN thread

Created by: null on 08-08-2007 05:56:36 PM
I am trying to create an Audio element that will handle 4 situations.

int a = 23
int b = 11

if a >= 0
Your account has a balance of <balance>
if b >=0
Your account is past due in the amount of <pastDue>
if a < 0
Your account has a credit of <balance>
if b < 0
You have no past due amount

Can I do this with a Dynamic Config or should I create a Custom Element?

Subject: RE: Dynamic Audio Element
Replied by: Janine Graves on 09-08-2007 12:26:12 AM
it would be easiest to just create a dynamic configuration for an audio element. All you are doing is adding audio prompts based upon some variable values. That should be pretty straightforward.

Subject: RE: Dynamic Audio Element
Replied by: null on 09-08-2007 12:59:13 PM
Can you send an example of adding an audio element in a configuration?

Subject: RE: Dynamic Audio Element
Replied by: Janine Graves on 10-08-2007 01:09:27 AM
Here's a sample that I use in my training class to show how to create a dynamic configuration for a form element. It builds voice keywords and audio prompts. It assumes a Base Configuration is passed from CVP Studio.

(NOTE - it has NOT been tested in production, just in classroom by calling in. It is meant as a demonstration, not as a foolproof piece of code).

You should come to training!

Janine
www.TrainingTheExperts.com

Subject: RE: Dynamic Audio Element
Replied by: Janine Graves on 10-08-2007 01:11:34 AM
I tried to attach it, but that didn't word. Here it is inline.

// These classes are used by dynamic voice element configurations.
import com.audium.server.AudiumException;
import com.audium.server.proxy.VoiceElementInterface;
import com.audium.server.session.ElementAPI;
import com.audium.server.xml.VoiceElementConfig;

/**
* This class would be called if the voice element configuration is to be
* dynamically generated. Note that the interface to implement is named
* VoiceElementInterface for backwards compatibility purposes.
*/
public class JaninesDynamicVoiceMenu implements VoiceElementInAAterface
{
/**
* This method is expected to assemble the completed voice element
* configuration. It receives the base configuration created by Audium
* Builder for Studio which this method can edit to represent the desired
* configuration. If no base configuration is defined in the Builder, the
* third argument to the method is null. ElementAPI is used to interface
* with the system such as creating variables.
*/
public VoiceElementConfig getConfig(String name,
ElementAPI elementAPI,
VoiceElementConfig defaults) throws AudiumException
{
//set up the Audio prompts for the initial audio
VoiceElementConfig.AudioGroup initialAudioGroup;

//If no audio exists yet, then create an initial audio group. Else add to existing.
if(defaults.getAudioGroup("initial_audio_group",1) == null){
initialAudioGroup = defaults.new AudioGroup("initial_audio_group", true);//true=allow bargein
} else {
initialAudioGroup = defaults.getAudioGroup("initial_audio_group",1);
}
VoiceElementConfig.StaticAudio prompt1 =
defaults.new StaticAudio("Say call mom", null);
VoiceElementConfig.StaticAudio prompt2 =
defaults.new StaticAudio("or call home", null);
VoiceElementConfig.StaticAudio prompt3 =
defaults.new StaticAudio("or call work", null);

initialAudioGroup.addAudioItem(prompt1);
initialAudioGroup.addAudioItem(prompt2);
initialAudioGroup.addAudioItem(prompt3);

// Add the initial Audio Group to the Voice Element Configuration.
defaults.setAudioGroup(initialAudioGroup);

//Now work on the voice keyword settings to build the grammar
String[] VoiceKeywords = defaults.getSettingValues("voice_keyword",elementAPI);

if (VoiceKeywords != null &#38;&#38; VoiceKeywords.length!=0){

// can only ADD more values to a setting, one at a time
defaults.addSettingValue("voice_keyword","call mom [555-1212]");
defaults.addSettingValue("voice_keyword","call home[555-1313]");
defaults.addSettingValue("voice_keyword","call work[1-800-555-1000]");
} else {
// when creating a NEW setting, we can use an array to set the values
defaults.setSettingValues("voice_keyword",new String[]{"call mom [555-1212]",
"call home[555-1313]","call work[1-800-555-1000]" });
}

// Alter defaults or create a new configuration and return.
return defaults;
}
}

Subject: RE: Dynamic Audio Element
Replied by: Janine Graves on 10-08-2007 01:11:45 AM
I tried to attach it, but that didn't word. Here it is inline.

// These classes are used by dynamic voice element configurations.
import com.audium.server.AudiumException;
import com.audium.server.proxy.VoiceElementInterface;
import com.audium.server.session.ElementAPI;
import com.audium.server.xml.VoiceElementConfig;

/**
* This class would be called if the voice element configuration is to be
* dynamically generated. Note that the interface to implement is named
* VoiceElementInterface for backwards compatibility purposes.
*/
public class JaninesDynamicVoiceMenu implements VoiceElementInAAterface
{
/**
* This method is expected to assemble the completed voice element
* configuration. It receives the base configuration created by Audium
* Builder for Studio which this method can edit to represent the desired
* configuration. If no base configuration is defined in the Builder, the
* third argument to the method is null. ElementAPI is used to interface
* with the system such as creating variables.
*/
public VoiceElementConfig getConfig(String name,
ElementAPI elementAPI,
VoiceElementConfig defaults) throws AudiumException
{
//set up the Audio prompts for the initial audio
VoiceElementConfig.AudioGroup initialAudioGroup;

//If no audio exists yet, then create an initial audio group. Else add to existing.
if(defaults.getAudioGroup("initial_audio_group",1) == null){
initialAudioGroup = defaults.new AudioGroup("initial_audio_group", true);//true=allow bargein
} else {
initialAudioGroup = defaults.getAudioGroup("initial_audio_group",1);
}
VoiceElementConfig.StaticAudio prompt1 =
defaults.new StaticAudio("Say call mom", null);
VoiceElementConfig.StaticAudio prompt2 =
defaults.new StaticAudio("or call home", null);
VoiceElementConfig.StaticAudio prompt3 =
defaults.new StaticAudio("or call work", null);

initialAudioGroup.addAudioItem(prompt1);
initialAudioGroup.addAudioItem(prompt2);
initialAudioGroup.addAudioItem(prompt3);

// Add the initial Audio Group to the Voice Element Configuration.
defaults.setAudioGroup(initialAudioGroup);

//Now work on the voice keyword settings to build the grammar
String[] VoiceKeywords = defaults.getSettingValues("voice_keyword",elementAPI);

if (VoiceKeywords != null &#38;&#38; VoiceKeywords.length!=0){

// can only ADD more values to a setting, one at a time
defaults.addSettingValue("voice_keyword","call mom [555-1212]");
defaults.addSettingValue("voice_keyword","call home[555-1313]");
defaults.addSettingValue("voice_keyword","call work[1-800-555-1000]");
} else {
// when creating a NEW setting, we can use an array to set the values
defaults.setSettingValues("voice_keyword",new String[]{"call mom [555-1212]",
"call home[555-1313]","call work[1-800-555-1000]" });
}

// Alter defaults or create a new configuration and return.
return defaults;
}
}
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Quick Links