Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Yate call recorder script
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;

This comment has been minimized.

Copy link

commented Sep 26, 2017


Will you please help me the procedure to implement this file on Yate whereas am currently using Yate 6.0. And as i think this script record both leg of call and convert into single wav file if am not wrong. Connect with 42428 is failed on Yate 6.0.

Is it possible to update this script to latest version.

And also have doubt as whether if caller made multiple person conference then it would record every channel as well.?


This comment has been minimized.

Copy link

commented Jul 31, 2018

tell me please, how can i run .pl file ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.