#!/usr/bin/perl use IO::Socket; use FileHandle; use IPC::Open2; $file = $ARGV[0]; open (FH, $file) || return undef; $fh = *FH; $file =~ /(gsm|wav)$/; my $type = $1; if ($type !~ /gsm|wav/) { warn "Unknown file type ($file)"; return undef; } print "FTYPE: $type\n"; #sox yellowaudio.wav -r 16000 -c 1 -s -w yellowaudio16k.raw $pid = open2(*SOXIN, *SOXOUT, "sox -t $type - -s -r 8000 -w -t wav - 2>/dev/null") || warn ("Could not open2.\n"); binmode $fh; binmode SOXIN; binmode SOXOUT; binmode $remote; print "hello\n"; while (defined(my $b = read $fh, my($buf), 4096)) { print "b = $b\n"; last if $b == 0; $count += $b; print SOXOUT $buf; print "count = $count\n"; } close SOXOUT; #### top - 17:43:41 up 2:31, 4 users, load average: 0.00, 0.02, 0.06 Tasks: 71 total, 1 running, 70 sleeping, 0 stopped, 0 zombie Cpu(s): 3.5% us, 2.1% sy, 3.3% ni, 86.1% id, 5.0% wa, 0.0% hi, 0.0% si Mem: 515584k total, 399400k used, 116184k free, 27072k buffers Swap: 779144k total, 148k used, 778996k free, 298108k cached