sox file1.wav -b 16 -c 1 -r 8k file2.wav
<?php
//getting all files of desired extension from the dir using explode
$desired_extension = 'wav'; //extension we're looking for
$dirname = "./";
$dir = opendir($dirname);
while(false != ($file = readdir($dir)))
{
if(($file != ".") and ($file != ".."))
{
$fileChunks = explode(".", $file);
if($fileChunks[1] == $desired_extension) //interested in second chunk only
{
echo $file;
echo "\n";
$file2='old'.$file;
//$command =' cp '. $file.' '.substr($file,0,strlen($file)-4).'old';
// sox -t raw -r 8000 -A -b 8 -c 1 fen.alaw file.wav
$command =' cp '. $file.' '.$file2;
echo $command;
echo "\n";
system($command,$return);
echo $return;
$command='sox '.$file2.' -b 16 -c 1 -r 8k '.$file;
echo $command;
echo "\n";
system($command,$return);
echo $return;
}
}
}
closedir($dir);
?>