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

Created by: null on 10-10-2005 10:50:42 AM
Hi,

I need a simple form that includes the repeat functionality, ie when the user says "repeat", the initial prompt is prompted again fon input.

When I run the form, I get the initial prompt,
When I say "repeat", I get the prompt again as expected , but this time the voice browser is not recognizing the word "repeat". Actually it's not "listening" for any input (voice only) and it's timing out all the time.
I am positive the grammars are loaded correclty. It must be something obvious I am doing wrong ..
I am including the code .. I anyone can help it would be much appreciated 😉

Thanks a lot
Mitch

THE CODE (Audium 3.4.1):
********************************************************
public class UniversalsForm extends MFoundationForm implements ElementInterface,VoiceElementInterface
{

// Some essential Tags
// The values here should match those of
// DVXAP.properties in the Grammar Tag section
public static String CONSULTANT_TAG = "CONSULTANT";
public static String HELP_TAG = "HELP";
public static String REPEAT_TAG = "REPEAT";
public static String START_AGAIN_TAG = "START_AGAIN";

public String getElementName()
{
return "UniversalsForm";
}

public String getDescription()
{
return "Default Form ";
}

/**
* This method returns the name of the folder in which this voice
* element resides. Return null if it is to appear directly under the
* Elements folder.
*/
public String getDisplayFolderName()
{
return "My Elements";
}

public ExitState[] getExitStates() throws ElementException
{
ExitState[] exitStateArray = new ExitState[2];
exitStateArray[0] = new ExitState(ExitState.DONE);
exitStateArray[1] = new ExitState("alternate",
"Alternate path",
"Alternate path");
return exitStateArray;
}

public ElementData[] getElementData() throws ElementException
{
return null;
}

public Setting[] getSettings() throws ElementException
{
return null;
}

public String[] getAudioGroupDisplayOrder()
{
return null;
}

public HashMap getAudioGroups() throws ElementException
{
return null;
}

public VoiceElementConfig getConfig(String name, ElementAPI elementAPI, VoiceElementConfig defaultConfig) throws AudiumException
{

// Get the configuration from a property file
Properties props = (Properties)elementAPI.getSessionData(DarwinVXAPConstants.AUDIUM_SESSION_DVXAP_PROPS_ATTR);
String DEFAULT_TIMEOUT_SETTING = props.getProperty("universals.default.timeout");
String DEFAULT_CONFIDENCE_LEVEL = props.getProperty("universals.confidence.level");

// Load the initial Form
VoiceElementConfig.AudioGroup initial = defaultConfig.new AudioGroup("initial_audio_group",true,1);
defaultConfig.setAudioGroup(initial);
VoiceElementConfig.StaticAudio audio = loadAudio(props, defaultConfig, initial,name, ".initial.audio.");


// Load grammars specified in the current DVXAP
loadGrammars(props,defaultConfig,"voice_grammar", name);
// Load grammars specified in the global DVXAP
loadGrammars(props,defaultConfig,"voice_grammar", "universals");

defaultConfig.setSettingValue("field_name", "foundation_fld");
defaultConfig.setSettingValue("noinput_timeout", DEFAULT_TIMEOUT_SETTING);
defaultConfig.setSettingValue("confidence_level", DEFAULT_CONFIDENCE_LEVEL);
defaultConfig.setSettingValue("inputmode","voice");
if (defaultConfig.getSettingValue("maxnbest",elementAPI) == null)
{
defaultConfig.setSettingValue("maxnbest","1");
}
defaultConfig.setSettingValue("max_nomatch_count","1");
defaultConfig.setSettingValue("max_noinput_count","1");

return defaultConfig;

}


/*
  • THIS IS THE ONE 
*/
public String addXmlBody(VMain vxml, Hashtable params,VoiceElementData data)
throws VException, ElementException
{

VoiceElementConfig config = data.getVoiceElementConfig();

String currentState = (String)data.getScratchData("PREV_STATE");

// if it's the first time
if (currentState == null)
{

data.setScratchData("PREV_STATE","undone");
data.setScratchData("REPEAT_COUNT", new Integer(0));
data.setScratchData("ERROR_COUNT", new Integer(0));
data.setScratchData("HELP_COUNT", new Integer(0));

MFoundationForm tmpForm = new MFoundationForm();

VoiceElementResult result = tmpForm.createSubVoiceElement(this, vxml, params, data);
return null;
}
else

// second time gets here
if ("undone".equals(currentState))
{

String value = null;

value = data.getElementData(data.getCurrentElement(),"value");

value = (String)params.get("foundation_fld");

if ("repeat".equals(value))
{

MFoundationForm tmpForm = new MFoundationForm();
params.clear();
VoiceElementResult result = tmpForm.createSubVoiceElement(this,vxml,params,data);
String returned = result.getExitState();
if (returned == null) {

return null;
}

// Increment REPEAT COUNTER ...
return null;


}

data.logError("value "+value);

}

return "done";

}

private void loadGrammars(Properties props,VoiceElementConfig cfg, String tag, String state ) throws ElementConfigException
{

for (int i = 1;i<999;i++)
{
String grammarName = props.getProperty(state+"."tag"."+i);
if (grammarName != null)
{
cfg.addSettingValue(tag,grammarName);
}
else
{
return;
}

}

}

private VoiceElementConfig.StaticAudio loadAudio(Properties props, VoiceElementConfig config, VoiceElementConfig.AudioGroup group,String name,String tag ) throws ElementConfigException
{

VoiceElementConfig.StaticAudio audio = null;
int audioCount=1;
while (true)
{
String audioItem = props.getProperty(name+tag+audioCount);
if (audioItem == null)
{
break;
}
audio = config.new StaticAudio(audioItem);
group.addAudioItem(audio );
audioCount++;
}
return audio;
}

}

Subject: RE: Simple Audium Form -  issue with the Repeat functionality
Replied by: Vance Vagell on 10-10-2005 04:43:41 PM
Hi Mitch,

The functionality you would like to implement does not require a custom element. You can accomplish the same result by following a Form element with a Decision element in your callflow. Configure the Decision element to exit back to the Form element if the "value" variable (in element data) of the Form element holds "repeat". Additionally, you could introduce a Counter element to keep track of the amount of times the Form has been repeated.

However, you may have a requirement that all Form elements support this functionality, in which case it would be beneficial to create a custom element. While code reviews and debugging are not part of standard support, we now offer a new Premium Support service whereby we would create and support this custom element for you. If time constraints are present, we also offer expedited service. If you are interested in this option, please contact us directly.

Regards,
Vance
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