Multiple Sound Folders - Spanish Syntax

Dear friends,

Many of you may have wanted to add multiple AstCC IVRs with different sound files, so each has its own voice. This may apply if you need to host different IVRs for different companies, but want to use only one main astcc.agi file.

Below is a PERL script that can substitue the original mysaynumber sub-routine in AstCC.

You may use it in any other AGI file:

sub mysaynumber() {
my $step = "9";
my ($number) = @_;
my $res;

/######################################################
/### Support for separate sound file in spanish syntax:
/######################################################

if ( index( $sound_map, "\_es" ) > -1 ) {

my $thousands = int ( $number / 1000 );

my $remains = ( $number - $thousands * 1000 );

$AGI->verbose( "Spanish Syntax for: $sound_map.", $verbose );
$AGI->verbose( "Number: $number.", $verbose );

if ( $thousands > 0 && $thousands < 30 ) {
if ( $thousands > 1 ) {
$res = &mystreamfile("digits/$sound_map/$thousands");
$AGI->verbose( "Thousands: $thousands", $verbose );
}
$res = &mystreamfile("digits/$sound_map/mil");
$AGI->verbose( "Thousand Sound: digits/$sound_map/mil", $verbose );
}

return $res if ( length($res) );

my $hundreds = int ( $remains / 100 );

$remains = $remains - $hundreds * 100;

if ( $hundreds ) {
if ( $hundreds > 1 || ( $hundreds == 1 && $remains == 0 ) ) {
$hundreds = $hundreds * 100;
$res = &mystreamfile("digits/$sound_map/$hundreds");
$AGI->verbose( "Hundreds: $hundreds", $verbose );
} else {
$res = &mystreamfile("digits/$sound_map/100-and");
$AGI->verbose( "Hundred and sound file: 100-and", $verbose );
}
}

$AGI->verbose( "RES inside mysaynumber: $res", $verbose );
return $res if ( length($res) );

my $decades = int ( $remains / 10 );

$remains = $remains - $decades * 10;

if ( $decades > 2 ) {
$decades = $decades * 10;
$res = &mystreamfile("digits/$sound_map/$decades");
$AGI->verbose( "High Decades: $decades", $verbose );
if ( $remains > 1 ) {
$AGI->verbose( "With $remains", $verbose );
$res = &mystreamfile("digits/$sound_map/and");
return $res if ( length($res) );
$res = &mystreamfile("digits/$sound_map/$remains");
return $res if ( length($res) );
} elsif ( $remains == 1 ) {
$AGI->verbose( "With 1M", $verbose );
$res = &mystreamfile("digits/$sound_map/and");
return $res if ( length($res) );
$res = &mystreamfile("digits/$sound_map/1M");
return $res if ( length($res) );
}
} else {
$decades = $decades * 10 + $remains;
$AGI->verbose( "Low Decades: $decades", $verbose );
$res = &mystreamfile("digits/$sound_map/$decades");
return $res if ( length($res) );
}
return $res if ( length($res) );

/######################################################

} else {
$AGI->verbose( "Res: $res before Playing: $number without Custom Syntax", $verbose );
$res = $AGI->say_number( $number, "0123456789");
$res = "" if $res eq "0";
$res = sprintf("%c", $res) if length($res);
}

$AGI->verbose( "RES at end of mysaynumber: $res", $verbose );

return $res;
}

To make the script work correctly, you'd need to call it with something like:

DeadAGI astcc.agi
VEB|${CALLERID}|${EXTEN}|${ACCOUNTCODE}|comtelnetworks_es

Where the last parameter is the sound map to the folder.

This is how the parameters are received:

($calleridnum, $phoneno, $quiet, $currency, $ani, $channel, $acct_code, $sound_map ) = @ARGV;

my $next_ivr = substr ( $channel, 0, length( $channel ) - 6 );

if ( $sound_map ne "" && length ( $sound_map ) > 0 ) {
$res = $AGI->exec('Set',"LANGUAGE()=$sound_map");
}


After that, you need to place the corresponding AstCC and digit sound files in the following way, considering the example and assuming standard installation paths:

/var/lib/asterisk/sounds/comtelnetworks_es
/var/lib/asterisk/sounds/digits/comtelnetworks_es

Other options have been added:
- Support for the VEB currency.
- Setting of the outbound accountcode different from the one of the incoming DID.
- Surcharges according to ANI and DID number.

If you need further support, please feel free to contact me (Max Glucksmann):
mglucksmann at comtel-networks.com
Dear friends,

Many of you may have wanted to add multiple AstCC IVRs with different sound files, so each has its own voice. This may apply if you need to host different IVRs for different companies, but want to use only one main astcc.agi file.

Below is a PERL script that can substitue the original mysaynumber sub-routine in AstCC.

You may use it in any other AGI file:

sub mysaynumber() {
my $step = "9";
my ($number) = @_;
my $res;

/######################################################
/### Support for separate sound file in spanish syntax:
/######################################################

if ( index( $sound_map, "\_es" ) > -1 ) {

my $thousands = int ( $number / 1000 );

my $remains = ( $number - $thousands * 1000 );

$AGI->verbose( "Spanish Syntax for: $sound_map.", $verbose );
$AGI->verbose( "Number: $number.", $verbose );

if ( $thousands > 0 && $thousands < 30 ) {
if ( $thousands > 1 ) {
$res = &mystreamfile("digits/$sound_map/$thousands");
$AGI->verbose( "Thousands: $thousands", $verbose );
}
$res = &mystreamfile("digits/$sound_map/mil");
$AGI->verbose( "Thousand Sound: digits/$sound_map/mil", $verbose );
}

return $res if ( length($res) );

my $hundreds = int ( $remains / 100 );

$remains = $remains - $hundreds * 100;

if ( $hundreds ) {
if ( $hundreds > 1 || ( $hundreds == 1 && $remains == 0 ) ) {
$hundreds = $hundreds * 100;
$res = &mystreamfile("digits/$sound_map/$hundreds");
$AGI->verbose( "Hundreds: $hundreds", $verbose );
} else {
$res = &mystreamfile("digits/$sound_map/100-and");
$AGI->verbose( "Hundred and sound file: 100-and", $verbose );
}
}

$AGI->verbose( "RES inside mysaynumber: $res", $verbose );
return $res if ( length($res) );

my $decades = int ( $remains / 10 );

$remains = $remains - $decades * 10;

if ( $decades > 2 ) {
$decades = $decades * 10;
$res = &mystreamfile("digits/$sound_map/$decades");
$AGI->verbose( "High Decades: $decades", $verbose );
if ( $remains > 1 ) {
$AGI->verbose( "With $remains", $verbose );
$res = &mystreamfile("digits/$sound_map/and");
return $res if ( length($res) );
$res = &mystreamfile("digits/$sound_map/$remains");
return $res if ( length($res) );
} elsif ( $remains == 1 ) {
$AGI->verbose( "With 1M", $verbose );
$res = &mystreamfile("digits/$sound_map/and");
return $res if ( length($res) );
$res = &mystreamfile("digits/$sound_map/1M");
return $res if ( length($res) );
}
} else {
$decades = $decades * 10 + $remains;
$AGI->verbose( "Low Decades: $decades", $verbose );
$res = &mystreamfile("digits/$sound_map/$decades");
return $res if ( length($res) );
}
return $res if ( length($res) );

/######################################################

} else {
$AGI->verbose( "Res: $res before Playing: $number without Custom Syntax", $verbose );
$res = $AGI->say_number( $number, "0123456789");
$res = "" if $res eq "0";
$res = sprintf("%c", $res) if length($res);
}

$AGI->verbose( "RES at end of mysaynumber: $res", $verbose );

return $res;
}

To make the script work correctly, you'd need to call it with something like:

DeadAGI astcc.agi
VEB|${CALLERID}|${EXTEN}|${ACCOUNTCODE}|comtelnetworks_es

Where the last parameter is the sound map to the folder.

This is how the parameters are received:

($calleridnum, $phoneno, $quiet, $currency, $ani, $channel, $acct_code, $sound_map ) = @ARGV;

my $next_ivr = substr ( $channel, 0, length( $channel ) - 6 );

if ( $sound_map ne "" && length ( $sound_map ) > 0 ) {
$res = $AGI->exec('Set',"LANGUAGE()=$sound_map");
}


After that, you need to place the corresponding AstCC and digit sound files in the following way, considering the example and assuming standard installation paths:

/var/lib/asterisk/sounds/comtelnetworks_es
/var/lib/asterisk/sounds/digits/comtelnetworks_es

Other options have been added:
- Support for the VEB currency.
- Setting of the outbound accountcode different from the one of the incoming DID.
- Surcharges according to ANI and DID number.

If you need further support, please feel free to contact me (Max Glucksmann):
mglucksmann at comtel-networks.com
Created by: mglucksmann, Last modification: Fri 28 of Jul, 2006 (15:54 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+