Author Topic: error record wave  (Read 7538 times)

Dam Dat

  • Newbie
  • *
  • Posts: 9
    • View Profile
error record wave
« on: August 14, 2018, 06:56:05 PM »
hello everybody i found some guide codes "record call" in this page
https://gist.github.com/vir/b1a868ef1d4aa5239064

#!/usr/bin/perl
use strict;
use warnings;
use Yate;
use Data::Dumper;

# Convert results into stereo wav:
#  sox -M /tmp/rec_2015-05-20T17\:09\:44_no-billid_6134-[AB].au /tmp/rec_2015-05-20T17:09:44_no-billid_6134.wav

my $yate = new Yate(Debug=>0);
$yate->connect("127.0.0.1:42428");
$yate->install('call.answered', \&call_answered_handler, 70);
$yate->listen();

sub call_answered_handler
{
  my $m = shift;
  my $billid = $m->param('billid') // 'no-billid';
  my $date = mk_date();
  my $fn = sprintf("/tmp/rec_%s_%s_%04d", $date, $billid, int(rand(10000)));
  my $ext = 'au';
  print "Recording call: $fn\n";
  $m->message('chan.masquerade', undef, '',
    message => "chan.record",
    id => $m->param('id'),
    peer => "wave/record/$fn-A.$ext",
    call => "wave/record/$fn-B.$ext",
  );
  open F, '>:utf8', "$fn.txt" or warn "Can't open $fn.txt: $!\n";
  print F Dumper($m->{params});
  close F or warn "Can't write to $fn.txt: $!\n";

  $date =~ s/_.*//;
  my $script = "/tmp/convert_$date.sh";
  my $first = !-e $script;
  open F, '>>:utf8', $script or warn "Can't open $script: $!\n";
  print F "#!/bin/sh\n" if $first;
  print F "sox -M $fn-[AB].au $fn.wav && rm $fn-[AB].au\n";
  close F;
  return undef;
}

sub mk_date
{
  my $time = shift;
  my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($time // time());
  return sprintf "%04d-%02d-%02d_%02d%02d%02d", $year + 1900, $mon + 1, $mday,$hour,$min,$sec;
}



and i received this response :
Can't locate Yate.pm in @INC (you may need to install the Yate module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at /home/p52/record_all_calls.pl line 4.
BEGIN failed--compilation aborted at /home/p52/record_all_calls.pl line 4.

who can hepl me fix this error please!