#!/usr/bin/perl # # Announces the time, and sometimes the date # # Last updated by rb on Sat Nov 22 07:35:03 EST 2003 # #use strict; use Festival::Client; use AI::TimeInWords; use AI::DateInWords; use vars qw/$text $Festival $Converter $DEBUG/; $DEBUG = 0; $Converter = AI::TimeInWords->new(); if ((my $i = rand(100)) < 50) { # 50% chance of short time "quater past ten" $DEBUG && warn $i; $text = "It's " . $Converter->ShortTime() . "."; } elsif ($i < 75) { # 25% chance of short time and weekday $DEBUG && warn $i; my $DateConverter = AI::DateInWords->new(); $text = "It's " . $Converter->ShortTime() . " on " . $DateConverter->WeekdayInWords() . "."; } elsif ($i < 95) { # 20% chance of long time "a quater past ten in the morning $DEBUG && warn $i; $text = "It's " . $Converter->LongTime() . "."; } else { # 5% chance of long time and short date # "a quater past ten in the morning on Monday, the sixth of November" $DEBUG && warn $i; my $DateConverter = AI::DateInWords->new(); $text = "It's " . $Converter->ShortTime() . " on " . $DateConverter->ShortDate() . "."; } if ($DEBUG) { warn $text; } else { $Festival = Festival::Client->new("localhost"); $Festival->say($text); } # # End. #