The sounds from the above scripts were not working when I actually tried to use them, so I wrote it again using Audio::Data. This script has worked great so far on real telephone lines and other devices. This save as an au file, but if you need a wav you can use something like ffmpeg to convert it.
#!/usr/bin/perl
use strict;
use Audio::Data;
my(@tones) = qw(1 2 3 4 5 6 7 8 9 0 * #);
my %lut =
(
'1'=>[697,1209], '2'=>[697,1336], '3'=>[697,1477],
'4'=>[770,1209], '5'=>[770,1336], '6'=>[770,1477],
'7'=>[852,1209], '8'=>[852,1336], '9'=>[852,1477],
'*'=>[941,1209], '0'=>[941,1336], '#'=>[941,1477]
);
my $rate = 44000;
my $audio1 = Audio::Data->new(rate => $rate);
my $audio2 = $audio1->clone();
foreach my $tone (@tones)
{
$audio1->tone(${$lut{$tone}}[0],.3,.8);
$audio1->silence(.05);
$audio2->tone(${$lut{$tone}}[1],.3,.8);
$audio2->silence(.05);
}
my $final = $audio1 + $audio2;
open(my $fh, '>dtmf'.join('',@tones).'.wav');
binmode $fh;
$final->Save($fh);
close($fh);
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.