root/Tags/AudioSegmentation/PromptsShuffle.pl
| Revision 2535, 1.7 kB (checked in by kmaclean, 8 months ago) |
|---|
| Line | |
|---|---|
| 1 | #! /usr/bin/perl |
| 2 | #################################################################### |
| 3 | ### |
| 4 | ### script name : PromptsShuffle.pl |
| 5 | ### version: 0.1 |
| 6 | ### created by: Ken MacLean |
| 7 | ### mail: contact@voxforge.org |
| 8 | ### Date: 2008.02.08 |
| 9 | ### |
| 10 | ### Copyright (C) 2008 Ken MacLean |
| 11 | ### |
| 12 | ### This program is free software; you can redistribute it and/or |
| 13 | ### modify it under the terms of the GNU General Public License |
| 14 | ### as published by the Free Software Foundation; either version 3 |
| 15 | ### of the License, or (at your option) any later version. |
| 16 | ### |
| 17 | ### This program is distributed in the hope that it will be useful, |
| 18 | ### but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | ### GNU General Public License for more details. |
| 21 | ### |
| 22 | ### Changes: |
| 23 | #################################################################### |
| 24 | use strict; |
| 25 | use List::Util 'shuffle'; |
| 26 | use File::Copy; |
| 27 | |
| 28 | my $debug = 1; |
| 29 | #################################################################### |
| 30 | open(PROMPTS, "wav/prompts") or die ("cannot open wav/prompts for input"); |
| 31 | my @list = <PROMPTS>; |
| 32 | |
| 33 | open(PROMPTS, ">wavShuffled/prompts") or die ("cannot open wavJumbled/prompts for output"); |
| 34 | |
| 35 | print "@list\n"; |
| 36 | my @shuffled = shuffle(@list); |
| 37 | print "@shuffled\n"; |
| 38 | my $x = 1; |
| 39 | foreach my $line (@shuffled) { |
| 40 | my ($oldPromptID, @prompt)=split(/ /, $line); |
| 41 | my $prefix = $oldPromptID; |
| 42 | $prefix =~ s/\d//g; |
| 43 | $prefix =~ s/\s//g; |
| 44 | my $padded_fileid = sprintf("%04d",$x); |
| 45 | my $newPromptID = "$prefix$padded_fileid"; |
| 46 | print PROMPTS "$newPromptID @prompt"; |
| 47 | copy("wav/$oldPromptID.wav", "wavShuffled/$newPromptID.wav"); |
| 48 | $x++; |
| 49 | } |
| 50 | close PROMPTS; |
| 51 | |
| 52 |
Note: See TracBrowser for help on using the browser.