voxforge.org
VoxForge Dev

Changeset 2388

Show
Ignore:
Timestamp:
01/07/08 00:20:39 (11 months ago)
Author:
kmaclean
Message:

snapshot - automated submission of SpeechSubmission zip file to WebGUI Forum

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/Scripts/Mirroring_scripts/WebGUIForumUpdate.pm

    r2386 r2388  
    3232#################################################################### 
    3333my $LoginURL ='http://www.scout.org'; 
    34 my $UploadURL ='http://www.scout.org/home/downloads/audio/model-repository/audio-speech-files'; 
    35 my $RepositoryURL ='http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original'; 
    3634my $command; 
    3735#################################################################### 
     
    4038sub Main { 
    4139        my ($parms,%ProcessedUserSubmissions) = @_; 
    42                 my $debug = $$parms{"debug"};            
     40                my $debug = $$parms{"debug"}; 
     41                 
     42        my $counter; 
     43                                 
    4344        Login($parms);   
    4445        foreach my $AudioDirName (keys %ProcessedUserSubmissions) { 
     46                $counter++; 
     47                print  "$counter. $AudioDirName ==============================================\n"; 
    4548                my $path_original = $ProcessedUserSubmissions{$AudioDirName}; 
    4649                print STDERR "Update Forum with AudioDirName:$path_original/$AudioDirName\n" if $debug; 
    47                 my ($content,$title)= getContentsofZipFile($parms,$path_original, $AudioDirName); 
    48                 Upload($parms,$content,$title); 
     50                my ($content,$title,$language,$AudioRecordingSoftware)= getContentsofZipFile($parms,$path_original, $AudioDirName); 
     51                if ($AudioRecordingSoftware =~ /VoxForge Speech Submission Application/) { 
     52                        Upload($parms,$content,$title,$language); 
     53                } 
     54 
    4955        } 
    5056        $command = ("rm my_cookies.txt"); print "$command\n" if $debug;system($command) == 0 or die "system $command failed: $?";   
     
    5460###  Subroutines                                                            
    5561#################################################################### 
     62sub getUploadURL { 
     63        my ($parms,$language) = @_; 
     64                my $debug = $$parms{"debug"}; 
     65                my $UploadURL; 
     66         
     67        if ($$language =~ /EN/) { 
     68                $UploadURL ='http://www.scout.org/home/downloads/audio/model-repository/audio-speech-files'; 
     69        } elsif ($$language =~ /NL/) { 
     70                $UploadURL ='http://www.scout.org/home/downloads/speech/dutch'; 
     71        } else { 
     72                $UploadURL ='http://www.scout.org/home/downloads/audio/model-repository/audio-speech-files';     
     73        } 
     74        return $UploadURL;       
     75} 
     76 
    5677sub getContentsofZipFile() { 
    5778        my ($parms,$path_original, $AudioDirName) = @_; 
    5879                my $debug = $$parms{"debug"}; 
    5980 
    60         my ($content, @readme, @prompts, @license); 
     81        my ($content, @readme, @prompts, @license,$AudioRecordingSoftware,$language,$RepositoryURL); 
    6182        my $title=$AudioDirName; 
    6283        print STDERR "Extracting :$path_original/$AudioDirName\n" if $debug;   
     
    6485        if ( $ae->extract( to => "$AudioDirName-temp" ) ) { 
    6586                open(README, "<$AudioDirName-temp/readme.txt") or confess ("can't find readme.txt");  
    66                 @readme = <README>;         
     87                @readme = <README>;      
     88                foreach my $line (@readme) { 
     89                        if ($line =~ /Language: /) { 
     90                                $language = $line; 
     91                                $language =~ s/Language: //; 
     92                        } elsif ($line =~ /Audio Recording Software: /) { 
     93                                $AudioRecordingSoftware = $line; 
     94                                $AudioRecordingSoftware =~ s/Audio Recording Software: //; 
     95                        } 
     96                } 
     97                $RepositoryURL = getRepositoryURL($parms,$language); 
    6798                open(PROMPTS, "<$AudioDirName-temp/prompts.txt") or confess ("can't find prompts.txt");  
    6899                @prompts = <PROMPTS>;    
     
    79110        $content .= join(" ",  @license); 
    80111        $content =~ s/\n/<br>\n/g;       
    81         $content =~ s/WARRANTY;/WARRANTY,/; # WebGUI does not like CAPITALS followed by semi-colons ...? 
     112        $content =~ s/WARRANTY;/WARRANTY,/; # WebGUI does not like CAPITAL LETTERS followed by a semi-colon ...? 
    82113        $content =~ s|<http://www.gnu.org/licenses/>|http://www.gnu.org/licenses/|;  # more WebGUI arcana 
    83114        $content .= "<br><img src=\"http://www.repository.voxforge1.org/spicons/compressed.gif\">"; 
    84         $content .= "<a href=\"$RepositoryURL/48kHz_16bit/$title.tgz\">$title.tgz</a><br>"; 
    85 #       $content = join(" ", 
    86 #               @readme,  
    87 #               "<h2>Prompts:</h2>", @prompts, 
    88 #               "<h2>License:</h2>", @license, 
    89 #               "<br> <img src=\"http://www.repository.voxforge1.org/spicons/compressed.gif\" alt=\"[   ]\" border=\"0\">", 
    90 #               "<a href=\"http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original/48kHz_16bit/$title.tgz\">$title.tgz</a><br>" 
    91 #               ); 
    92  
    93         print $content; 
    94         return (\$content,\$title); 
     115        $content .= "<a href=\"$RepositoryURL/$title.tgz\">$title.tgz</a><br>"; 
     116        return (\$content,\$title,\$language,$AudioRecordingSoftware); 
     117
     118 
     119sub getRepositoryURL { 
     120        my ($parms,$language) = @_; 
     121                my $debug = $$parms{"debug"}; 
     122                 
     123        my $RepositoryURL; 
     124         
     125        if ($language =~ /EN/) { 
     126                $RepositoryURL ='http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original/48kHz_16bit'; 
     127        } elsif ($language =~ /NL/) { 
     128                $RepositoryURL = "WARNING: Dutch submissions not set up yet in Repository yet!\n"; 
     129                print "WARNING: Dutch submissions not set up yet in Repository yet!\n"; 
     130        } else { 
     131                $RepositoryURL ='http://www.repository.voxforge1.org/downloads/SpeechCorpus/Trunk/Audio/Original/48kHz_16bit'; 
     132        } 
     133        return $RepositoryURL; 
    95134} 
    96135 
     
    129168                # print  "\n\nresult:\n$result\n"; 
    130169        } 
    131         print  "==============================================\n"; 
    132170} 
    133171 
     
    143181 
    144182sub Upload { 
    145         my ($parms,$content,$title) = @_; 
     183        my ($parms,$content,$title,$language) = @_; 
    146184                my $debug = $$parms{"debug"}; 
    147185                         
    148186        my ($result, $err); 
    149187        my $post = "func=editSave;assetId=new;class=WebGUI::Asset::Post::Thread;proceed=showConfirmation;title=$$title;content=$$content;contentType=text,subscribe=1;submit=save"; 
     188        my $UploadURL = getUploadURL($parms,$language); 
    150189         
    151190        my $curl = new WWW::Curl::Easy; 
     
    175214                print  "info: $curl->getinfo(CURLINFO_HTTP_CODE\n"; 
    176215        } 
     216 
    177217} 
    178218