|
Revision 2270, 2.1 kB
(checked in by kmaclean, 1 year ago)
|
Flac audio processing updates & GPL v3 updates
|
| Line | |
|---|
| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
use strict; |
|---|
| 26 |
use File::Spec; |
|---|
| 27 |
|
|---|
| 28 |
my ($targetrate, $command, $codetrain, $line, $file, $directories, $volume); |
|---|
| 29 |
my ($original_file_type, @filename, $original_sampling_rate); |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
if (@ARGV != 4) { |
|---|
| 33 |
print "Wrong number of arguments ... usage: $0 FilesToBeDownsampled filetype(raw/wav) original_sampling_rate(Hz) targetrate(Hz)\n\n"; |
|---|
| 34 |
exit (0); |
|---|
| 35 |
} |
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
($codetrain, $original_file_type, $original_sampling_rate, $targetrate) = @ARGV; |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
open (FILEIN,"$codetrain") || die ("Unable to open codetrain $codetrain file for reading"); |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
while ($line = <FILEIN>) { |
|---|
| 45 |
chomp ($line); |
|---|
| 46 |
($volume,$directories,$file) = File::Spec->splitpath( $line ); |
|---|
| 47 |
print "downsampling:$file\n"; |
|---|
| 48 |
|
|---|
| 49 |
if ($original_file_type eq "wav") { |
|---|
| 50 |
$command = ("sox $line -r $targetrate -w /home/kmaclean/workspace/VoxForge/Audio/Test/Main/8kHz_16bit/$file"); system($command) == 0 or die "system $command failed: $?"; |
|---|
| 51 |
} else { |
|---|
| 52 |
die ("Error: wrong file type (only \'wav\' or \'raw\' permitted)"); |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
} |
|---|
| 56 |
|
|---|
| 57 |
close(FILEIN); |
|---|
| 58 |
|
|---|