I would like to switch ProgramAB robots personalities

This is the script I’m running in the MRL python window. I have tried modifying it in many ways with ‘ghostchat’ to use my AIML file but it will only run as is.  I think Kevin wrote it. It works for alice2 bot and opens the web GUI successfully.  It works fine but I want to use my own to add personality to my inMoov.

I’ve put a copy of my script in various places in the ProgramAB folder including in the bot file with alice2 and tried changing the WebGUI initiating script to refer to it. It always gets ignored. I've also created a separate bot file in the bot folder and copied other files across. Can anyone tell me how I need to modify the script below and what other AB files need to be added or changed and put in what folder? I’ve run out of ideas. 
 
 

#file : home/Humanoid/MyBot.py edit raw
from java.lang import String
 
######################################################################
# A helper function to print the recognized text to the python window.
# semi-useful for debugging.
######################################################################
def heard(data):
  print "Speech Recognition Data:", data
 
######################################################################
# Create ProgramAB chat bot
######################################################################
lloyd = Runtime.createAndStart("lloyd", "ProgramAB")
#lloyd.startSession("c:/dev/workspace.kmw/pyrobotlab/home/kwatters", "default", "lloyd")
lloyd.startSession("kevin", "alice2")

######################################################################
# create the speech recognition service
# Speech recognition is based on WebSpeechToolkit API
######################################################################
# Start the new WebGuiREST API for MRL
webgui = Runtime.createAndStart("webgui","WebGui")

######################################################################
# Create the webkit speech recognition gui
######################################################################
wksr = Runtime.createAndStart("webkitspeechrecognition", "WebkitSpeechRecognition")
######################################################################
# create the html filter to filter the output of program ab
######################################################################
htmlfilter = Runtime.createAndStart("htmlfilter", "HtmlFilter")
 
######################################################################
# create the speech to text service (named the same as the inmoov's)
######################################################################
#mouth = Runtime.createAndStart("i01.mouth", "MarySpeech")
# mouth.setGoogleURI("http://thehackettfamily.org/Voice_api/api2.php?voice=Ryan&txt=")
mouth = Runtime.createAndStart("i01.mouth", "AcapelaSpeech") 
######################################################################
# MRL Routing webkitspeechrecognition -> program ab -> htmlfilter -> inmoov
######################################################################
# add a route from Sphinx to ProgramAB
# sphinx.addTextListener(lloyd)
# debugging in python route.
# sphinx.addListener("publishText", python.name, "heard", String().getClass());
 
# add a link between the webkit speech to publish to ProgramAB
wksr.addTextListener(lloyd)
# Add route from Program AB to html filter
lloyd.addTextListener(htmlfilter)
# Add route from html filter to mouth
htmlfilter.addTextListener(mouth)
 
# make sure the ear knows if it's speaking.
# TODO: how does this jive with webspeech ?!
# sphinx.attach(mouth)

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Humanoid's picture

Ignore "purple"

Ignore the word "purple". When I emailed this to Grog the script was in purple. Ta. 

calamity's picture

everything almost fine

the script is working, but there is something missing in aiml file.

You have set some topic, but nothing set those topics

programAB will only look for pattern inside topic tag when that topic is set

Read that to know more how to set AIML files

http://www.tutorialspoint.com/aiml/aiml_topic_tag.htm

Christian

Humanoid's picture

ProgramAB loves boring Alice

Thanks for the topic info. I've modified and added some topics in my AIML script.  I doesn't seem to make a difference to what happens in the WebGUI.  ProgramAB doggedly reverts back to the boring old Alice2 bot regardless to what's in the AIML file. I'm thinking it has a default in the ProgramAB library which causes this to happen no matter what you type in in the 'start session' setting. 

Can I see a copy of the script you use to open the WebGui from MRL to get it to use your own chatbot so that I can see what you have done differently? 

Mastablasta's picture

new bot using ProgramAB

A new bot should be placed into develop/ProgramAB/bots. And your aiml files into the aiml-folder, if necessary create a new aiml-folder.... develop/ProgramAB/bots/YOURBOTNAME/aiml

Try this:

holygrail = Runtime.createAndStart("holygrail", "WebGui")
wksr = Runtime.createAndStart("webkitspeechrecognition", "WebkitSpeechRecognition")
YOURBOTNAME= Runtime.createAndStart("YOURBOTNAME", "ProgramAB")
YOURBOTNAME.startSession("ProgramAB/bots", "YOURBOTNAME")
htmlfilter = Runtime.createAndStart("htmlfilter", "HtmlFilter")
acapelaSpeech = Runtime.createAndStart("speech", "AcapelaSpeech")
voices = acapelaSpeech.getVoices()
for voice in voices:
    acapelaSpeech.setVoice("Ryan")
wksr.addTextListener(YOURBOTNAME)
YOURBOTNAME.addTextListener(htmlfilter)
htmlfilter.addTextListener(acapelaSpeech)

Humanoid's picture

No worky

No worky as yet. I had already placed the files as you recommended.

I've also tried adding other alice 2 files but no joy.

I kept getting "I have no answer for that" multiple times.

At one point it said I was not permitted to run more that 300 characters. Strange. Same on PC and Mac.

Very frustrating. My script is about 600 lines - LOL.

Have you run a bot in that way through the web gui successfully?

Mastablasta's picture

Hope this will help

Hope this will help

Humanoid's picture

Is Pandora the AB file problem I am having?

Hi Mastablasta,

I noticed that some of your bot file names have " _pand".  None of my files have this in the title though the folder names appear to be the same otherwise.  Did you copy these across from the Alice2 bot file?

Is there a later mrl build which downloads different ABfiles?  Is there a new mrl Pandora service I need to download?  I haven't created my bot through Pandora. I have just created an aiml file and a folder.

I'm thinking this might be the problem as everything else I'm doing appears to be the same.   

 

Humanoid's picture

Alice 2 no worky now either. Does anyone have any idea why?

The above script is now no longer worky either for Alice2. I keep getting a java error in the WebGui and in my terminal.   

ERROR class org.myrobotlab.service.WebGui - ------

java.lang.reflect.InvocationTargetException

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.

 

I have redownloaded JDK from oracle and it's the latest version.  The WebGui appears to have opened all the relevant services but is not using them to produce or recognise speech. 

Does anyone know what these error messages mean?

UPDATE:

I found this on Stack Overflow:

"The error message is pretty self-explanatory - you can't use 32-bit libraries with a 64-bit JVM.

Try the solution from http://technophi.com/2010/03/22/cannot-load-32-bit-swt-libraries-on-64-bit-jvm/ (add the -d32 switch to your command line)"

 

COMMENT:

This makes sense to me as the problem is happening on the Mac and not PC.

The above link is dead but I plan to try the Command Line switch unless someone has better advice.

 

Q. Does anyone know if there is a solution to these speech related libraries being only 32 bit (if that is the problem) and can anyone tell me if the main MRL platform is 32 bit?  I suspect it's one/some of the service libraries which are 32 bit. Advice on these issues would be much appreciated. 

 

FURTHER UPDATE:

I just found this on Java website:

"This article applies to:

  • Browser(s) Chrome
  • Java version(s): 7.0, 8.0

Chrome no longer supports NPAPI (technology required for Java applets)

The Java plug-in for web browsers relies on the cross platform plugin architecture NPAPI, which has been supported by all major web browsers for over a decade. Google's Chrome version 45 (scheduled for release in September 2015) drops support for NPAPI, impacting plugins for Silverlight, Java, Facebook Video and other similar NPAPI based plugins.

Java applications are offered through web browsers as either a web start application (which do not interact with the browser once they are launched) or as a Java applet (which might interact with the browser). This change does not affect Web Start applications, it only impacts applets.

If you have problems accessing Java applications using Chrome, Oracle recommends using Internet Explorer (Windows) or Safari (Mac OS X) instead.

Question:

IS THIS WHY OUR WEBGUI CHATBOTS AREN'T LAUNCHING PROPERLY IN CHROME? CAN WEBKITSPEECH BE CHANGED TO OPEN IN ANOTHER ANOTHER BROWSER?

 

 

kwatters's picture

Not related

Hi Humanoid,

  The chrome issue is unrelated to your problem.  I recommend a few things first.

1.  If you have a 64 bit operating system  you MUST use the 64 bit version of java.

2. Your Java version must be at least version 1.7 or newer.  Java version 1.6 or earlier will NOT work.

3. You can always send a "no worky".  The whole stack trace / log file makes it much easier to see what is happening.  

4. Validate the version of java that you are using on the command line  with  "java -version"  you should see at least version 1.7 and 64 bit.  If you don't, make sure you upgrade your java version to at least version 1.7 and 64 bit. 

5. if you're making a new bot, start simple and incrementally add to it.

6. webkitspeech recognition only works in Chrome.  It will NOT work in any other browser.  (maybe some day Google will support other browsers, but I wouldn't hold my breath for that.)

7. ProgramAB has a concept of the "current session" ... That is a combination of your user name and the bot that is loaded.  When you call "startSession", that will make the user/bot combination the current session.  When you speak with the bot, the responses will be returned as though that session is loaded.

8. The swing GUI defaults to username "default" and bot name "alice2"  but that does not mean that it's the current session.  when you call  startSession("username", "botname")  it makes the current session to be one between "username" and "botname".  Ignore what the swing gui says. 

9. The webgui works much better.  You can start multiple sessions with different bots and switch between them with the dropdown.  I fixed that up on friday, so make sure you're on the "latest".

I hope this will help you understand/debug a bit better.

Good luck!  

  -Kevin

 

 

Humanoid's picture

WebkitSpeech issues

I'm using the current version of Java (64bit) and verified it's the correct one. My Mac is 64bit. 

Mastablasta sent me a copy of the older MRL build (1112).  It works well with Alice2 bot.  Same script doesn't work on MRL versions 1159-1162. Result is previously mentioned Java error.  I've sent a 'no worky' using the 1162 build.

I haven't been testing my bot at this point.  I suspect I need to cut my bot up into several aiml files as it might be too long. I will also do further work on the 'topics' in my script to improve them and start testing simple ones first as you suggest. Thanks.

UPDATE:

Grog sorted the problem after a chat with him on the Shoutbox. Version 1165 has rectified the problem. Yay! Thanks, Captain. Apparently the change was here:

https://github.com/MyRobotLab/myrobotlab/commit/87530c4d2583d44b4501ffa4546f7c6a087919bd#diff-0b29eee3a2ffd5d995d43262f6a329d5L48

 

Tandy's picture

Learning through the relaible web resource

Owing to the growing popularity of Java, I have started learning its fundamentals. It will help me in developing mobile apps with greater efficiency. I rely on http://www.java-forums.org/forum.php to get handy tips for Java programming.

Humanoid's picture

Thanks

I think I'll leave the Java programming to the other guys on MRL.  I'll stick to working on the AIML and Python for the speech synthesis for the time being. That's more than enough work for me. 

Thanks.