Method1:
Using ch_wav commandch_wave -f 16000 -F 8000 -o wav_8KHz/text001.wav ../wav_16KHz/text001.wav
Method2:
Using sox command
Example: Converting 16 Khz wave file into 8 Khz
sox text0001.wav -r 8000 wav_8KHz/text001.wav resample
sox input.wav -r 44000 output.wav resample
Here 44000 is the sampling rate of output file
Example: Converting 16 Khz wave file into 8 Khz
sox text0001.wav -r 8000 wav_8KHz/text001.wav resample
Resampling all files of a directory
write following code in a file suppose down_sample.pl
chomp(@ARGV = <STDIN>) unless @ARGV;
for ( @ARGV )
{
$was = $_;
print "was=$was";
#print "op =$op";
$now="./output/".$was;
print "now1=$now\n";
# @args= ( "ch_wave", "-f", "48000", "-F", "16000", "-o", "$now", "$was");
@args= ( "sox", "$was", "-r", "16000", "$now", "resample" );
system(@args);
}
chomp(@ARGV = <STDIN>) unless @ARGV;
for ( @ARGV )
{
$was = $_;
print "was=$was";
#print "op =$op";
$now="./output/".$was;
print "now1=$now\n";
# @args= ( "ch_wave", "-f", "48000", "-F", "16000", "-o", "$now", "$was");
@args= ( "sox", "$was", "-r", "16000", "$now", "resample" );
system(@args);
}
Suppose you are having 48 Khz wav files i directory wav_48khz:
1. Copy the down_sample.pl file having above code into wav_48khz directory
2. Create directory output inside wav_48khz directory
3. Open terminal and go to the wav_48khz directory
4. run following command
perl down_sample.pl *.wav
5. 16 Khz wav files will be inside output directory
7. You may use either sox or ch_wav command. Some times ch_wav command does not recognise wave files then we should use sox.