Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

marcel (3299)

  (email not shown publicly)

Journal of marcel (3299)

Tuesday July 23, 2002
07:29 AM

spoken news

[ #6566 ]

Hear your favourite RSS newsfeeds: Take some LWP, a little XML::RSS and season with command-line driven AppleScript.


use warnings;
use strict;
use XML::RSS;
use LWP::Simple;

my %news = (
        slashdot => "",
        useperl => "",

my $key = shift || die "usage: $0 key\n";
die "unknown key\n" unless exists $news{$key};

my $rss = XML::RSS->new or die "can't create XML::RSS?";
eval { $rss->parse(get( $news{$key} )) } and not $@
        or die "cannot get or parse content: $@";

for my $item (@{$rss->{items}}) {
                my $title = $item->{title};
                my $spoken = prepare_spoken($title);;

                print "title: \n";
                print "spoken: \n\n";
                system('/usr/bin/osascript', '-e', sprintf q!say "%s"!, $spoken)
                        == 0 or die "can't speak '$spoken': $?";

sub prepare_spoken {
                local $_ = shift;
                $_ = lc;

                s/\.NET/ dot net /gi;
                s/U\.S\./ U S /gi;
                s/mozilla/ mo zilla /gi;
                s/AMD's/ AMDs /gi;
                s/yapc/ yapsee /gi;
                s/bsd/ BSD /gi;

                s/(\d+)-/ $1 /gi;
                s/(?=\S)\.(?=\S)/ dot /gi;
                s/(?=\.)/ /g;


Note that prepare_spoken is rather primitive; some more general rules would be appreciated. Send suggestions to

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.