This document was generated from CDN thread
Created by: Joe Zamora on 03-01-2012 06:45:08 PM
Hello all,
I'm converting some legacy code to the latest version of CVP, and I'd like to get some advice on the approach I'm taking.
I've got a bunch of Audio elements with dynamic configurations (implements VoiceElementInterface), and I'd like to convert them to configurable voice elements (extends VoiceElementBase implements ElementInterface). The legacy classes implement the following method:
public VoiceElementConfig getConfig(String name, ElementAPI api, VoiceElementConfig config)
In this method, the legacy code is programmatically adding StaticAudio and SayItSmart objects to the audio group:
// Get the initial audio group.
VoiceElementConfig.AudioGroup audioGroup = config.getAudioGroup("initial_audio_group", 1);
// Add static audio.
audioGroup.addAudioItem(config.new StaticAudio("Hello, World.", "HelloWorld.wav"));
// Add a date with SayItSmart.
VoiceElementConfig.SayItSmart dateSis = config.new SayItSmart(
"com.audium.sayitsmart.plugins.AudiumSayItSmartDate",
"yyyymmdd",
"date",
(Object)"20120101");
dateSis.setFileset("standard_date");
dateSis.setAudioType("wav");
dateSis.setUseDefaultAudioPath(true);
dateSis.setAudioPath("../sys/");
dateSis.setUseRecordedAudio(true);
audioGroup.addAudioItem(dateSis);
// Update the audio group.
config.setAudioGroup(audioGroup);
I've discovered that I can reuse this code in the corresponding API method for the configurable voice element:
protected String addXmlBody(VMain vxml, Hashtable reqParameters, VoiceElementData voiceData)
However, the conversion from VoiceElementConfig.AudioGroup to VMain seems a bit convoluted:
VPreference pref = voiceData.getPreference();
// Start building the VXML doc by adding main form which must be called "start"
VForm form = VForm.getNew(pref, "start");
// Add form to VXML doc
vxml.add(form);
// Create block and add to form
VBlock prompt_block = VBlock.getNew(pref);
form.add(prompt_block);
// Add audio element to block followed by submit
prompt_block.add(audioGroup.constructAudio(voiceData));
VAction prompt_submit = VAction.getNew(pref);
prompt_submit.add(getSubmitVAction(null, pref));
prompt_block.add(prompt_submit);
Does anyone have any experience or advice on this conversion? Is there a simpler way to accomplish it? Are there considerations that I'm missing? Should I not even be attempting to do this?
Thanks,
Joe