voxforge.org
VoxForge Dev

Changeset 2326

Show
Ignore:
Timestamp:
10/08/07 22:00:57 (11 months ago)
Author:
kmaclean
Message:

snapshot - speech submission app and upload working on windows/linux

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/SpeechSubmission/VFSpeechSubmission/java/src/speechrecorder/CapturePlayback.java

    r2319 r2326  
    317317 
    318318    int compressionMode = 2; // Simple compression 1 (loqual) 2 (med) 3 (hiqual) 
     319     
     320        String tempdir = getTempDir(); 
    319321// !!!!!! 
    320322//    public CapturePlayback(String subject,  String fileFieldName, 
     
    390392                        wavFile.deleteOnExit(); 
    391393// !!!!!! 
    392  
    393                         File dir=File.createTempFile("VF-dir",null); 
    394                         dir.delete(); 
    395                         dir.mkdir(); 
    396                         String tempdir = dir.toString(); 
    397                         if ( !(tempdir.endsWith("/") || tempdir.endsWith("\\")) ) 
    398                                    tempdir = tempdir + System.getProperty("file.separator");     
    399                          
    400394                        wavFile1 = new File(tempdir + "wavFile1.wav"); 
    401395                        wavFile1.deleteOnExit(); 
     
    757751         JPanel DisclaimerInnerPanel = new JPanel();  
    758752         String DisclaimerText =  
    759                  "<html><br>VoxForge SpeechSubmission Applet - Copyright (C) 2007 VoxForge<br>" 
     753                 "<html>VoxForge SpeechSubmission Applet - Copyright (C) 2007 VoxForge<br>" 
    760754                 +"This program comes with ABSOLUTELY NO WARRANTY; without even the implied<br> " 
    761755                 +"warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  For<br>"  
    762756                 +"details click the \"About\" button:"; 
    763          DisclaimerPanel.add(new JLabel(DisclaimerText)); 
     757         DisclaimerInnerPanel.add(new JLabel(DisclaimerText)); 
    764758         aboutB = addButton("About", DisclaimerInnerPanel, true);  
    765         
    766           
    767 //         DisclaimerInnerPanel.setBorder(BorderFactory.createLineBorder (voxforgeColour, 3)); 
    768 //         DisclaimerInnerPanel.add(new JLabel(DisclaimerText)); 
     759         DisclaimerInnerPanel.setBorder(BorderFactory.createLineBorder (voxforgeColour, 3)); 
     760  
    769761         DisclaimerPanel.add(DisclaimerInnerPanel);         
    770762        p2.add(DisclaimerPanel);  
     
    775767    public void open() { } 
    776768 
     769    private String getTempDir() { 
     770        String tempdir=null; 
     771                try { 
     772                File dir=File.createTempFile("VF-dir",null); 
     773                dir.delete(); 
     774                dir.mkdir(); 
     775                tempdir = dir.toString(); 
     776                if ( !(tempdir.endsWith("/") || tempdir.endsWith("\\")) ) 
     777                           tempdir = tempdir + System.getProperty("file.separator"); 
     778 
     779                } catch (Exception e) { 
     780                        System.err.println("Unable to create temp directory\n" + e); 
     781                } 
     782                return tempdir; 
     783    } 
    777784 
    778785    public void close() { 
     
    815822     
    816823    private void setButtonsOff() { 
    817         System.err.println("setButtonsOff" ); 
     824        // debug System.err.println("setButtonsOff" ); 
    818825        play1.setEnabled(false);  
    819826        capt1.setEnabled(false);  
     
    839846     
    840847    private void saveButtonState() { 
    841         System.err.println("saveButtonState" ); 
     848        // debug System.err.println("saveButtonState" ); 
    842849        if (play1.isEnabled()) {play1_state = true;} else {play1_state = false;} 
    843850        if (play2.isEnabled()) {play2_state = true;} else {play2_state = false;}   
     
    863870     
    864871    private void restoreButtonState() { 
    865         System.err.println("restoreButtonState" ); 
     872        // debug System.err.println("restoreButtonState" ); 
    866873        if (play1_state) {play1.setEnabled(true);} else {play1.setEnabled(false);} 
    867874        if (play2_state) {play2.setEnabled(true);} else {play2.setEnabled(false);} 
     
    15321539  
    15331540           JOptionPane.showMessageDialog(this, areaScrollPane,  
    1534                    "More info on Copyright and GPL license", JOptionPane.PLAIN_MESSAGE); 
     1541                   "About VoxForge Speech Submission Application", JOptionPane.PLAIN_MESSAGE); 
    15351542       } 
    15361543    } 
     
    19251932                        } 
    19261933 
    1927                         System.err.println("thread==null, recording thread about to tidy up"); 
     1934                        // debug System.err.println("thread==null, recording thread about to tidy up"); 
    19281935 
    19291936            // we reached the end of the stream.  stop and close the line. 
     
    19521959            } catch (Exception ex) { reportStatus(ex.toString()); } 
    19531960            // !!!!!! 
    1954                       System.err.println("About to load bytes to byte array"); 
     1961                // debug      System.err.println("About to load bytes to byte array"); 
    19551962                byte audioBytes[] = outbaos.toByteArray(); 
    19561963        //      System.err.println("Loaded bytes to byte array"); 
     
    19631970                 duration = totalBytesWritten / (double) (format.getSampleRate() * format.getSampleSizeInBits()/ 8); 
    19641971            // !!!!!! 
    1965                       System.err.println("Calculated duration"); 
     1972                // debug      System.err.println("Calculated duration"); 
    19661973// !!!!!! 
    19671974//            samplingGraph.createWaveForm(audioInputStream); 
    19681975            samplingGraph.createWaveForm(audioBytes); 
    19691976// !!!!!! 
    1970             System.err.println("Created samplingGraph"); 
     1977            // debug System.err.println("Created samplingGraph"); 
    19711978 
    19721979            // This is the only way to "reset" long streams - re-grab 
     
    19921999                } 
    19932000         
    1994                 System.err.println("About to grab audio input stream from cache file"); 
     2001                // debug System.err.println("About to grab audio input stream from cache file"); 
    19952002                try { 
    19962003                        //              audioInputStream = AudioSystem.getAudioInputStream(wavFile); 
     
    20042011                        System.err.println("Exception while reading cache file: " + err); 
    20052012                } 
    2006                 System.err.println("Grabbed audio input stream from cache file"); 
     2013                // debug System.err.println("Grabbed audio input stream from cache file"); 
    20072014        } 
    20082015 
     
    21242131//            totalBytes = ((int)spxFile.length()); 
    21252132            progBar.setMaximum((int)wavFile.length()); 
    2126             totalBytes = ((int)wavFile.length());             
     2133 //           totalBytes = ((int)wavFile.length());             
    21272134// !!!!!!             
    21282135            progBar.setMinimum(0); 
     
    21672174files[9] = uploadWavFile9; 
    21682175files[10] = uploadWavFile10; 
     2176 
    21692177//############ prompt files ####################################  
    21702178try { 
     
    22762284} 
    22772285 
    2278  
    22792286if (userName != null){ 
    2280         archiveFile = new File(userName + "-" + date + "-" + randomID + ".zip"); 
     2287        archiveFile = new File(tempdir + userName + "-" + date + "-" + randomID + ".zip"); 
    22812288} else { 
    2282         archiveFile = new File("Anonymous-" + date + "-" + randomID + ".zip"); 
     2289        archiveFile = new File(tempdir +"Anonymous-" + date + "-" + randomID + ".zip"); 
    22832290} 
    22842291 
    22852292createZipArchive(archiveFile, files); 
    22862293System.err.println("Archive file location:" + archiveFile); 
    2287 System.err.println("username:" + userName + ":"); 
     2294// debug System.err.println("username:" + userName + ":"); 
     2295//!!!!!! 
     2296totalBytes = ((int)archiveFile.length()) ;  
     2297// !!!!!! 
    22882298//############ Upload ####################################  
    22892299 
     
    25602570 
    25612571                    // .. draw current position .. 
    2562                     System.err.println("seconds "+seconds+";duration:"+duration+":"); 
     2572// debug            System.err.println("seconds "+seconds+";duration:"+duration+":"); 
    25632573                    if (seconds != 0) { 
    25642574                        double loc = seconds/duration*w; 
     
    25932603 
    25942604                    seconds =  milliseconds / 1000.0; 
    2595                     System.err.println("playback.line:seconds "+seconds+";milliseconds:"+milliseconds+":"); 
     2605    // debug        System.err.println("playback.line:seconds "+seconds+";milliseconds:"+milliseconds+":"); 
    25962606                } else if ( (capture.line != null) && (capture.line.isActive()) ) { 
    25972607 
    25982608                    long milliseconds = (long)(capture.line.getMicrosecondPosition() / 1000); 
    25992609                    seconds =  milliseconds / 1000.0; 
    2600                     System.err.println("capture.line:seconds "+seconds+";milliseconds:"+milliseconds+":"); 
     2610    // debug        System.err.println("capture.line:seconds "+seconds+";milliseconds:"+milliseconds+":"); 
    26012611 
    26022612                } 
     
    26262636            //DEL progCompletion.setText(pLabels.getLabel(2)); 
    26272637            if (endPageURL != null){ 
     2638                progBar.setString("Upload completed... Thank you for your submission!"); 
     2639                progBar.setIndeterminate(false); 
    26282640                System.err.println("Finished! Sending you on to "+endPageURL); 
    26292641                ((JApplet)(getParent().getParent().getParent().getParent())).getAppletContext().showDocument(endPageURL); 
     
    26332645                // Attempt at calling Javascript after upload is complete. 
    26342646//FORDEBUG 
    2635            System.err.println("setProgress(): endPageURL is null, so trying to use the javascript hook to end."); 
     2647                System.err.println("setProgress(): endPageURL is null, so trying to use the javascript hook to end."); 
    26362648                JSObject win = (JSObject) JSObject.getWindow((JApplet)getParent()); 
    26372649                win.eval("postletFinished();"); 
     
    26442656        } else { 
    26452657//FORDEBUG 
    2646 //           System.err.println("setProgress(): Not reached end yet. sentBytes="+sentBytes+", totalBytes="+totalBytes); 
     2658           System.err.println("setProgress(): Not reached end yet. sentBytes="+sentBytes+", totalBytes="+totalBytes); 
    26472659        } 
    26482660     } 
  • Trunk/SpeechSubmission/VFSpeechSubmission/java/src/speechrecorder/License.java

    r2322 r2326  
    4848                 
    4949                VFlicenseNotice =   
    50                   "VoxForge SpeechSubmission Application - allows a user to record their speech and  " + System.getProperty("line.separator") 
     50                  "VoxForge Speech Submission Application v0.1 - allows a user to record their speech and  " + System.getProperty("line.separator") 
    5151                + " upload the recorded audio to the VoxForge server, so that it can be" + System.getProperty("line.separator")  
    5252                + "incorporated into the VoxForge Speech Corpus and used in the creation of " + System.getProperty("line.separator")  
  • Trunk/SpeechSubmission/VFSpeechSubmission/java/src/speechrecorder/RecorderApplet.java

    r2317 r2326  
    213213         
    214214        /*  HELPPAGE  */ 
    215         try { 
    216             helpPageURL = new URL(getParameter("helppage")); 
    217         } catch(java.net.MalformedURLException malurlex){ 
    218             errorMessage(System.out, "helppage is badly formed:###"+getParameter("helppage")+"###"); 
    219         } catch(java.lang.NullPointerException npe){ 
    220             errorMessage(System.out, "helppage is null"); 
    221         } 
     215 //       try { 
     216 //           helpPageURL = new URL(getParameter("helppage")); 
     217  //      } catch(java.net.MalformedURLException malurlex){ 
     218  //          errorMessage(System.out, "helppage is badly formed:###"+getParameter("helppage")+"###"); 
     219  //      } catch(java.lang.NullPointerException npe){ 
     220  //          errorMessage(System.out, "helppage is null"); 
     221  //      } 
    222222    } 
    223223 
  • Trunk/SpeechSubmission/VFSpeechSubmission/java/src/speechrecorder/copyrights

    • Property svn:ignore set to
      prompts.temp
  • Trunk/SpeechSubmission/VFSpeechSubmission/server/SubmitSpeechServer.php

    r2325 r2326  
    1616  $cookie = htmlspecialchars($_SERVER['HTTP_COOKIE']); 
    1717  $code =  <<<ENDHTMLFRAGMENT 
    18 <applet name="VoxForge.org Speech Submission Application" width ="800" height ="850" mayscript="mayscript" 
     18<applet name="VoxForge.org Speech Submission Application" width ="825" height ="875" mayscript="mayscript" 
    1919      code="speechrecorder/RecorderApplet.class" style="border: 1px solid rgb(153,153,153);"> 
    2020 <param name="codebase"  value="$codebase"/> 
  • Trunk/SpeechSubmission/VFSpeechSubmission/server/index.php

    r2325 r2326  
    88        } 
    99        .copyright { 
    10                 test-align: left; 
     10                text-align: left; 
    1111                color: #2E3436; 
    1212                font-family: sans-serif; 
     
    155155<p>After each recording, the black box near the bottom of your screen will display the audio waveform corresponding to the currently active recording.  Please avoid recording clipped speech (i.e. recording with the  volume to high).  The grey bar below the upload button will display a warning if your recording volume is too loud.</p> 
    156156<p>Once you have completed recording all ten prompts the <b>Upload</b> button will activate.  Click the <b>Upload</b> button to upload your entire submission to the VoxForge repository as a single zip file.</p> 
    157 <p>Thank you for helping Free and Open Source Speech Recogntion!</p> 
     157<p>Thank you for helping Free and Open Source Speech Recognition!</p> 
    158158</br> 
    159159<?php 
     
    161161 
    162162echo speex_postlet_applet( 
    163 'http://www.repository.voxforge1.org/SubmitSpeech/javaUploadServer.php',  
    164 'http://www.repository.voxforge1.org/SubmitSpeech/endpage.php', 
    165 'http://www.repository.voxforge1.org/SubmitSpeech
     163'http://read.voxforge1.org/javaUploadServer.php',  
     164'http://read.voxforge1.org/endpage.php', 
     165'http://read.voxforge1.org
    166166     ); 
    167167 
  • Trunk/SpeechSubmission/VFSpeechSubmission/server/javaUpload.php

    r2290 r2326  
    2424// or "c:\php\uploads\" 
    2525// Note, this MUST have the trailing slash. 
    26 $uploaddir = '/home/kmaclean/httpd/audiosubmissions/'; 
     26//$uploaddir = 'public/'; 
     27$uploaddir = '../public/speechsubmissions/'; 
    2728// Whether or not to allow the upload of specific files 
    28 $allow_or_deny = false; 
     29$allow_or_deny = true; 
    2930// If the above is true, then this states whether the array of files is a list of 
    3031// extensions to ALLOW, or DENY