#!/usr/bin/perl -w
use strict;
use warnings; 
use Log::Log4perl; 



my $tonePath = '/opt/svam/lib/tones/uploads';
my $log_conf = "/opt/svam/scripts/scm/scmlogger.conf"; 
Log::Log4perl::init($log_conf); 
my $logger = Log::Log4perl->get_logger();
my $continue=1;


chdir($tonePath) ; 
my @files = `ls -1 *.wav`;
my $file;
my $cmd;
foreach $file(@files) {

    $logger->debug("WAV2GSM ::> Fichier WAV detecté ".$file );
    $logger->debug("WAV2GSM ::> Conversion du fichier en GSM ".$file ); 
    chomp $file;
    my @values = split('\.', $file); 
    my $gsmname = $values[0];
    $gsmname = $gsmname.".gsm"; 
    my $cc = "sox $file  -r 8000 -c 1  $gsmname"  ;
    $logger->debug("WAV2GSM ::> Command de conversion  ".$cc );
    
    $cmd = `$cc`; 
    
    $logger->debug("WAV2GSM ::> Conversion en GSM reussi. Ancien fichier ::> ".$file. " Nouveau Fichier ::> ".$gsmname );
        my $erase =    `rm -rf  $file`;
    
    

}


