| 39 | | 'EN' => ['English',1], # 1 = language supported in SVN, only put link to audio in VoxForge repository |
|---|
| 40 | | 'NL' => ['Netherlands',1], |
|---|
| 41 | | 'DE' => ['Germany',1], |
|---|
| 42 | | 'RU' => ['Russian',1], |
|---|
| 43 | | 'HE' => ['Hebrew',0], # 0 = language not supported in SVN, upload tar file to WebGUI |
|---|
| 44 | | 'IT' => ['Italian',0], |
|---|
| 45 | | 'SP' => ['Spanish',0], |
|---|
| 46 | | 'PT-BR' => ['BrazillianPortuguese',0] |
|---|
| | 51 | 'EN' => ['English','yes'], |
|---|
| | 52 | 'NL' => ['Netherlands','yes'], |
|---|
| | 53 | 'DE' => ['Germany','yes'], |
|---|
| | 54 | 'RU' => ['Russian','yes'], |
|---|
| | 55 | 'HE' => ['Hebrew','no'], |
|---|
| | 56 | 'IT' => ['Italian','no'], |
|---|
| | 57 | 'SP' => ['Spanish','no'], |
|---|
| | 58 | 'PT-BR' => ['Brazillian-Portuguese','no'], |
|---|
| 50 | | my $command; |
|---|
| 51 | | #my ($promptspath, $readmepath, $licensepath); |
|---|
| 52 | | #my ($path_original,$AudioDirName,$tarfile,$pathtoTarfile); |
|---|
| 53 | | |
|---|
| 54 | | #################################################################### |
|---|
| 55 | | ### Main |
|---|
| 56 | | #################################################################### |
|---|
| 57 | | $self->getOptions(); |
|---|
| 58 | | $self->main(); |
|---|
| 59 | | print "completed\n"; |
|---|
| 60 | | |
|---|
| 61 | | #################################################################### |
|---|
| 62 | | ### Main |
|---|
| 63 | | #################################################################### |
|---|
| 64 | | |
|---|
| 65 | | sub Main { |
|---|
| 66 | | my ($self)= @_; |
|---|
| | 63 | $self->Process(); |
|---|
| | 64 | print "completed\n"; |
|---|
| | 65 | |
|---|
| | 66 | =head2 Process |
|---|
| | 67 | |
|---|
| | 68 | =cut |
|---|
| | 69 | |
|---|
| | 70 | sub Process { |
|---|
| | 71 | my ($self)= @_; |
|---|
| | 72 | getopts('t:d:hg'); # sets $opt_* as a side effect. |
|---|
| | 73 | if ($opt_h) { |
|---|
| | 74 | print "\nVoxForge Manual WebGUIForum Update\n"; |
|---|
| | 75 | print "=============================================\n"; |
|---|
| | 76 | print "-d\t directory containing tar file or \n"; |
|---|
| | 77 | print "\t set of tar files to be uploaded to WebGUI Forum\n"; |
|---|
| | 78 | print "-g\t group of tar files contained in directory (-d)\n"; |
|---|
| | 79 | print "-h\t help\n"; |
|---|
| | 80 | print "-t\t tar file name (use \"-d\" to set path)\n"; |
|---|
| | 81 | print "--\n"; |
|---|
| | 82 | print "Free Speech... Recognition\n"; |
|---|
| | 83 | print "http://www.voxforge.org\n\n"; |
|---|
| | 84 | exit; |
|---|
| | 85 | } elsif ($opt_t and $opt_d) { |
|---|
| | 86 | $self->{"tarFile"} = $opt_t; |
|---|
| | 87 | $self->{"tarFilePath"} = $opt_d; |
|---|
| | 88 | $self->processSingleTar(); |
|---|
| | 89 | } elsif ($opt_g and $opt_d) { |
|---|
| | 90 | $self->{"tarFile"} = undef; |
|---|
| | 91 | $self->{"tarFilePath"} = $opt_d; |
|---|
| | 92 | $self->processDirOfTars(); |
|---|
| | 93 | } else { |
|---|
| | 94 | print "\nVoxForge Manual WebGUIForum Update\n"; |
|---|
| | 95 | print "==================================\n"; |
|---|
| | 96 | print "Use -h parameter for more information\n\n"; |
|---|
| | 97 | print "--\n"; |
|---|
| | 98 | print "Free Speech... Recognition\n"; |
|---|
| | 99 | print "http://www.voxforge.org\n\n"; |
|---|
| | 100 | exit; |
|---|
| | 101 | } |
|---|
| | 102 | } |
|---|
| | 103 | |
|---|
| | 104 | =head2 processSingleTar |
|---|
| | 105 | |
|---|
| | 106 | =cut |
|---|
| | 107 | |
|---|
| | 108 | sub processSingleTar { |
|---|
| | 109 | my ($self)= @_; |
|---|
| 69 | | my $languages = $self->{"languages"}; |
|---|
| 70 | | my %ProcessedUserSubmissions; |
|---|
| | 112 | my $parms = $self->{'parms'}; |
|---|
| | 113 | my $ProcessedUserSubmissions = $self->{"processedUserSubmissions"}; |
|---|
| | 114 | |
|---|
| | 115 | my ($filename,$path,$suffix) = fileparse($tarFile,@suffixlist); |
|---|
| | 116 | if (grep /$suffix/, @suffixlist) { |
|---|
| | 117 | my $newTarfileName = $self->renameTarfile($tarFilePath,$tarFile); |
|---|
| | 118 | my $tarfileDirName = $self->extractTarFile($tarFilePath,$newTarfileName); |
|---|
| | 119 | my $readme = $self->getReadmeWithPath($tarFilePath,$tarfileDirName); |
|---|
| | 120 | $ProcessedUserSubmissions->{$tarfileDirName}= { |
|---|
| | 121 | "path_original" => "$tarFilePath", |
|---|
| | 122 | "readme" => $readme, |
|---|
| | 123 | "tarfile" => $newTarfileName, |
|---|
| | 124 | } |
|---|
| | 125 | } |
|---|
| | 126 | $self->Update('speechsubmission', 'n@wp@$$') || confess "error: $?"; |
|---|
| | 127 | return 1; |
|---|
| | 128 | } |
|---|
| | 129 | |
|---|
| | 130 | =head2 processDirOfTars |
|---|
| | 131 | |
|---|
| | 132 | =cut |
|---|
| | 133 | |
|---|
| | 134 | sub processDirOfTars { |
|---|
| | 135 | my ($self)= @_; |
|---|
| | 136 | my $tarFilePath = $self->{"tarFilePath"}; |
|---|
| | 137 | my $tarFile = $self->{"tarFile"}; |
|---|
| | 138 | my $parms = $self->{'parms'}; |
|---|
| | 139 | my $ProcessedUserSubmissions = $self->{"processedUserSubmissions"}; |
|---|
| | 140 | |
|---|
| | 141 | opendir(DIR, $tarFilePath) || confess ("Unable to open file: $tarFilePath"); |
|---|
| | 142 | while (my $line = readdir(DIR)) { |
|---|
| | 143 | chomp ($line); |
|---|
| | 144 | if ($line ne "." and $line ne ".." ) { |
|---|
| | 145 | my ($filename,$path,$suffix) = fileparse($line,@suffixlist); |
|---|
| | 146 | if (grep /$suffix/, @suffixlist) { |
|---|
| | 147 | my $newTarfileName = $self->renameTarfile($tarFilePath,$line); |
|---|
| | 148 | my $tarfileDirName = $self->extractTarFile($tarFilePath,$newTarfileName); |
|---|
| | 149 | my $readme = $self->getReadmeWithPath($tarFilePath,$tarfileDirName); |
|---|
| | 150 | $ProcessedUserSubmissions->{$tarfileDirName}= { |
|---|
| | 151 | "path_original" => "$tarFilePath", |
|---|
| | 152 | "readme" => $readme, |
|---|
| | 153 | "tarfile" => $newTarfileName, |
|---|
| | 154 | } |
|---|
| | 155 | } |
|---|
| | 156 | } |
|---|
| | 157 | } |
|---|
| | 158 | $self->Update('speechsubmission', 'n@wp@$$') || confess "error: $?"; |
|---|
| | 159 | return 1; |
|---|
| | 160 | } |
|---|
| | 161 | |
|---|
| | 162 | =head2 getReadmeWithPath |
|---|
| | 163 | |
|---|
| | 164 | =cut |
|---|
| | 165 | |
|---|
| | 166 | sub getReadmeWithPath { |
|---|
| | 167 | my ($self,$tarFilePath,$tarfileDirName)= @_; |
|---|
| | 168 | my $parms = $self->{'parms'}; |
|---|
| | 169 | my $readmeWithPath = UserSubmission::README->getFileWithPath($parms,"$tarFilePath/$tarfileDirName"); |
|---|
| | 170 | $command = ("dos2unix -c Mac $readmeWithPath"); print "$command\n"; system($command) == 0 or confess "getReadmeWithPath $command failed: $?"; |
|---|
| | 171 | $command = ("dos2unix $readmeWithPath"); print "$command\n"; system($command) == 0 or confess "getReadmeWithPath $command failed: $?"; |
|---|
| | 172 | return UserSubmission::README->new($parms,$readmeWithPath,$tarfileDirName); |
|---|
| | 173 | } |
|---|
| | 174 | |
|---|
| | 175 | =head2 renameTarfile |
|---|
| | 176 | |
|---|
| | 177 | =cut |
|---|
| | 178 | |
|---|
| | 179 | sub renameTarfile { |
|---|
| | 180 | my ($self,$tarFilePath,$tarFile)= @_; |
|---|
| | 181 | my $languages = $self->{"languages"}; |
|---|
| 87 | | |
|---|
| 88 | | my $readmeWithPath = UserSubmission::README->getFileWithPath($parms,"$tarFilePath/$AudioDirName"); |
|---|
| 89 | | print "!!!!!!readmeWithPath:$readmeWithPath\n"; |
|---|
| 90 | | my $readme = UserSubmission::README->new($parms, "$readmeWithPath"); |
|---|
| 91 | | |
|---|
| 92 | | $ProcessedUserSubmissions{$AudioDirName}= { |
|---|
| 93 | | "path_original" => $tarFilePath, |
|---|
| 94 | | "readme" => $readme |
|---|
| 95 | | }; |
|---|
| 96 | | |
|---|
| 97 | | if ($languages->{$readme->getLanguage()}[1]) { |
|---|
| 98 | | if ((-e "$tarFilePath/$newTarFileName") and (-e "$tarFilePath/$AudioDirName")) { |
|---|
| 99 | | print "Main: path to tar file: $tarFilePath/$newTarFileName\n"; |
|---|
| 100 | | print "Main: path to Audio Directory: $tarFilePath/$AudioDirName\n"; |
|---|
| 101 | | Update($parms, \%ProcessedUserSubmissions, 'speechsubmission', 'password') || confess "error: $?"; |
|---|
| 102 | | } else { |
|---|
| 103 | | confess "Zip/Tar file: $tarFilePath/$newTarFileName does not exist\n"; |
|---|
| 104 | | } |
|---|
| 105 | | } else { |
|---|
| 106 | | Update($parms, \%ProcessedUserSubmissions, 'speechsubmission', 'password') || confess "error: $?"; |
|---|
| 107 | | } |
|---|
| 108 | | } |
|---|
| 109 | | |
|---|
| 110 | | #################################################################### |
|---|
| 111 | | ### Overrides |
|---|
| 112 | | #################################################################### |
|---|
| | 206 | return $AudioDirName; |
|---|
| | 207 | } |
|---|
| | 208 | |
|---|
| | 209 | =head2 Update |
|---|
| | 210 | |
|---|
| | 211 | Overrides UserSubmission method |
|---|
| | 212 | |
|---|
| | 213 | =cut |
|---|
| | 214 | |
|---|
| 125 | | my $path_original = $$ProcessedUserSubmissions{$AudioDirName}{"path_original"}; |
|---|
| 126 | | my $readme = $$ProcessedUserSubmissions{$AudioDirName}{"readme"}; |
|---|
| 127 | | print STDERR "Update Forum with AudioDirName:$path_original/$AudioDirName\n" if $debug; |
|---|
| 128 | | #my ($content,$title)= WebGUIForum::getSubmissionContents($parms,$readmepath,$promptspath,$licensepath,$AudioDirName, $readme,$tarfile); |
|---|
| 129 | | my ($content,$title)= WebGUIForum::getSubmissionContents($parms,$path_original,$AudioDirName,$readme,$tarfile); |
|---|
| 130 | | WebGUIForum::Upload($parms,$browser,$content,$title,$readme,$pathtoTarfile); |
|---|
| 131 | | } |
|---|
| 132 | | print "\nWebGUIForumUpdate.pm completed!\n****************************************************\n\n"; |
|---|
| 133 | | } |
|---|
| 134 | | |
|---|
| 135 | | =head2 getOptions |
|---|
| 136 | | |
|---|
| 137 | | Get the user submitted options ('a:b:d:hil:m:p:r:s:t:u:x:q:vwST') |
|---|
| 138 | | |
|---|
| 139 | | =cut |
|---|
| 140 | | |
|---|
| 141 | | sub getOptions { |
|---|
| 142 | | my ($self)= @_; |
|---|
| 143 | | my $debug = $self->{'debug'}; |
|---|
| 144 | | getopts('t:d:hg'); # sets $opt_* as a side effect. |
|---|
| 145 | | if ($opt_h) { |
|---|
| 146 | | print "\nVoxForge Manual WebGUIForum Update Parameters\n"; |
|---|
| 147 | | print "=============================================\n"; |
|---|
| 148 | | print "-d\t directory containing tar file or set of tar files to be uploaded to WebGUI\n"; |
|---|
| 149 | | print "-g\t group of tar files contained in directory (-d)\n"; |
|---|
| 150 | | print "-h\t help\n"; |
|---|
| 151 | | print "-t\t tar file name (no path; use \"-d\")\n"; |
|---|
| 152 | | print "--\n"; |
|---|
| 153 | | print "Free Speech... Recognition\n"; |
|---|
| 154 | | print "http://www.voxforge.org\n\n"; |
|---|
| 155 | | exit; |
|---|
| 156 | | } elsif ($opt_t) { |
|---|
| 157 | | |
|---|
| 158 | | |
|---|
| 159 | | } else { |
|---|
| 160 | | print "\nVoxForge Manual WebGUIForum Update Parameters\n"; |
|---|
| 161 | | print "==================================\n"; |
|---|
| 162 | | print "Use -h parameter for more information\n\n"; |
|---|
| 163 | | print "--\n"; |
|---|
| 164 | | print "Free Speech... Recognition\n"; |
|---|
| 165 | | print "http://www.voxforge.org\n\n"; |
|---|
| 166 | | exit; |
|---|
| 167 | | } |
|---|
| 168 | | } |
|---|
| 169 | | |
|---|
| 170 | | |
|---|
| | 230 | my $path_original = $ProcessedUserSubmissions->{$AudioDirName}{"path_original"}; |
|---|
| | 231 | my $readme = $ProcessedUserSubmissions->{$AudioDirName}{"readme"}; |
|---|
| | 232 | #print "!!!!!!!readme$readme\n"; |
|---|
| | 233 | my $tarfile = $ProcessedUserSubmissions->{$AudioDirName}{"tarfile"}; |
|---|
| | 234 | #my $readmeLanguage = $readme->getLanguage(); |
|---|
| | 235 | #print "!!!!!!!readmeLanguage:$readmeLanguage:\n"; |
|---|
| | 236 | #print "!!!!!!!languagesSupportedInSVN:" . $languages->{$readmeLanguage}[0] . $languages->{$readmeLanguage}[1] . "\n"; |
|---|
| | 237 | #print "!!!!!!!languagesSupportedInSVN:" . $languages->{'EN'}[0] . $languages->{'EN'}[1] . "\n"; |
|---|
| | 238 | print STDERR "Update Forum with AudioDirName:$path_original/$AudioDirName\n" if $debug; |
|---|
| | 239 | if ($languages->{$readme->getLanguage()}[1] eq 'yes') { # check for switch telling you that language is supported in svn (then only need to link to audio tar file on voxforge repository) |
|---|
| | 240 | my $tarFileWithPath = undef; # if this is undef, then WebGUIForum script will add link to VoxForge repository in body of post to forum |
|---|
| | 241 | my ($content,$title)= WebGUIForum::getSubmissionContents($parms,$path_original,$AudioDirName,$readme,$tarFileWithPath); |
|---|
| | 242 | WebGUIForum::Upload($parms,$browser,$content,$title,$readme,$tarFileWithPath); |
|---|
| | 243 | } elsif ($languages->{$readme->getLanguage()}[1] eq 'no') { |
|---|
| | 244 | my $tarFileWithPath = "$path_original/$tarfile"; # if this points to a tar file, then WebGUIForum script will upload tar file as part of the post to forum |
|---|
| | 245 | my ($content,$title)= WebGUIForum::getSubmissionContents($parms,$path_original,$AudioDirName,$readme,$tarFileWithPath); |
|---|
| | 246 | WebGUIForum::Upload($parms,$browser,$content,$title,$readme,$tarFileWithPath); |
|---|
| | 247 | } else { |
|---|
| | 248 | confess "Error: language:" . $readme->getLanguage() .": not defined\n"; |
|---|
| | 249 | } |
|---|
| | 250 | } |
|---|
| | 251 | return 1; |
|---|
| | 252 | } |
|---|
| | 253 | |
|---|