[Asterisk-Users] agi script for german date / time
Sebastian Böhm
seb at exse.net
Wed Mar 23 15:51:23 MST 2005
Hi,
I wanted to say a date (and time) in german, but did not found a way to
do this with sayunixtime, so I wrote this agi script.
(I could switch to german, but it was not correct)
be sure to use the sound files from:
http://www.stadt-pforzheim.de/asterisk/dateien/ast_prompts_de.tgz (which
are of very good quality)
(only works from 2000 to 2019 (-:, which should be enough for the moment )
I adjusted some sleeps beween the digits to make it sound more natural.
feel free to send me your suggestions (it's my first agi script ever),
PS: is there a sound file which contains "the" ?
/sebastian
---------------------SNIP------------------------
#!/usr/bin/perl
use strict;
use Time::HiRes qw/sleep/;
my %params;
$|=1;
while(1)
{
my $line = <stdin>;
chomp($line);
last if $line eq '';
(my $key, my $value) = split(/\: /,$line);
$params{$key}=$value;
}
(undef,my $min,my $hour,my $mday,my $mon,my $year,my $wday,undef,undef)
= localtime(time);
sendcmd('ANSWER');
sleep(1);
sendcmd('STREAM FILE digits/de/day-'.$wday.' 0');
sleep(0.3);
if($mday > 19)
{
my $decade = substr($mday,0,1).'0';
sendcmd('STREAM FILE digits/de/'.($mday-$decade).'-and 0') if $mday
ne $decade;
sendcmd('STREAM FILE digits/de/h-'.$decade.' 0');
}
else
{
sendcmd('STREAM FILE digits/de/h-'.$mday.' 0');
}
sendcmd('STREAM FILE digits/de/mon-'.$mon.' 0');
sendcmd('STREAM FILE digits/de/2 0');
sendcmd('STREAM FILE digits/de/thousand 0');
sendcmd('STREAM FILE digits/de/'.($year-100).' 0');
sleep(0.5);
if($hour > 19)
{
sendcmd('STREAM FILE digits/de/'.($hour-20).'-and 0') if $hour ne 20;
sendcmd('STREAM FILE digits/de/20 0');
}
else
{
sendcmd('STREAM FILE digits/de/'.($hour).' 0');
}
sendcmd('STREAM FILE digits/de/oclock 0');
sendcmd('STREAM FILE digits/de/and 0');
sleep(0.15);
if($min > 19)
{
my $decade = substr($min,0,1).'0';
sendcmd('STREAM FILE digits/de/'.($min-$decade).'-and 0') if $min ne
$decade;
sendcmd('STREAM FILE digits/de/'.$decade.' 0');
}
else
{
sendcmd('STREAM FILE digits/de/'.$min.' 0');
}
sendcmd('STREAM FILE de/minutes 0');
sleep(2);
sendcmd('HANGUP');
sub sendcmd($)
{
my $cmd = shift;
print $cmd." \n";
my $retval = <stdin> ;
return $retval;
}
----------------SNAP-------------
More information about the asterisk-users
mailing list