Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
United Kingdom
Asked — Edited

Rss Feeds

@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.

AI Support Bot
Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#2  
I don't want to look a gift horse in the mouth. But, if there was a way to improve the parsing on the items where we could understand them better it would be nice.

thanks for what you have already done.
United Kingdom
#3  
I'm not sure what you're asking for?
#4  
I guess I am asking for the speech engine to pronounce the words better. But, that would be an issue to discuss with microsoft, i guess.
United Kingdom
#5  
It would be an issue to discuss with whoever produced the voice you are using, be that Microsoft, Cereproc, Acapela etc.

I bought a new voice for Jarvis which has very good pronunciation, sometimes it makes errors but they are very rare.
PRO
USA
#6  
Rich,
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
United Kingdom
#7  
The speech speed will vary for each voice used, I find that the voice I use on Jarvis needs to run at normal speed but other voices I tried needed to run slower to understand them better. It's always going to be a case of playing with the settings and finding out which works best.

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.
PRO
USA
#8  
Rich,
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
United Kingdom
#9  
Yeah, it's just a case of changing the $feedurl variable in each of the scripts really.

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:


# Script Title
# Author: Rich Pyke

# Define variables
# Quote Feed URL
$feedurl = "url to rss feed"

# Speak the story
SpeakRSSDescription($feedurl,1)

# End of script
Halt()


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.
PRO
USA
#10  
Rich,
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
#12  
I love this feature. I have a question about it though. Can you place a RSS feed into a variable as mentioned above, an then use a replace type of command to strip out the extra characters like non-breakable space's ( ) with " ". I haven't found a replace yet, and substring type functions could be a lot of script for a large article. Does anyone have a sample script that does this?
#13  
Here is the issue that I am running up against if I wasn't clear in what I was asking. I don't think that I was at all...

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.
#14  
@steve, please share your finished rss script with us.

thanks,
Mel
PRO
USA
#15  
Here is one way is use a variable in RSS. I am sure there are many ways.
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()
#16  
I guess the question should be phrased more like this...

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!
#17  
This is C# code that will convert RSS into a text file. Now to figure out how to get ARC to read the desired section of the text file.

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 &nbsp; characters - may not be needed
rssContent.Append(description.Replace("&nbsp;", ""));
// regex to turn html into text
file.WriteLine(System.Text.RegularExpressions.Regex.Replace(rssContent.ToString(),"<[^>]*>",""));
}
file.Close();
Application.Run(new Form1());

}

}
}
#18  
Here is the solution that I have so far.

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 &nbsp; characters - may not be needed
rssContent.Append(description.Replace("&nbsp;", ""));
// 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("&mdash;", "");
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.