@MovieMaker mentioned he wanted more RSS Feeds in the AI topic earlier and listed out a few so...
Here is a project with a single Script Manager (renamed as RSS Reader so you can import in to your project via the merge button - I suspect you don't already have a command called RSS Reader).
I'm still working on it, I need to find some better RSS feeds or add in some code to cut off some of the feeds and remove the information we don't want (the poem of the day is a prime example).
It should hopefully make it clear how you can use pretty much any RSS url in the script (they are all the same script with a different feed url). Simply have your Speech Recognition commands run ControlCommand() with the relevant info to start the required feed reader. For instance;Code:
ControlCommand("RSS Reader", ScriptStart, "Inspirational Quote")
I was (and have) going to make a single script which would read the feed from a list of available feeds however it all seemed like a lot of hard work for no gain what so ever. You could alter the code in the scripts I've linked to and use a WaitForChange() to hold off reading anything until a command was given which would change the feed url to the correct one, but this added far too many variables for my liking. I have another idea which may work to avoid having to copy and paste the same code in each script but again, unless there is good reason not to, I don't see copy and pasting code over and over again necessarily as a bad thing.
Please feel free to list any and all RSS feeds for information you use or would like to be included and I will add the scripts as we go. Keep checking the cloud, updates will just happen so make sure you check the notepad within the project to see what's been added and when it was last updated.
Asked
— Edited
thanks for what you have already done.
I bought a new voice for Jarvis which has very good pronunciation, sometimes it makes errors but they are very rare.
I merged your RSS feed program, added additional Feeds (up to about 10 now). Still working on VR commands.
Having all RSS feeds in Script manager is a big improvement plus.
I run my windows speech @ a slightly slower speed, with a good sounding sound system, that makes it more understandable.
Thank You
Steve S
Which other RSS feeds are you using Steve? I'm trying to build up a nice list of useful RSS feeds so your input would be very much appreciated.
Since you can have multiple "Script Manager" controls running I thought it would be a cool idea to group the RSS Feeds together in one manager named RSS Feeds. Now we have the 3 desktop view screen real estate isn't as big a problem and the manager can be hidden away on a different desktop and out of the way if required. It just seemed to make it easier to group scripts this way.
Last week @ campground, no PC.
I can list them Monday or Tuesday, but it is 3 weather reports, your news feed, EZ robot joke example, your last rss feed script manager modified to include bible quotes, I think about 10 in all. I just changed text on your feed to see what worked.
You are a great help Rich.
Thank you,
Steve S
I did have an idea of making one main script and then another which would select the correct feed url but since the code is so simple and short per script it made more sense, at least to me, to just duplicate the script each time and change the URL to suit, saving as a new script.
The basic code for the scripts is;
Code:
So it's so simple to adjust to suit a different RSS feed. To be honest, the whole script could be replaced with just the SpeakRSSDescription() command and hardcode the URL each time. Everything else in the script is pretty much redundant but it allows for future modification and alteration to include a more complex script if the requirement is ever there (i.e. find location from GPS sensor, look up correct weather forecast for location, read multiple stories etc.)
However, with rss feeds such as news and forum posts there is always going to be more than one story, this is where the code will change. The News Feed RSS script from a few months ago asks the user if they want to hear another story and continues until a no is heard. This script will be added to the next update of this script along with 2 blank scripts, one for a single story and one for multiple stories. Depending on my weekend I should hopefully have it updated over the next couple of days.
If you find any other RSS feeds please share, like you always do.
You have encouraged me to explore and update my project many times.
Thank you
Steve S
http://weather.yahooapis.com/forecastrss?p=%s&u=c
http://rss.news.yahoo.com/rss/sports
http://rss/en.wikipedia.org/wiki/Main_Page/
http://henryalford.com/?feed=rss2&p=535
http://www.jokesareawesome.com/rss/random/
http://www.rssweather.com/zipcode/37138/rss.php
http://rss.cbc.ca/lineup/world.xml
http://www.quotationspage.com/qotd.html
http://www.quotationspage.com/mqotd.html
http://www.fool.com/
www.historyorb.com/today/rss-feeds.php
www.history.com/this-day-in-history/rss
www.makeuseof.com/tag/top-8-rss-feeds-motivational-quotes-day
www.thoughtfortoday.org.uk
www.ucb.co.uk/rss/word-for-today
randomthoughtstoday.com/files/blog.xml
greatday.com/motivate/index.html
www.sciencedaily.com/newsfeeds.htm
short-funny-jokes.com
http://www.quotesdaddy.com/feed/tagged/Inspirational
http://www.quotesdaddy.com/feed/tagged/Life
http://feeds.feedburner.com/historyorb/famousbirthdays?
http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?
http://feeds.feedburner.com/historyorb/famousbirthdays?format=xml
http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml
I am trying to remove the " " from this feed.
SpeakRSS("http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml",1)
If you place this into a script and run it, you will see what I am running into. This bot is going to be used at a elementary and high school to introduce students to robotics, so any advice you can give would be greatly appreciated.
Thanks for any advice.
thanks,
Mel
This is an example by Rich that I modified adding a random # gen.
# Quote Of The Day
# Author: Rich Pyke (modifed by Steve S - random quotes)
# Define variables
# Quote Feed URL
# Pick a random number from 1 to 5
$response = GetRandom(1,5)
print ($response)
# Use response depending on random number
If($response = 1)
$feedurl = "http://www.quotesdaddy.com/feed/tagged/Inspirational"
ElseIf($response = 2)
$feedurl = "http://www.quotesdaddy.com/feed/tagged/baseball"
ElseIf($response = 3)
$feedurl = "http://www.quotesdaddy.com/feed/tagged/political"
ElseIf($response = 4)
$feedurl = "http://www.quotesdaddy.com/feed/tagged/man"
ElseIf($response = 5)
$feedurl = "http://www.quotesdaddy.com/feed/tagged/women"
EndIf
# Speak the story
SpeakRSSDescription($feedurl,1)
# End of script
Halt()
I want to take the xml that is being passed back from a web request, and store it in either a variable. I then want to use something like Replace($returnedtext,"&npsb;"," ") to remove "&npsb; values (and any others I come across) from the feed so that the text to speech piece can read the rss feed without reading the extra invisible characters.
I may just write an app that runs on my desktop that does this periodically, clean the data, and then place it in files on my machine to be read by the robot. I hoped not to have to this, but I cant find anything in EZ-B that is going to allow me to do this yet. Its not any big deal. I just hoped that there was a method of doing this more easily.
BTW, I have written all of the scripts for my next project (except for movement scripts). ARC is so simple to use and pretty powerful. I am impressed. Great job EZ-Robot team!
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Text;
namespace WindowsFormsApplication3
{
static class Program
{
/// <summary>
/// Used to convert RSS read to plain text file
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
XmlDocument rssXmlDoc = new XmlDocument();
// Load the RSS file from the RSS URL
rssXmlDoc.Load("http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml?1");
// Parse the Items in the RSS file
XmlNodeList rssNodes = rssXmlDoc.SelectNodes("rss/channel/item");
StringBuilder rssContent = new StringBuilder();
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\rssfeeds\\Test.txt");
// Iterate through the items in the RSS file
foreach (XmlNode rssNode in rssNodes)
{
XmlNode rssSubNode = rssNode.SelectSingleNode("title");
string title = rssSubNode != null ? rssSubNode.InnerText : "";
rssSubNode = rssNode.SelectSingleNode("link");
string link = rssSubNode != null ? rssSubNode.InnerText : "";
rssSubNode = rssNode.SelectSingleNode("description");
string description = rssSubNode != null ? rssSubNode.InnerText : "";
// Removes the characters - may not be needed
rssContent.Append(description.Replace(" ", ""));
// regex to turn html into text
file.WriteLine(System.Text.RegularExpressions.Regex.Replace(rssContent.ToString(),"<[^>]*>",""));
}
file.Close();
Application.Run(new Form1());
}
}
}
I have a C# app that will convert an rss feed into a text file. Here is the code below. You can parameterize it and make it run for multiple rss feeds. You can also have it write the files to a different location. Feel free to modify it however suits you.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.IO;
using System.Text;
namespace WindowsFormsApplication3
{
static class Program
{
/// <summary>
/// Used to convert RSS read to plain text file
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
XmlDocument rssXmlDoc = new XmlDocument();
string nextline = null;
// Load the RSS file from the RSS URL
rssXmlDoc.Load("http://feeds.poetryfoundation.org/PoetryFoundation/PoemOfTheDayText?format=xml?1");
// Parse the Items in the RSS file
XmlNodeList rssNodes = rssXmlDoc.SelectNodes("rss/channel/item");
StringBuilder rssContent = new StringBuilder();
System.IO.StreamWriter file = new System.IO.StreamWriter("C:\\rssfeeds\\Test.txt");
// Iterate through the items in the RSS file
foreach (XmlNode rssNode in rssNodes)
{
XmlNode rssSubNode = rssNode.SelectSingleNode("title");
string title = rssSubNode != null ? rssSubNode.InnerText : "";
rssSubNode = rssNode.SelectSingleNode("link");
string link = rssSubNode != null ? rssSubNode.InnerText : "";
rssSubNode = rssNode.SelectSingleNode("description");
string description = rssSubNode != null ? rssSubNode.InnerText : "";
// Removes the characters - may not be needed
rssContent.Append(description.Replace(" ", ""));
// regex to turn html into text
nextline = System.Text.RegularExpressions.Regex.Replace(rssContent.ToString(), "<[^>]*>", "");
//replace whitespace
nextline = System.Text.RegularExpressions.Regex.Replace(nextline, "[\n\r\t]", " ");
nextline = nextline.Replace("\"","");
nextline = nextline.Replace("(","");
nextline = nextline.Replace(")", "");
nextline = nextline.Replace("—", "");
int cutat = 0;
cutat = nextline.IndexOf("Biography");
nextline = nextline.Remove(cutat);
file.WriteLine(nextline);
break;
}
file.Close();
Application.Run(new Form1());
}
}
}
Then in EX-Builder, I have a script called DailyPoem. It reads the file into a variable, and then reads(says) the variable.
$rsstext = filereadline("c:\rssfeeds\test.txt")
say($rsstext)
filereadclose("C:\rssfeeds\test.txt")
I plan on making the code far better. This was just an effort to get something working. I will clean it up and post it for people to use. I will also try to figure out how to make this far less of a two step process and see if it is possible to put the app somehow as a component ARC. I know there is an SDK, but I haven't played much with it.
I hope this helps others who have had this issue with RSS feeds.