Author Topic: error record wave  (Read 5965 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

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->install('call.answered', \&call_answered_handler, 70);

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_$";
  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 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/ line 4.
BEGIN failed--compilation aborted at /home/p52/ line 4.

who can hepl me fix this error please!