|
|
|
Page 2 of 2
|
[ 22 posts ] |
Go to page: Previous 1, 2 |
| Author |
Message |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6665 Location: Austin, Texas
|
 Re: Say a Text File to a AIF
This python script should work - I'm unclear why it's needed as an AIF file so I just have the Indigo Server say the article titles. - Code: Select all
import urllib2 import xml.dom.minidom
f = urllib2.urlopen("http://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.npr.org%2Frss%2Frss.php%3Fid%3D1001%22&diagnostics=true") dom = xml.dom.minidom.parse(f) f.close() sayString = "" for titleElem in dom.getElementsByTagName("title"): sayString += "%s\n" % titleElem.firstChild.data
# Unclear if you really need it spoken to a file # so I'll just tell the server to speak the string indigo.server.speak(sayString)
You'll probably want to run this as an external script so that if the network connection is slow the script won't get killed prematurely.
_________________ Jay (Indigo Support)
|
| Wed Jun 27, 2012 2:55 pm |
|
 |
|
nsheldon
Joined: Aug 09, 2010 Posts: 767 Location: CA
|
 Re: Say a Text File to a AIF
Nice! That's certainly more elegant than the gobbledygook sed stuff! 
|
| Wed Jun 27, 2012 3:00 pm |
|
 |
|
ckeyes888
Joined: Nov 26, 2009 Posts: 930 Location: Kalispell, MT
|
 Re: Say a Text File to a AIF
Very nice, thanks a bunch! I have my Squeezebox Radio do most my announcements etc. hence the aif file.
Thanks,
Carl
|
| Wed Jun 27, 2012 6:59 pm |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6665 Location: Austin, Texas
|
 Re: Say a Text File to a AIF
This one does the same thing but saves it into the specified file - just change the path to the output file. If the path has spaces in it I think you'll need to precede them with a backslash. - Code: Select all
import urllib2 import xml.dom.minidom import subprocess
f = urllib2.urlopen("http://query.yahooapis.com/v1/public/yql?q=select%20title%20from%20rss%20where%20url%3D%22http%3A%2F%2Fwww.npr.org%2Frss%2Frss.php%3Fid%3D1001%22&diagnostics=true") dom = xml.dom.minidom.parse(f) f.close() sayString = "" for titleElem in dom.getElementsByTagName("title"): sayString += "%s.\n" % titleElem.firstChild.data # So we need to call the "say" command-line tool to # record the string spoken into an .aif file subprocess.call(["say", "-o", "/PATH/TO/RSS.aif", sayString])
_________________ Jay (Indigo Support)
|
| Thu Jun 28, 2012 10:21 am |
|
 |
|
ckeyes888
Joined: Nov 26, 2009 Posts: 930 Location: Kalispell, MT
|
 Re: Say a Text File to a AIF
Thanks. Curious about something... I've been getting the "rest query" to use in my scripts from this site http://developer.yahoo.com/yql/console/#h=select%20title%20from%20rss%20where%20url%3D%22http%3A//www.jokesareawesome.com/rss/random/%22Works fine for just titles but am not seeing how to have the body text included as well. Is that a different process? Thanks, Carl
|
| Thu Jun 28, 2012 10:35 am |
|
 |
|
jay (support)
Site Admin
Joined: Mar 19, 2008 Posts: 6665 Location: Austin, Texas
|
 Re: Say a Text File to a AIF
No clue - I just used your URL, I know nothing about your data source... 
_________________ Jay (Indigo Support)
|
| Thu Jun 28, 2012 3:10 pm |
|
 |
|
ckeyes888
Joined: Nov 26, 2009 Posts: 930 Location: Kalispell, MT
|
 Re: Say a Text File to a AIF
Thanks Jay...it's always something. Trying to have Indigo read a random joke when prompted.
Carl
|
| Thu Jun 28, 2012 3:18 pm |
|
|
|
Page 2 of 2
|
[ 22 posts ] |
Go to page: Previous 1, 2 |
Who is online |
Users browsing this forum: No registered users and 2 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|