From: spencer l. <spe...@gm...> - 2010-01-22 20:15:59
|
Hi On Sat, Jan 9, 2010 at 1:37 PM, johny jj2 <joh...@gm...> wrote: > Thank you for your answer! > > I've got two major difficulties, one with adding action to recognizing > words which match the grammar and the other with running Parrot from > softphone. Please, answer at least first of these two. > > ---------------------------------------------------- > > May you tell me, please, how to add action to Parrot if the {WEATHER} > is recognized? I'd like the application to respond with wav file and > to follow some java code (e.g. write to file; in my case it would be > calculating sum and playing either 1.wav or 2.wav). > > I guess there must be change to both Parrot.java and parrot.vxml. > > For example to parrot.vxml (perhaps it is not good way) - to answer > the action with wav file: > > <filled> > > <prompt> <value expr="main"/> </prompt> > <if cond="main=='weather'"> //NEW CODE BEGINS HERE > <block> > <audio src="weather_wav_file_URL"/> > </block> > </if> //NEW CODE ENDS HERE > > <if cond="main=='quit'"> > > <exit/> > > <else/> > > <clear namelist="main"/> > > <reprompt/> > > </if> > > > > </filled> > > This looks basically correct, but I would use an "else if" in the existing "if" block rather than a new "if" block. I am not an expert in voicexml, so take my answer with a grain of salt :) > And Parrot.java - to add some action with java code, e.g. writing to file: > > if ((rule.getTag().equals("QUIT")) && (rule.getRule().equals("main"))) > { > > //... > > } > if ((rule.getTag().equals("WEATHER")) && > (rule.getRule().equals("main"))) { > > //here e.g. I perform calculations - according to their > result I'd like the application to say either "control sum correct" or > "control sum incorrect" - wav answer is DEPENDENT ON CALCULATIONS, not > only on recognized word (which is the case of using vxml file)!!! how > to specify playing either 1.wav or 2.wav here ?!?!? > > } > This looks good. I would consider using "else if" also note the first parameter to playAndrecognize is TRUE indicating that the next parameter is a uri to an audio file. If it is false the next parameter is assumed to be text to be synthesized. Then in the else if block, set the audioUri to a the audio file of your choice. String audioUri; boolean PromptIsUri = true; RecognitionResult r = sClient.playAndRecognizeBlocking(PromptIsUri ,audioUri,grammar, false); if ((r != null) && (!r.isOutOfGrammar())) { for (RuleMatch rule : r.getRuleMatches()) { if ((rule.getTag().equals("QUIT")) && (rule.getRule().equals("main"))) { stopFlag = true; this.getContext().dialogCompleted(); else if ((rule.getTag().equals("WEATHER")) && (rule.getRule().equals("main"))) { //logic to figur out which audio file to use in the the next playAndRec command audioUri = file:///prompts/a.wav } } > Some additional, minor, questions: > > 1. I don't get why in parrot.vxml there is "Would you like to hear the > weather, get sports news or hear a stock quote?" if the parrot > application is about repeating what somebody says. > It is not recognizing anything. It only recognizes what is in the grammar. The prompt is trying to indicate what is in the grammar. It is a dumb parrot that only knows a few words :) > 2. Why is there > ~/cairo/zanzibar-0.1-src/src/resources/prompts/parrot.wav if this wav > is never used? > Sorry, I meant to add an option to the demo to show how you can use a pre-recorded prompt rather than TTS. I will add it to the next release. > > ---------------------------------------------------- > > May you also help me to run this Parrot from softphone, please? > > 1. I extracted zanzibar-0.1-bin.tar.bz2 to > /home/mainaccount/cairo/zanzibar-0.1-bin. Later I did all the stuff > connected with global variables for Java, extracting JSAPI etc. > 2. I run /home/mainaccount/cairo/zanzibar-0.1-bin/bin/rserver.sh from > Terminal. (There was error in sh file - I had to change from \ to / > because it couldn't find launch.sh). > 3. I copy config directory from ~/cairo/zanzibar-0.1-bin to > ~/cairo/zanzibar-0.1-bin/bin because one of those three sh couldn't > find config directory. > 4. OK, all three sh files from ~/cairo/zanzibar-0.1-bin/bin/cairo and > also ~/cairo/zanzibar-0.1-bin/bin/zanzibar/asteriskConnector.sh are > running. > 5. I add to sip.conf: > > [Zanzibar] > type=peer > host=localhost //I wasn't sure what to write here > port=5090 > dtmfmode=info > canreinvite=no > localhost is probably ok if zanzibar and asterisk are on the same machine. You can put the real host name or ip address of the zanzibar machine to be safe. > > 6. I add to extensions.conf at the end of [mainmenu] section (is it > proper place?): > > exten => 1,n,SIPAddHeader(x-channel:${CHANNEL}) > exten => > 1,n,SIPAddHeader(x-application:basic|org.speechforge.apps.demos.Parrot) > exten => 1,n,Dial(SIP/Zanzibar) > Not sure if it should be at the end of mainmenu, can you send the main menu dialplan? I am very sorry, but the doc has a mistake and there is a bug in the code. This section is partially correct type|applicationName where: type is either "beanId" "className" or "vxml" So if you want to use the classname option instead of basic, use "classname" The bug is that you must use "classname" in all lower case. exten => 1,n,SIPAddHeader(x-application:classname|org.speechforge.apps.demos.Parrot) if you still have the bean "Parrot" defined in your context.xml file, you can also use this instead (again case is important) exten => 1,n,SIPAddHeader(x-application:beanId|Parrot) <bean id="Parrot" class="org.speechforge.apps.demos.Parrot" singleton="false"> <property name="prompt"> <value>You can start speaking any time. Would you like to hear the weather, get sports news or hear a stock quote? Say goodbye to exit.</value> </property> <property name="grammar"> <value>file:../../demo/grammar/example-loop.gram</value> </property> </bean> > 7. I add to /etc/asterisk/manager.conf at the end of file: > > [twinkle] > secret=password > permit=0.0.0.0/0.0.0.0 > read=system,call,log,verbose,agent,command,user > write=system,call,log,verbose,agent,command,user<http://0.0.0.0/0.0.0.0%0Aread=system,call,log,verbose,agent,command,user%0Awrite=system,call,log,verbose,agent,command,user> > This is not really used unless you are transfering calls. I do not believe you are doing this, so no worries about this config. > > 8. I cannot find context.xml file to do what is written here > http://www.spokentech.org/openivr/aik.html > Sorry, but another issue with the docs. This is also called the configuration file. It is basically a spring config file that is passed in on te command line to the main zanzibar program. So look at the shell script that you are using to start zanzibar (probably asteriskConnector.sh) and check this line. In this case the context or config file is pbxconfig.xml CONFIG=file:../config/pbxconfig.xml > > 9. I run 'asterisk' in Terminal > > 10. I run 'twinkle'. I choos profile: 'twinkle', SIP service provider: > 'None (direct IP to IP calls), username: twinkle, domain: localhost, > system settings -> network -> SIP port: 5061. I write in call: > '1000@127.0.0.1'. It connects me to "Congratulations. You have > successfully installed and executed the Asterisk open source". So I > can connect to Asterisk but cannot connect to Parrot demo. I guess the > call is improper but there also may be something wrong with > configurations above. > I think you are very close. The issue is with your dialplan. Probably your placement of the three statements you describe in section 6. above. > > Regards! > > PS > > Are your acoustic models in jar files? > Yes, it contains two directories (etc and model_parameters) without > loaders (it needs sphinx3 loader to be specified in xml). > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and > easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > cairo-user mailing list > cai...@li... > https://lists.sourceforge.net/lists/listinfo/cairo-user > |