From 1747f33c34e85fcbf161e4680404fdce2ee384f0 Mon Sep 17 00:00:00 2001 From: jules on spawn Date: Fri, 25 May 2018 15:56:35 +0200 Subject: if pitchshiftedfiles are not exactly 8 seconds remove them --- datasets/dataset.pl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'datasets') diff --git a/datasets/dataset.pl b/datasets/dataset.pl index cd068bf..568928c 100755 --- a/datasets/dataset.pl +++ b/datasets/dataset.pl @@ -3,8 +3,8 @@ use strict; use Getopt::Std; -our $opt_c; # normalize the file -our $opt_j; # jitter the pitch of each subsample by N rather than repitching big chunks +our $opt_c; # DON'T normalize the file +our $opt_j; # jitter the pitch of each subsample by N 1/100th semitones rather than repitching big chunks getopts('cj:'); print "<<<< DATASET >>>>\n"; @@ -78,9 +78,16 @@ sub process($) { next if /^\./; print "$i...\n" if ++$i % 100 == 0; my $fn = $_; - my $n = rand( 2 * $opt_j ) - $opt_j; - system 'sox', $name . '/' . $fn, $name . '/z_' . $fn, 'pitch', $n; - system 'rm', $name . '/' . $fn; + my $in_fn = $name . '/' . $fn; + my $out_fn = $name . '/z_' . $fn; + my $n = int rand( 2 * $opt_j ) - $opt_j; + system 'sox', $in_fn, $out_fn, 'pitch', $n; + my $rep = `soxi $name/z_$fn`; + if ($rep =~ /352800/) { + unlink $in_fn; + } else { + unlink $out_fn; + } } closedir $dh; } -- cgit v1.2.3-70-g09d2