This document was generated from CDN thread Created by: Theepan Gnani on 12-11-2010 09:57:04 PM Hello, I'm trying to play an Audio file in VoiceElement class and it doesn't seems to be working. Please see the code and let me know if there is any issues.. VPreference pref = voiceElementData.getPreference();<font size="2">VForm form = VForm.getNew(pref, </font> "start");<font size="2"> </font> //VForm form = VForm.getNew(pref, "PromoMsg");VBlock block = VBlock.getNew(pref);<font size="2"> </font> //VAudio promoMessage = VAudio.getNew(pref,audioPath, audioFile,"File Not Found", audioFileType, false);<font size="2">VAudio promoMessage = VAudio.getNew(pref,</font> "en-us/app/", "80060","File Not Found", "wav", false); <font size="2">VAction addAction = VAction.getNew(pref, VAction.</font> EXIT, super.getSubmitURL()); <font size="2">block.add(promoMessage); </font> // Add the audio to the block.<font size="2">block.add(addAction); </font> // Add the action to the block (occurs after the audio or won't hear it).<font size="2">form.add(block); </font> // Add the block to the myOtherForm form.vxml.add(form);Subject: RE: VAudio: error.semantic Replied by: Hemal Mehta on 14-11-2010 05:16:24 PMPlease provide more details. What are you seeing in the logs? Subject: RE: VAudio: error.semantic Replied by: Theepan Gnani on 15-11-2010 07:44:11 PMPlease provide more details. What are you seeing in the logs?
Thank you for the quick response. I was able to get this to work. My problem was that I was generating proper Voice XML file. In the log file I was seeing "error.semantic" Solution was to Submit the page by creating proper VAction object. VPreference pref = voiceElementData.getPreference(); <font size="2"> </font>// Set a page-scope property. <font size="2"> </font> <font size="2">vxml.setProperties(VProperty.getNew(pref, </font> "someProperty", "someValue")); <font size="2"> </font> // Make a page-scope variable.<font size="2">vxml.add(</font> "myVar", "playing audio ", VMain.WITH_QUOTES); <font size="2">VForm form = VForm.getNew(pref, </font> "start");VBlock block = VBlock.getNew(pref); <font size="2">promoAudioFileName = Constant.</font> PROMO_MESSAGE_50 + "." + audioFileType;promoAudioFileName = audioPath + promoAudioFileName; <font size="2"> </font> this.logToActivityLog(voiceElementData,currentMethod, "File to be played: "+ promoAudioFileName); <font size="2">VAudio promoMessage = VAudio.getNew(pref, AudioFileName, VAudio.</font> FILENAME_ONLY); <font size="2"> </font> // Disable Bargein (key over)<font size="2">promoMessage.</font> bargein = false; <font size="2"> </font> //VAudio promoMessage2 = VAudio.getNew(pref, "http://10.3.254.204/en-us/app/eng/80060.wav", VAudio.FILENAME_ONLY); <font size="2">block.add(promoMessage); </font> // Add the audio to the block.<font size="2"> </font> //block.add(promoMessage2); // Add the audio to the block. <font size="2"> </font> //Not Sure why i'm doing this but, you have to inorder generate a proper Voice XML Page<font size="2">VAction submitAction = getSubmitVAction(</font> "myVar", pref); <font size="2">block.add(submitAction); </font> // Add the action to the block (occurs after the audio or won't hear it).<font size="2">form.add(block); </font> // Add the block to the myOtherForm form.<font size="2">vxml.add(form); </font> // Add myOtherForm to the VMain object. <font size="2" color="#3f7f5f"><font size="2" color="#3f7f5f"> </font></font><font size="2" color="#3f7f5f"> </font> <font size="2"> </font> Subject: RE: VAudio: error.semantic Replied by: Coty Condry on 13-08-2013 05:13:30 PMI used this code while making a custom element for using fetchaudio. Since the code above is pretty mangled by the forum, here is my element code: 1
2import java.util.HashMap;
3import java.util.Hashtable;
4
5import com.audium.core.vfc.VException;
6import com.audium.core.vfc.VPreference;
7import com.audium.core.vfc.audio.VAudio;
8import com.audium.core.vfc.form.VBlock;
9import com.audium.core.vfc.form.VForm;
10import com.audium.core.vfc.util.VAction;
11import com.audium.core.vfc.util.VMain;
12import com.audium.core.vfc.util.VProperty;
13import com.audium.server.session.VoiceElementData;
14//import com.audium.server.voiceElement.ElementData;
15import com.audium.server.voiceElement.ElementData;
16import com.audium.server.voiceElement.ElementException;
17import com.audium.server.voiceElement.ElementInterface;
18import com.audium.server.voiceElement.ExitState;
19import com.audium.server.voiceElement.Setting;
20import com.audium.server.voiceElement.VoiceElementBase;
21import com.audium.server.xml.VoiceElementConfig;
22
23@SuppressWarnings("unchecked")
24public class FetchAudio extends VoiceElementBase implements ElementInterface {
25 public String getElementName()
26 {
27 return "Fetch_Audio";
28 }
29
30 public String getDescription()
31 {
32 return "Fetch audio and continue the call flow while playing the audio file.";
33 }
34
35 public String getDisplayFolderName()
36 {
37 return "";
38 }
39
40 public Setting[] getSettings() throws ElementException
41 {
42
43 Setting file = new Setting(
44 "file"
45 ,"Audio File"
46 ,"The audio file to play in the background."
47 ,true
48 ,true
49 ,true
50 ,Setting.STRING
51 );
52 file.setDefaultValue("{Data.Session.defaultAudioPath}rained.wav");
53
54 Setting timeout = new Setting(
55 "timeout"
56 ,"Timeout (seconds)"
57 ,"Length of time to try to play this audio file in the background."
58 ,true
59 ,true
60 ,true
61 ,Setting.INT
62 );
63 timeout.setDefaultValue("325");
64
65 return new Setting[] {file,timeout};
66 }
67
68 public HashMap getAudioGroups() throws ElementException
69 {
70 return null;
71 }
72
73 public String[] getAudioGroupDisplayOrder()
74 {
75 return null;
76 }
77
78 public ExitState[] getExitStates() throws ElementException
79 {
80 ExitState cont = new ExitState(ExitState.DONE);
81 return new ExitState[] {cont};
82 }
83
84 public ElementData[] getElementData() throws ElementException
85 {
86 return null;
87 }
88
89 protected String addXmlBody(VMain vxml, Hashtable reqParameters, VoiceElementData data)
90 throws VException, ElementException
91 {
92 VoiceElementConfig cfg = data.getVoiceElementConfig();
93 String file = cfg.getSettingValue("file", data);
94 int seconds = cfg.getIntSettingValue("timeout", data);
95 String timeout = String.valueOf(seconds) + "s";
96
97 VPreference pref = data.getPreference();
98 // Set a page-scope property.
99 VProperty vp = VProperty.getNew(pref, VProperty.AUDIO_TO_PLAY_WHILE_FETCH, file);
100 vp.add(VProperty.FETCHING_TIMEOUT, timeout);
101 //vp.add(VProperty.OBJECT_FETCH_HINT, "prefetch");
102
103 vxml.setProperties(vp);
104 vxml.add("myVar", "playing audio ", VMain.WITH_QUOTES);
105 VForm form = VForm.getNew(pref,"start");
106 VBlock block = VBlock.getNew(pref);
107 if(1==0){
108 VAudio promoMessage = VAudio.getNew(pref, "silence.wav", VAudio.FILENAME_ONLY);
109 // Disable Bargein (key over)
110 promoMessage.bargein = false;
111 block.add(promoMessage);
112 }
113 //Not Sure why i'm doing this but, you have to inorder generate a proper Voice XML Page
114 VAction submitAction = getSubmitVAction("myVar", pref);
115 block.add(submitAction);
116 // Add the action to the block (occurs after the audio or won't hear it).
117 form.add(block);
118 // Add the block to the myOtherForm form.
119 vxml.add(form);
120 // Add myOtherForm to the VMain object.
121 return "done";
122 }
123}