Programming AI with Leaf/Development/RSS Feeds for Weather, News and Sports
RSS Weather, News and Sports feed[edit | edit source]
So you want your Leaf to tell you what the weather is like and the forecast for tomorrow? Thanks to Dr. Bruce and Mr. Gary Malolepsy this is easy. The RSS function also allows for news and sport news to be read and I will show you the commands in the end. (For some reason the sports function seems to be broken at the moment, I will update if/when I get it working)
Just follow these instructions and you will have Leaf telling you weather and news in no time.
I assume you have a working copy of the Leaf AI platform.
First, make backup copies of the following files that we will be editing:
- Leaf Interface.lisp
You are going to need the RSS package from the Yahoo Leaf group at http://tech.groups.yahoo.com/group/leaf_an_AI_robot/files/ scroll down and you will find it.
Download and unzip the RSS.lisp to your Leaf folder and the IMessDLL.dll into your system folder (c:\windows\system32) Open up your Speech.xml and add <P>forecast</P> under the line that says <P>this is a dragon</P> You can now save and close the file.
"forecast" is going to be our keyword for making Leaf download and tell us what the weather is like and forecast tomorrows weather.
Now open up RSS.lisp and copy everything with ctrl+a and then ctrl+c to copy everything into your computers clipboard, then open your Leaf Interfaces.lisp and scroll to the bottom where you will paste the clipboard into Leaf Interfaces.lisp
Save and then hit compile in your File menu.
Close Leaf Interfaces.lisp and open Leaf.lisp, because we're now going to add the function that tells Leaf to listen for the keyword "forecast" and what to do when he hears it.
So, open up Leaf.lisp and use the find function, it's in the Edit menu. Write "this is Bart" without the "" characters.
You can copy and paste this section under the bart function:
((string-equal *text-phrase* (concatenate 'string robot " forecast")) ;behavior (setf *text-phrase* nil) (weather YOURZIP))
Just change YOURZIP to your local zip code.
To also make Leaf able to tell you news, add this code under the last one you made:
((string-equal *text-phrase* (concatenate 'string robot " news")) ;behavior (setf *text-phrase* nil) (News))
And add <P>news</P> to your Speech.xml under <P>forecast</P>
Now compile Leaf.lisp using the File menu.
There you have it, Leaf can now tell you the local weather and tomorrows forecast as well as the latest news.