Trevor Hammonds
2009-Jul-16 11:49 UTC
[asterisk-users] AGI to announce temperature from weather.com XML file
I would like to have the ability to have Asterisk announce the temperature -- not using TTS -- within the dialplan. For a non-Asterisk project, I have a cron job that periodically pulls down an XML file from weather.com containing local weather data (TWC's user agreement requires that data be cached locally). Using sed, I also create a text file that contains only the numeric value of the current temperature, created from that XML file (e.g. <tmp>65</tmp> in the XML file becomes a text file with 65 as its only contents). I am hoping someone on the list has an example of a lightweight AGI script that I may modify to either read the simple text file and set a dialplan variable to the current temperature, or hopefully a more-sophisticated one which will parse the XML file to set the dialplan variable. The end goal is to have Asterisk play the speech files "temperature" "sixty" "five" "degrees" or the equivalent non-English files per the channel's current language setting. Thank you. Any assistance will be greatly appreciated. Sincerely, Trevor Hammonds
John Novack
2009-Jul-16 12:53 UTC
[asterisk-users] AGI to announce temperature from weather.com XML file
Check this one out. developed for AstLinux, it ought to be close to what you want. depending on your version, you may need to modify sound file references http://lonnie.abelbeck.com/astlinux/info/weather.php John Novack Trevor Hammonds wrote:> I would like to have the ability to have Asterisk announce the temperature > -- not using TTS -- within the dialplan. > > For a non-Asterisk project, I have a cron job that periodically pulls down > an XML file from weather.com containing local weather data (TWC's user > agreement requires that data be cached locally). Using sed, I also create a > text file that contains only the numeric value of the current temperature, > created from that XML file (e.g. <tmp>65</tmp> in the XML file becomes a > text file with 65 as its only contents). > > I am hoping someone on the list has an example of a lightweight AGI script > that I may modify to either read the simple text file and set a dialplan > variable to the current temperature, or hopefully a more-sophisticated one > which will parse the XML file to set the dialplan variable. > > The end goal is to have Asterisk play the speech files "temperature" "sixty" > "five" "degrees" or the equivalent non-English files per the channel's > current language setting. > > Thank you. Any assistance will be greatly appreciated. > > Sincerely, > Trevor Hammonds > > > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > >-- Dog is my co-pilot
Barry L. Kline
2009-Jul-16 13:09 UTC
[asterisk-users] AGI to announce temperature from weather.com XML file
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Trevor Hammonds wrote:> I am hoping someone on the list has an example of a lightweight AGI script > that I may modify to either read the simple text file and set a dialplan > variable to the current temperature, or hopefully a more-sophisticated one > which will parse the XML file to set the dialplan variable.I think that the 'FILE' function will do what you're looking for. Barry -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQFKXyZsCFu3bIiwtTARAg/rAJ9D6RQQ2N51GNU8sWHbxPyJM82U1ACgn4bR c55n6BEUTuMPRSsRgETeE9w=YLth -----END PGP SIGNATURE-----
Jared Smith
2009-Jul-16 17:57 UTC
[asterisk-users] AGI to announce temperature from weather.com XML file
On Thu, 2009-07-16 at 04:49 -0700, Trevor Hammonds wrote:> I would like to have the ability to have Asterisk announce the temperature > -- not using TTS -- within the dialplan.Chapter 9 of "Asterisk: The Future of Telephony" shows you how to build an AGI script to do just that. For a free download, check out www.asteriskdocs.org. There are obviously many other ways to do it. -- Jared Smith Training Manager Digium, Inc.
Leif Madsen
2009-Jul-17 17:27 UTC
[asterisk-users] AGI to announce temperature from weather.com XML file
Trevor Hammonds wrote:> I would like to have the ability to have Asterisk announce the temperature > -- not using TTS -- within the dialplan. > > For a non-Asterisk project, I have a cron job that periodically pulls down > an XML file from weather.com containing local weather data (TWC's user > agreement requires that data be cached locally). Using sed, I also create a > text file that contains only the numeric value of the current temperature, > created from that XML file (e.g. <tmp>65</tmp> in the XML file becomes a > text file with 65 as its only contents). > > I am hoping someone on the list has an example of a lightweight AGI script > that I may modify to either read the simple text file and set a dialplan > variable to the current temperature, or hopefully a more-sophisticated one > which will parse the XML file to set the dialplan variable. > > The end goal is to have Asterisk play the speech files "temperature" "sixty" > "five" "degrees" or the equivalent non-English files per the channel's > current language setting. > > Thank you. Any assistance will be greatly appreciated.Since your problem came up on the VoIP Users Conference today, it ended up being the basis for a blog post I wrote today. The blog post (which may solve your problem) is available here: http://leifmadsen.wordpress.com/2009/07/17/howto-read-a-value-from-a-file-and-say-it-back/ Let me know if that works for you -- just respond on the comments section since I don't always check this users list. Note: I haven't actually tested the dialplan yet, so if someone can test it for errors, let me know if you run into any, and I'll update the blog post with any that may be found. Thanks! Leif Madsen. http://www.leifmadsen.com http://www.oreilly.com/catalog/asterisk
Andrew Thomas
2009-Jul-22 08:53 UTC
[asterisk-users] AGI to announce temperature from weather.com XML file
It appears I opened some flood gates when I offered my 'alternative' version. So, rather than send hundreds of e-mails out - here's the link : http://www.dv-ip.com//downloads/files/misc/weather.txt Any questions - just 'yell'. Andrew Thomas Technical Services Manager andy at datavox.co.uk DataVox Ltd Saddleworth Business Centre Huddersfield Road Delph, Oldham OL3 5DF -----Original Message----- From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Leif Madsen Sent: 17 July 2009 18:28 To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: Re: [asterisk-users] AGI to announce temperature from weather.com XML file Trevor Hammonds wrote:> I would like to have the ability to have Asterisk announce thetemperature> -- not using TTS -- within the dialplan. > > For a non-Asterisk project, I have a cron job that periodically pullsdown> an XML file from weather.com containing local weather data (TWC's user > agreement requires that data be cached locally). Using sed, I alsocreate a> text file that contains only the numeric value of the currenttemperature,> created from that XML file (e.g. <tmp>65</tmp> in the XML file becomesa> text file with 65 as its only contents). > > I am hoping someone on the list has an example of a lightweight AGIscript> that I may modify to either read the simple text file and set adialplan> variable to the current temperature, or hopefully a more-sophisticatedone> which will parse the XML file to set the dialplan variable. > > The end goal is to have Asterisk play the speech files "temperature""sixty"> "five" "degrees" or the equivalent non-English files per the channel's > current language setting. > > Thank you. Any assistance will be greatly appreciated.Since your problem came up on the VoIP Users Conference today, it ended up being the basis for a blog post I wrote today. The blog post (which may solve your problem) is available here: http://leifmadsen.wordpress.com/2009/07/17/howto-read-a-value-from-a-fil e-and-say-it-back/ Let me know if that works for you -- just respond on the comments section since I don't always check this users list. Note: I haven't actually tested the dialplan yet, so if someone can test it for errors, let me know if you run into any, and I'll update the blog post with any that may be found. Thanks! Leif Madsen. http://www.leifmadsen.com http://www.oreilly.com/catalog/asterisk _______________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users