United Kingdom
Asked — Edited
Resolved Resolved by CochranRobotics!

Two Questions Regarding Rss Feed Scripts

Hi guys.

I need a little help with an RSS feed script and hoping someone can point me in the right direction.

Question one.

Is there a way to have an RSS feed to be spoken through the EZB4 instead of through the PC's sound card as I haven't seen a "SpeakRSSEZB() script function?

Question 2.

I am looking for a way to insert something similar to a "Sleep()" function in-between each RSS feed in the script below with a 2 second gap between each feed read.


SpeakRSS("http://feeds.skynews.com/feeds/rss/uk.xml",1)
SpeakRSS("http://feeds.skynews.com/feeds/rss/uk.xml",2)
SpeakRSS("http://feeds.skynews.com/feeds/rss/uk.xml",3)
SpeakRSS("http://feeds.skynews.com/feeds/rss/uk.xml",4)

The "Sleep() script function is not a viable option as the length of the feeds spoken change length from day to day (or hour to hour) so I need something like a "SayWait() but not sure what or where to put the correct function in to my script.

Many thanks.

Steve G. :)


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

United Kingdom
#1  

Well I have spent some time and gone through the entire script command menu, but have not seen a command that will "speak" an RSS feed through the EZ-B v4's speaker, only through my PC's speakers. Is there a way to do this, and if not, can this be an ARC feature request? confused

Thanks.

#2  

That's because speak RSSEZB hasn't been added yet... Not sure if it will be added... Maybe it will at some point....

United Kingdom
#3  

When I wrote "Speak RSSEZB()" it was just example of what I wanted to accomplish ;). Hopefully DJ will consider adding this feature if there's no other way. It would be a great addition.

United Kingdom
#4  

@EZ-Robot team.

Hi guys. I would like to mark this thread as resolved so can I ask, has adding the ability to have an RSS feed to be heard through the EZ-B4 speaker been added to the "to do" list for ARC for a future release?

@everybody else

Has anyone found a way to achieve this with some cleaver scripting? I have had a little play around with scripts but been unable to get it to work.

Thanks. :)

United Kingdom
#5  

You could use scripting but the SpeakRSS() command doesn't save the results to a variable, you would need to use HTTPGet() and parse the returned results. Such a simple task is a fair amount of scripting (so I've not even looked at doing it).

#6  

I have written an exe In c# that gets all of my rss feeds for the day and places them into text files on my computer. It also strip out the characters that cause issues when reading the rss feeds. In ARC, I read these files into variables. I haven't tried it yet, but you should be able to then use the variable in a speakezb command. I am in the middle of a crisis at work right now. I will post the code for the exe later today when I have time to find it.

#7  

It has been a while since I looked at this, but here is a good sample to start with.

This build a file at "C:\rssfeeds\Bible.txt" and uses "http://feeds.feedburner.com/ESV-one-year-tract?format=xml" for the feed.


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 BibleVerse
{
    static class BibleVerse
    {
        /// <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.feedburner.com/ESV-one-year-tract?format=xml");

            // 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\\Bible.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();

            
            nextline = null;
            //Application.Run(new Form1());
            Application.Exit();
        }

    }
}



In ARC I have a script that reads the file into a variable called $rsstext and then uses the Say command to read the variable. This could be changed to the SAYEZB command.

After the reading is complete, it deletes the file and clears the variable to save memory and drive space.


#Run the app to get the poem
Exec("c:\rssfeeds\BibleVerse.exe")
Say("Retrieving the words of the almighty father for you sir.")
sleep(1000)
Say("Genesis, exodus, leviticus, numbers, oh here we are with todays verses")
#Load the poem into a variable
$rsstext = filereadline("C:\rssfeeds\Bible.txt")
#Read the poem
say($rsstext)
#Close the poem
filereadclose("C:\rssfeeds\Bible.txt")
#Delete the text and prepare for the next one
filedelete("C:\rssfeeds\Bible.txt")
#dump memory
$rsstext = ""

This way allows you to call the exe, which then generates the file on the fly. I had thought about making this database driven to allow you to store the RSS feed locations in a database, and then call them by ID instead of calling the exe.

In any event, it works. Using this the way it is now, you would have to create an exe for each feed, but that isnt hard and keeps you from making it too complicated in the long run. I like to complicate things so I am sure at some point in the future, I will make this database driven and store the text to the database for that day, and then update the variable from the database.

Let me know if you have any questions.

#8  

I gave this one because it is impressive how much can be stored in a variable to be passed into the say command.

This part

 Say("Retrieving the words of the almighty father for you sir.")
sleep(1000)
Say("Genesis, exodus, leviticus, numbers, oh here we are with todays verses")

allows the executable time to get the feed and parse it without the robot sitting and acting like it is waiting for something (which it is).

Trinidad/Tobago
#9  

@d.cochran if you are outputting to the pc speakers using the say command should you use saywait instead?


SayWait("#text here")

that way you don't have to put the sleep in there...

#10  

Agreed. I think this was one of my first scripts for ARC. Lot of options. This one worked and I moved on to trying other parts of ARC. I wrote all of this before getting my first ez-b. The sleep is there to give it a pause though and not to really wait for something to be said. I wanted it to look like it was thinking a bit.

I wrote this more to clean up the RSS feed than anything, but it would work for the need posted in this thread to allow the user to speak an RSS feed through the EZ-B along with cleaning up a bunch of the junk that is in RSS Feeds. This doesn't get everything, but does get an estimated 95% of the garbage out of the feeds that I tried it with. This was another thing that I was going to do with making it database driven. I was going to specify which parts of the regex and cleanup were needed for each feed in the database table. Another thing that could be done is to make it to accept parameters that would allow you to call one exe and pass in the feed. Because the file is cleaned up after it is read, you could use one exe and one text file.

Lots of ideas in my head but I just haven't had the time to put them into action. I had also though about having a student complete this when I got into the programming level of the course that I am teaching. It would be a good project for someone to work on, but by the time I get to that point, I am sure it wont be needed because it will be in ARC anyway :)

Another thing that I would add is to disable the speech recognition at the beginning of the script and enabling it at the end.

United Kingdom
#11  

Thanks for your responses guys, much appreciated and sorry for the late reply. Had a crisis of my own to deal with today.

Quick question. How or where do I use the first set of code in post #8? Never used any programming code like C# so not sure what to do with it.

#12  

@Steve G,

Yes, that is C# code. You can download a free version of Visual Studio from Microsoft to compile the code into programs.

Alan

#13  

if you want, send me the list of RSS feeds that you want to use and I will build multiple exe's for you to call from your script. I can test them to make sure things work as you need them to. I might not be able to get to it until early next week due to going out of town with family, but I would be willing to help you there.

#14  

It would be good for you to get C# downloaded and installed and attempt to do it yourself just so that you can learn from this. I will help you there also.

United Kingdom
#15  

Thanks very much for the offer @d.cochran. I will try it out myself first to see if I can get my head around it, but if I get stuck I will give you a shout with the feeds. :)

#16  

sounds like a plan. Good luck and let me know if you need anything.

United Kingdom
#17  

A real quick-and-dirty method for scripting could be using the native XML type in PowerShell to get the RSS, pipe it to a file, then use one of the FileRead functions in EZB. That way, the XML can be manipulated into all kinds on wonderful ways quite easily.

The PowerShell code would be simple:


$rss = New-Object XML;
$rss.Load("https://yourRSS/feed/URL");
# Probably some stuff here to format the XML
$rss | Out-File -FilePath "C:\Path\To\File.ext";

EZB script might be something like this:


$rss = FileReadEnd("C:\Path\To\File.ext")
Say($rss)

Wrote that from memory though... so it could be a lot cleaner :)

Edit: I missed the "Say()" function from the EZB code

United Kingdom
#19  

@d.cochran.

Well I downloaded Visual Studio and gave it a try, and failed miserably as I kept getting errors. Bearing in mind that I didn't really know what I was doing, I obviously did something wrong so I would like to take you up on your help request. Please find the RSS feeds below.


SpeakRSS("http://feeds.skynews.com/feeds/rss/uk.xml")

SpeakRSS("http://www.rssweather.com/wx/gb/london/rss.php",1)

SpeakRSS("http://www.rssweather.com/wx/gb/london/rss.php",2)

SpeakRSS("http://www.rssweather.com/wx/gb/london/rss.php",3)

SpeakRSS("http://www.rssweather.com/wx/gb/london/rss.php",4)

SpeakRSS("http://www.fta.co.uk/feeds/traffic_incidents.xml")

I will still keep playing around with it but it's like trying to find my way around in the dark at the moment, so any help you can offer will be most welcome. ;)

#20  

Will do. I will have time to do this for you tonight. I will test them and will post these on http://cochranrobotics.com/EZ-Robot-Plugins

I will get to these at about 6:00 PM CST so that you should have these by tomorrow.

United Kingdom
#21  

Fantastic. There's no rush so please take your time. And thank you very much. :)

#22  

I took lunch to get the first one going for you.

I published a sample project at Example

Try this one. I tested it and it works well for me. I did change the code in the exe to handle the feed. I placed the code for the exe in the notepad component in the project if anyone is interested.

It was compiled with .net framework 4.5. Instructions are in the EZ-Robot project. Let me know if you have any issues with this one and I will work on the others tonight.

Thanks David

#23  

d.cochran... works great... Is there anyway to change the feed location to something other than the UK?

#24  

You would have to modify the exe or build a new one using the code that is in the package. I will make a modification to this when I have time, that will allow you to pass a parameter with the rss feed into it, and it would then generate a file that is more generic. I will be publishing all 6 of these so that anyone can see how to modify the exe until I complete the addition.

The code for reworking the exe is in the notes section of the ez-robot job if you want to try your hand at making the change.

#25  

@David, I figured that much... I saw the code in the notes... Although I understand the code as I use C in the arduino IDE all the time... For the life of me, I wouldn't have a clue in how to compile it into a Window's executable...

Anyway, no worries I know you're busy....

Cheers Richard

United Kingdom
#26  

@d.cochran.

That's fantastic David. It works like a charm :D. After my failed attemp I must admit it was a little over my head to achieve this (for now at least). I can't thank you enough for supplying this. Once I get Xmas out of the way I will look in to studying C# programming a bit more, but for now I have enough to do learning all what EZ Script can do and how to use it to try and fully get the most out of it before starting to learn a new language.

Anyway I really appreciate your help with this, and thank you once again. :)

Steve G.

#27  

The wife and daughter had a Christmas party to go to which left me with time to think about this and work on it. I decided to go ahead and give the exe the ability to accept and expect command line args. The project is here

The new exe can be downloaded from

here

You need to put this into a directory on c:\rssfeeds which you will need to create. I didn't take the time to build a setup package as I am sure this will change with time. I have only tested this with one RSS feed which is skynews' rss feed.

Let me know if you run into any issues.

Thanks David

#28  

I have been toying with this a bit. I have tested with News, Weather and Traffic. It is a bit better and also includes the title blocks in the RSS now. This makes the news and weather a bit easier to understand. I dont have a clue about your streets so I assume it is more clear.

Also, if you get to where you can work with C#, you could replace words with phonetically spelled words as you find them. One that I have replaced is Winds with Wends. it sounds much nicer when the robot is speaking.

Check it out. I will check back tomorrow for any issues you have in using this.

United Kingdom
#29  

Thanks for the update David. I tried the News, Weather, Traffic project but when I try to open rssGetter.exe I get the message "You must pass the RSS feed location". I'm not sure what I need to do here?

User-inserted image

#30  

@Steve That exe is supposed to be called from within the ARC example that d.cochran linked above... It's not a stand alone app... Download the ezb file project and edit it as you wish.....

@d.cochran... the new version works great.... thanks

United Kingdom
#31  

That's what I thought I did do but can't get this example to work like the other one did.

User-inserted image

#32  

Specifically, what is not working for you? See where your mouse is in the above picture? Use the edit box on each line to adjust your code to your specific needs... I have the news adjusted to the US and the weather set to a location close to my home town.... I haven't looked at the traffic yet....

check the path of the rssfeed.txt and see why the program can't find it....

United Kingdom
#33  

It's not finding the 'C:\rssfeeds\rssfeed.txt'. file to read the info according to the debug window. Not sure what I have done wrong here. The first project for the news worked absolutely fine, and still does, but for the life of me cannot figure out why the rssGetter.exe is not working for me. As far as I'm aware i followed the instructions to the letter.

#34  

I think I might know what's going on with steve. Check to make sure the exe isn't already running in the task manager in windows. If it is, kill it. I thought of a possible bug when I was about to fall asleep last night. If you run the exe without passing a parameter, it might not be exiting the app. I will look at it this morning.

If the app is running in task manager, kill it and then try again from the example ARC project.

United Kingdom
#35  

Thanks David and Richard. Well I got the News to work following Richards advice to check the rss feed path and edited it in the project, but no luck with the weather or traffic as there are no text files for them to be read.

#36  

Okay, the exe is working. What are you passing in for the rss feed for weather?

If it's one of the ones from earlier, try removing the ,1 from the end of the url.

United Kingdom
#37  

Right, success :D. I deleted everything and started again from scratch, reinstalled the project and RSS get file and it all works really well now. That is a great little project you made there David and will come in very useful. Thank you once again for what you have supplied and for all your help.

Steve. :)

#38  

@Setve G

I just updated the ARC project with rss feeds that should work for you.

The exe always writes to the same text file (c:\rssfeeds\rssfeed.txt). This allows you to only have to change the line in the script that looks like

Exec("c:\rssfeeds\rssGetter.exe", "http://www.rssweather.com/wx/gb/london/rss.php")

You can copy the script text and paste it into a new script and then change this line. You could make this a parameter and then set it, and call a single script that would read in this variable to read whatever rss feed you wanted also.

I will also setup a couple of scripts that will do this in the ARC project.

United Kingdom
#39  

Brilliant. Thanks again. One question, what does the init script in the rss script manager actually do, as it seems to work with out starting the init script?

#40  

It is setup in the connection to execute. Once you connect to the EZ-B it sets up a couple of variables that are going to be used for the RSS feed. It isnt necessary but I like to see all of my variables at the start of the project.

I have a new version here for you. You will see a few new scripts.

ReadNews, ReadWeather and ReadTraffic, along with readRSS. The readRSS script is what calls the exe and does the actual work of reading the RSS feed.

The other 3 are what you would modify to call the readRSS script. They set some variables so that readRSS can work.

This is the ReadTraffic script.


$feedDescription = "Traffic"
$rssLocation = "http://www.fta.co.uk/feeds/traffic_incidents.xml"
ControlCommand("Script Manager", ScriptStart, "readRSS")

This just makes it a bit easier to use and a bit easier to add new feeds as you need to. Download the EZ-B project again to see how its all used.

Your very welcome. I love adding features to ARC that haven't been put in yet. I am sure that DJ and team will put this in at some point, but this helps and can allow them to focus on something else for a bit.

#41  

Good Afternoon,

I am looking for some assistance with this program. I cannot find the latest .exe file to use?

#42  

Rss reader was added into the ez-ai package along with all of the other projects that I had going on. By adding it into ez-ai, I was able to allow the user to also do some phonetic changes to text, and clean up the encoding characters that were a part of the rss feeds. Ez-ai is being rewritten (and will also include this feature). Because it is being completely rewritten in a different language with a different database backend, I won't be able to help much without slowing down the production of the new ez-ai. My development resources are tied up with this project right now trying to meet a very tight deadline.

Switzerland
#43  

hello,

any news ? or where can I get the old "rssGetter.exe" ?