voxforge.org
VoxForge Dev

Changeset 2363

Show
Ignore:
Timestamp:
11/28/07 00:09:04 (1 year ago)
Author:
kmaclean
Message:

SpeechSubmission snapshot

Files:

Legend:

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

    r2360 r2363  
    215215    String promptID9; 
    216216    String promptID10;   
     217     
     218    String fileFieldName; 
    217219//  ############ Localized Fields ####################################    
    218220    JTextField usernameTextField;   
    219     LabelLocalizer labels = new LabelLocalizer("Dutch"); 
    220 //   LabelLocalizer labels = new LabelLocalizer("English"); 
    221     String usernamePanelLabel = labels.usernamePanelLabel; 
     221    String usernamePanelLabel; 
    222222    String userName; 
    223     String usernamePanelText = labels.usernamePanelText
    224      
    225     String copyrightName = labels.copyrightName
    226     String gplAccepted = labels.gplAccepted
    227      
    228     String pleaseSelect = labels.pleaseSelect
    229     String notApplicable = labels.notApplicable
    230      
    231     String genderPanelLabel = labels.genderPanelLabel
     223    String usernamePanelText
     224     
     225    String copyrightName
     226    String gplAccepted
     227     
     228    String pleaseSelect
     229    String notApplicable
     230     
     231    String genderPanelLabel
    232232    JComboBox genderChooser;        
    233     String[] genderSelection = labels.genderSelection
    234     String gender = notApplicable
    235      
    236     String ageRangePanelLabel = labels.ageRangePanelLabel
     233    String[] genderSelection
     234    String gender
     235     
     236    String ageRangePanelLabel
    237237    JComboBox ageRangeChooser;  
    238     String[] ageSelection = labels.ageSelection
    239     String ageRange = notApplicable
    240  
    241     String dialectPanelLabel = labels.dialectPanelLabel
     238    String[] ageSelection
     239    String ageRange
     240 
     241    String dialectPanelLabel
    242242    JComboBox dialectChooser; 
    243     String dialect = notApplicable;  // default selection 
    244     String[] dialectSelection = labels.dialectSelection; 
    245  
    246     String microphonePanelLabel = labels.microphonePanelLabel
     243    String[] dialectSelection; 
     244    String dialect;   
     245     
     246    String microphonePanelLabel
    247247    JComboBox microphoneChooser;      
    248     String[] microphoneSelection = labels.microphoneSelection; 
    249     String microphone = notApplicable;   
    250      
    251     String uploadText = labels.uploadText; 
    252     String uploadButtonLabel = labels.uploadButtonLabel; 
    253      
    254     String moreInfoText = labels.moreInfoText; 
    255     String moreInfoButtonLabel = labels.moreInfoButtonLabel;     
    256  
    257     String disclaimerText = labels.disclaimerText; 
    258     String aboutButtonLabel = labels.aboutButtonLabel; 
    259      
    260     String recordButton = labels.recordButton;  
    261     String stopButton = labels.stopButton;  
    262     String playButton = labels.playButton;  
    263      
    264     String peakWarningLabel = labels.peakWarningLabel;  
    265     String sampleGraphFileLabel = labels.sampleGraphFileLabel;  
    266     String sampleGraphLengthLabel = labels.sampleGraphLengthLabel;  
    267     String sampleGraphPositionLabel = labels.sampleGraphPositionLabel;  
    268 //  ############ Localized Fields ####################################       
    269     String fileFieldName; 
    270      
     248    String[] microphoneSelection; 
     249    String microphone;   
     250     
     251    String uploadText; 
     252    String uploadButtonLabel; 
     253     
     254    String moreInfoText; 
     255    String moreInfoButtonLabel;     
     256 
     257    String disclaimerText; 
     258    String aboutButtonLabel; 
     259     
     260    String recordButton;  
     261    String stopButton;  
     262    String playButton;  
     263     
     264    String peakWarningLabel;  
     265    String sampleGraphFileLabel;  
     266    String sampleGraphLengthLabel;  
     267    String sampleGraphPositionLabel;  
     268//  ############ Localized Fields ####################################    
    271269    URL endPageURL; 
    272270    URL helpPageURL; 
     
    278276   
    279277        String tempdir = getTempDir(); 
    280 public CapturePlayback(String subject,  
    281                 String promptID1, String prompt1, String promptID2, String prompt2, String promptID3, String prompt3, String promptID4, String prompt4, String promptID5, String prompt5, 
    282                 String promptID6, String prompt6, String promptID7, String prompt7, String promptID8, String prompt8, String promptID9, String prompt9, String promptID10, String prompt10, 
    283                 String fileFieldName,String language, URL destinationURL,  
    284         URL endPageURL, URL helpPageURL, String cookie, int defaultCompressionMode) {            
    285  
     278public CapturePlayback(String language, URL destinationURL,  
     279        URL endPageURL, URL helpPageURL, String cookie) {        
     280//  ############ Localized Fields ####################################    
     281        this.language = language; 
     282        System.err.println("CapturePlayback Language:" + this.language + ":"); 
     283 
     284    LabelLocalizer labels = new LabelLocalizer(this.language); 
     285    usernamePanelLabel = labels.getUsernamePanelLabel(); 
     286    usernamePanelText = labels.getUsernamePanelText(); 
     287     
     288    copyrightName = labels.getCopyrightName(); 
     289    gplAccepted = labels.getGplAccepted(); 
     290     
     291    pleaseSelect = labels.getPleaseSelect(); 
     292    notApplicable = labels.getNotApplicable(); 
     293     
     294    genderPanelLabel = labels.getGenderPanelLabel(); 
     295    genderSelection = labels.getGenderSelection(); 
     296    gender = notApplicable; // default selection 
     297     
     298    ageRangePanelLabel = labels.getAgeRangePanelLabel(); 
     299    ageSelection = labels.getAgeSelection(); 
     300    ageRange = notApplicable; // default selection 
     301 
     302    dialectPanelLabel = labels.getDialectPanelLabel(); 
     303    dialectSelection = labels.getDialectSelection(); 
     304    dialect = notApplicable;  // default selection 
     305     
     306    microphonePanelLabel = labels.getMicrophonePanelLabel(); 
     307    microphoneSelection = labels.getMicrophoneSelection(); 
     308    microphone = notApplicable;  // default selection 
     309     
     310    uploadText = labels.getUploadText(); 
     311    uploadButtonLabel = labels.getUploadButtonLabel(); 
     312     
     313    moreInfoText = labels.getMoreInfoText(); 
     314    moreInfoButtonLabel = labels.getMoreInfoButtonLabel();     
     315 
     316    disclaimerText = labels.getDisclaimerText() ; 
     317    aboutButtonLabel = labels.getAboutButtonLabel(); 
     318     
     319    recordButton = labels.getRecordButton();  
     320    stopButton = labels.getStopButton();  
     321    playButton = labels.getPlayButton();  
     322     
     323    peakWarningLabel = labels.getPeakWarningLabel();  
     324    sampleGraphFileLabel = labels.getSampleGraphFileLabel();  
     325    sampleGraphLengthLabel = labels.getSampleGraphLengthLabel();  
     326    sampleGraphPositionLabel = labels.getSampleGraphPositionLabel();  
     327//  ############ Localized Fields ####################################   
    286328    if (prompt1 == null || prompt1.length() == 0) { 
    287         Prompts prompts = new Prompts(10, "Dutch"); 
     329        Prompts prompts = new Prompts(10, this.language); 
    288330        String [][] promptArray = prompts.getPrompts(); 
    289331                this.promptID1 = promptArray[0][0]; 
     
    307349                this.promptID10 = promptArray[0][9]; 
    308350                this.prompt10 = promptArray[1][9];               
    309     } else { 
    310         this.prompt1 = prompt1;         
    311                 this.prompt2 = prompt2;         
    312                 this.prompt3 = prompt3;         
    313                 this.prompt4 = prompt4;         
    314                 this.prompt5 = prompt5;     
    315                 this.promptID1 = promptID1;         
    316                 this.promptID2 = promptID2;         
    317                 this.promptID3 = promptID3;         
    318                 this.promptID4 = promptID4;         
    319                 this.promptID5 = promptID5;   
    320         this.prompt6 = prompt6;         
    321                 this.prompt7 = prompt7;         
    322                 this.prompt8 = prompt8;         
    323                 this.prompt9 = prompt9;         
    324                 this.prompt10 = prompt10;     
    325                 this.promptID6 = promptID6;         
    326                 this.promptID7 = promptID7;         
    327                 this.promptID8 = promptID8;         
    328                 this.promptID9 = promptID9;         
    329                 this.promptID10 = promptID10;            
    330           } 
    331        
    332         this.subject = subject; 
    333         this.fileFieldName = fileFieldName; 
    334         this.language = language; 
     351    }  
     352 
     353//        this.language = language; 
    335354        this.destinationURL = destinationURL; 
    336355        this.endPageURL = endPageURL; 
     
    400419                System.err.println("CapturePlayback's WAV file for recording uploadWavFile4 is:" + uploadWavFile4); 
    401420                System.err.println("CapturePlayback's WAV file for recording uploadWavFile5 is:" + uploadWavFile5); 
    402                 System.err.println("CapturePlayback's WAV file for recording uploadWavFile1 is:" + uploadWavFile6); 
    403                 System.err.println("CapturePlayback's WAV file for recording uploadWavFile2 is:" + uploadWavFile7); 
    404                 System.err.println("CapturePlayback's WAV file for recording uploadWavFile3 is:" + uploadWavFile8); 
    405                 System.err.println("CapturePlayback's WAV file for recording uploadWavFile4 is:" + uploadWavFile9); 
    406                 System.err.println("CapturePlayback's WAV file for recording uploadWavFile5 is:" + uploadWavFile10);             
     421                System.err.println("CapturePlayback's WAV file for recording uploadWavFile6 is:" + uploadWavFile6); 
     422                System.err.println("CapturePlayback's WAV file for recording uploadWavFile7 is:" + uploadWavFile7); 
     423                System.err.println("CapturePlayback's WAV file for recording uploadWavFile8 is:" + uploadWavFile8); 
     424                System.err.println("CapturePlayback's WAV file for recording uploadWavFile9 is:" + uploadWavFile9); 
     425                System.err.println("CapturePlayback's WAV file for recording uploadWavFile10 is:" + uploadWavFile10);            
     426                System.err.println("---------------------------------------------------------------------------");               
    407427 
    408428                setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); 
     
    620640         p2.add(DisclaimerPanel);  
    621641//#########################################################################    
    622         add(p2); 
     642        add(p2); 
    623643    } 
    624644 
     
    678698     
    679699    private void setButtonsOff() { 
    680         System.err.println("!!!!!!!setButtonsOff" ); 
     700        // debug System.err.println("!!!!!!!setButtonsOff" ); 
    681701        play1.setEnabled(false);  
    682702        capt1.setEnabled(false);  
     
    702722     
    703723    private void saveButtonState() { 
    704         System.err.println("!!!!!!!saveButtonState" ); 
     724        // debug System.err.println("!!!!!!!saveButtonState" ); 
    705725        if (play1.isEnabled()) {play1_state = true;} else {play1_state = false;} 
    706726        if (play2.isEnabled()) {play2_state = true;} else {play2_state = false;}   
     
    726746     
    727747    private void restoreButtonState() { 
    728         System.err.println("!!!!!!restoreButtonState" ); 
     748        // debug System.err.println("!!!!!!restoreButtonState" ); 
    729749        if (play1_state) {play1.setEnabled(true);} else {play1.setEnabled(false);} 
    730750        if (play2_state) {play2.setEnabled(true);} else {play2.setEnabled(false);} 
     
    755775       if (obj.equals(play1)) { 
    756776            if (play1.getText().startsWith(playButton)) { 
    757                 wavFile = wavFile1;  // !!!!!!       
     777                wavFile = wavFile1;       
    758778                duration = duration1; 
    759779                playback.start(); 
     
    771791        else if (obj.equals(play2)) { 
    772792            if (play2.getText().startsWith(playButton)) { 
    773                 wavFile = wavFile2;  // !!!!!!                 
     793                wavFile = wavFile2;            
    774794                duration = duration2;   
    775795                playback.start(); 
     
    787807        else if (obj.equals(play3)) { 
    788808            if (play3.getText().startsWith(playButton)) { 
    789                 wavFile = wavFile3;  // !!!!!!                 
     809                wavFile = wavFile3;                    
    790810                playback.start(); 
    791811                duration = duration3; 
     
    803823        else if (obj.equals(play4)) { 
    804824            if (play4.getText().startsWith(playButton)) { 
    805                 wavFile = wavFile4;  // !!!!!!                 
     825                wavFile = wavFile4;            
    806826                duration = duration4; 
    807827                playback.start(); 
     
    819839        else if (obj.equals(play5)) { 
    820840            if (play5.getText().startsWith(playButton)) { 
    821                 wavFile = wavFile5;  // !!!!!!                 
     841                wavFile = wavFile5;                    
    822842                duration = duration5; 
    823843                playback.start(); 
     
    835855        else if (obj.equals(play6)) { 
    836856            if (play6.getText().startsWith(playButton)) { 
    837                 wavFile = wavFile6;  // !!!!!!                 
     857                wavFile = wavFile6;                    
    838858                duration = duration6; 
    839859                playback.start(); 
     
    851871        else if (obj.equals(play7)) { 
    852872            if (play7.getText().startsWith(playButton)) { 
    853                 wavFile = wavFile7;  // !!!!!!                 
     873                wavFile = wavFile7;                    
    854874                duration = duration7; 
    855875                playback.start(); 
     
    867887        else if (obj.equals(play8)) { 
    868888            if (play8.getText().startsWith(playButton)) { 
    869                 wavFile = wavFile8;  // !!!!!!                 
     889                wavFile = wavFile8;                    
    870890                duration = duration8; 
    871891                playback.start(); 
     
    883903        else if (obj.equals(play9)) { 
    884904            if (play9.getText().startsWith(playButton)) { 
    885                 wavFile = wavFile9;  // !!!!!!                 
     905                wavFile = wavFile9;                    
    886906                duration = duration9; 
    887907                playback.start(); 
     
    899919        else if (obj.equals(play10)) { 
    900920            if (play10.getText().startsWith(playButton)) { 
    901                 wavFile = wavFile10;  // !!!!!!                
     921                wavFile = wavFile10;                   
    902922                duration = duration10; 
    903923                playback.start(); 
     
    17131733         
    17141734        public void run() { 
    1715  
    1716             // The COMPRESSING stage 
    17171735            progBar.setVisible(true); 
    17181736            progBar.setStringPainted(true); 
    1719             progBar.setString("Compressing..."); 
    1720             //progBar.setIndeterminate(true); 
    1721  
    1722             try { 
    1723 //DEL WHEN NEW METHOD                if (AudioSystem.write(audioInputStream, AudioFileFormat.Type.WAVE, wavFile) == -1) { 
    1724 //DEL WHEN NEW METHOD                    throw new IOException("Problems writing to temp WAV file"); 
    1725 //DEL WHEN NEW METHOD                } 
    1726                 File spxFile = File.createTempFile("mdl", ".spx"); 
    1727                 spxFile.deleteOnExit(); 
    1728 System.err.println("Temp Speex file: " + spxFile); 
    1729                  
    1730                 progBar.setMinimum(0); 
    1731                 progBar.setMaximum(100); 
    1732  
    1733  
    1734  
    1735  
    1736             // The UPLOAD stage 
     1737            progBar.setMaximum(100); 
    17371738            progBar.setString("Uploading..."); 
    17381739            progBar.setIndeterminate(false); 
    1739  
    1740 // !!!!!! 
    1741 //            progBar.setMaximum((int)spxFile.length()); 
    1742 //            totalBytes = ((int)spxFile.length()); 
    1743  //           progBar.setMaximum((int)wavFile.length()); 
    1744  //           totalBytes = ((int)wavFile.length());             
    1745 // !!!!!!             
    17461740            progBar.setMinimum(0); 
    17471741            sentBytes = 0; 
    1748  
    1749  
    1750 //if(subject != null) { 
    1751 //  System.err.println("Adding subject to URL"); 
    1752   try { 
    1753           destinationURL = new URL(destinationURL.toString());     
    1754   }catch(Exception err){ 
    1755     System.err.println(err); 
    1756   } 
    1757   System.err.println("Destination URL is " + destinationURL); 
    1758 //} 
    1759  
    1760 File[] files = new File[15]; 
    1761 //############ audio files ####################################  
    1762 files[1] = uploadWavFile1; 
    1763 files[2] = uploadWavFile2; 
    1764 files[3] = uploadWavFile3; 
    1765 files[4] = uploadWavFile4; 
    1766 files[5] = uploadWavFile5; 
    1767 files[6] = uploadWavFile6; 
    1768 files[7] = uploadWavFile7; 
    1769 files[8] = uploadWavFile8; 
    1770 files[9] = uploadWavFile9; 
    1771 files[10] = uploadWavFile10; 
    1772  
    1773 //############ prompt files ####################################  
    1774 try { 
    1775         BufferedWriter out_prompts = new BufferedWriter(new FileWriter(promptsFile)); 
    1776         out_prompts.write(promptID1 + " " + prompt1 + System.getProperty("line.separator")); 
    1777         out_prompts.write(promptID2 + " " + prompt2 + System.getProperty("line.separator")); 
    1778         out_prompts.write(promptID3 + " " + prompt3 + System.getProperty("line.separator")); 
    1779         out_prompts.write(promptID4 + " " + prompt4 + System.getProperty("line.separator")); 
    1780     out_prompts.write(promptID5 + " " + prompt5 + System.getProperty("line.separator"));         
    1781         out_prompts.write(promptID6 + " " + prompt6 + System.getProperty("line.separator")); 
    1782         out_prompts.write(promptID7 + " " + prompt7 + System.getProperty("line.separator")); 
    1783         out_prompts.write(promptID8 + " " + prompt8 + System.getProperty("line.separator")); 
    1784         out_prompts.write(promptID9 + " " + prompt9 + System.getProperty("line.separator")); 
    1785     out_prompts.write(promptID10 + " " + prompt10 + System.getProperty("line.separator"));       
    1786     out_prompts.close(); 
    1787 } catch (IOException e) { 
    1788             System.err.println("Problems with prompts"); 
    1789 }  
    1790 files[11] = promptsFile; 
    1791 //############ ReadMe file####################################  
    1792 try { 
    1793         BufferedWriter out_readme = new BufferedWriter(new FileWriter(readmeFile)); 
    1794         out_readme.write("User Name:" + userName + System.getProperty("line.separator")); 
    1795         out_readme.write(System.getProperty("line.separator"));  
    1796  
    1797         out_readme.write("Speaker Characteristics:" + System.getProperty("line.separator") ); 
    1798         out_readme.write(System.getProperty("line.separator"));  
    1799         out_readme.write("Gender: " + gender + System.getProperty("line.separator") ); 
    1800         out_readme.write("Age Range: " + ageRange + System.getProperty("line.separator"));  
    1801         out_readme.write("Pronunciation dialect: " + dialect + System.getProperty("line.separator"));    
    1802         out_readme.write(System.getProperty("line.separator")); 
    1803  
    1804         out_readme.write("Recording Information:" + System.getProperty("line.separator"));       
    1805         out_readme.write(System.getProperty("line.separator")); 
    1806         out_readme.write("Microphone make: n/a" + System.getProperty("line.separator"));         
    1807         out_readme.write("Microphone type:" + microphone + System.getProperty("line.separator"));        
    1808         out_readme.write("Audio card make: unknown" + System.getProperty("line.separator"));     
    1809         out_readme.write("Audio card type: unknown" + System.getProperty("line.separator")); 
    1810         out_readme.write("Audio Recording Software: VoxForge Speech Submission Application" + System.getProperty("line.separator")); 
    1811         out_readme.write("O/S:" + System.getProperty("line.separator"));         
    1812         out_readme.write(System.getProperty("line.separator"));  
    1813          
    1814         out_readme.write("File Info:" + System.getProperty("line.separator")); 
    1815         out_readme.write(System.getProperty("line.separator")); 
    1816         out_readme.write("File type: " + fileType + System.getProperty("line.separator")); 
    1817         out_readme.write("Sampling Rate: " + samplingRate + System.getProperty("line.separator")); 
    1818         out_readme.write("Sample rate format: " + samplingRateFormat + System.getProperty("line.separator")); 
    1819         out_readme.write("Number of channels: " + numberChannels + System.getProperty("line.separator"));        
    1820          
    1821         out_readme.close();      
    1822 } catch (IOException e) { 
    1823     System.err.println("Problems with Gender, Age Range or Dialect"); 
    1824 }  
    1825 files[12] = readmeFile; 
    1826 //############ License Notice File ####################################     
    1827 try { 
    1828         Calendar cal = Calendar.getInstance(); 
    1829         int year = cal.get(Calendar.YEAR); 
    1830         BufferedWriter out_licenseNoticeFile = new BufferedWriter(new FileWriter(licenseNoticeFile)); 
    1831         String licenseNotice = "Copyright " + cal.get(Calendar.YEAR) + " " + copyrightName + System.getProperty("line.separator")  
    1832                 + System.getProperty("line.separator")  
    1833                 + licenseObject.getBlanklicenseNotice(); 
    1834         out_licenseNoticeFile.write(licenseNotice); 
    1835         out_licenseNoticeFile.close();   
    1836 } catch (IOException e) { 
    1837             System.err.println("Problems with licenseNoticeFile file"); 
    1838 }  
    1839 files[13] = licenseNoticeFile; 
    1840  
    1841 //############ license file ####################################     
    1842 try { 
    1843         BufferedWriter out_licenseFile = new BufferedWriter(new FileWriter(licenseFile)); 
    1844         out_licenseFile.write(licenseObject.getGPLLicense()); 
    1845         out_licenseFile.close();         
    1846 } catch (IOException e) { 
    1847         System.err.println("Problems with license file"); 
    1848 }  
    1849 files[14] = licenseFile; 
    1850 //############ create archive file ####################################  
    1851 File archiveFile; 
    1852 Calendar cal = Calendar.getInstance(); 
    1853 int day = cal.get(Calendar.DATE); 
    1854 int month = cal.get(Calendar.MONTH) + 1; 
    1855 int year = cal.get(Calendar.YEAR); 
    1856 StringBuffer sb = new StringBuffer(11); 
    1857 sb.append(year); 
    1858 if( month < 10 ) sb.append("0"); 
    1859 sb.append(month); 
    1860 if( day < 10 ) sb.append("0"); 
    1861 sb.append(day); 
    1862 String date = sb.toString(); 
    1863  
    1864 Random randomGenerator = new Random(); 
    1865 int SMALL_LETTERS_BASE_VALUE = 97; 
    1866 // int CAPITAL_LETTERS_BASE_VALUE = 65; 
    1867 StringBuffer randomID = new StringBuffer("");  // required for jvm 1.4.2 
    1868 //StringBuilder randomID = new StringBuilder(""); // will not work with JVM 1.4.2  
    1869 for ( int i = 0; randomID.length() < 3; i++ ) 
    1870 
    1871         int currentValue = randomGenerator.nextInt(26); 
    1872         currentValue += SMALL_LETTERS_BASE_VALUE;//convert to ASCII value for a-z 
    1873         randomID.append((char)currentValue); 
    1874 
    1875  
    1876 if (userName != null){ 
    1877         archiveFile = new File(tempdir + userName + "-" + date + "-" + randomID + ".zip"); 
    1878 } else { 
    1879         archiveFile = new File(tempdir +"Anonymous-" + date + "-" + randomID + ".zip"); 
    1880 
    1881  
    1882 createZipArchive(archiveFile, files); 
    1883 System.err.println("Archive file location:" + archiveFile); 
    1884 // debug System.err.println("username:" + userName + ":"); 
    1885 //!!!!!! 
    1886 totalBytes = ((int)archiveFile.length()) ;  
    1887 progBar.setMaximum((int)archiveFile.length()); 
    1888 // !!!!!! 
    1889 //############ Upload ####################################  
    1890  
    1891 // Upload manager needs an array but JavaUpload.php script can only handle one file at a time 
    1892 File[] archiveFiles = new File[1]; 
    1893  
    1894 archiveFiles[0] = archiveFile; 
    1895                         UploadManager u; 
    1896                         try { 
    1897  //                          u = new UploadManager(files, capturePlayback, destinationURL, 1, fileFieldName); 
    1898                             u = new UploadManager(archiveFiles, capturePlayback, destinationURL, 1, fileFieldName); 
    1899  
    1900                         } catch(java.lang.NullPointerException npered){ 
    1901 //                            u = new UploadManager(files, capturePlayback, destinationURL, fileFieldName); 
    1902                                 u = new UploadManager(archiveFiles, capturePlayback, destinationURL, fileFieldName); 
    1903                         } 
    1904                         System.err.println("Uploading to " + destinationURL); 
    1905 // !!!!!!                         
    1906                         u.start(); 
    1907  
    1908             } catch(IOException e) { 
    1909                 shutDown("Unable to encode the stream\n" + e); 
    1910             } 
     1742                        try { 
     1743                                destinationURL = new URL(destinationURL.toString());       
     1744                        }catch(Exception err){ 
     1745                            System.err.println(err); 
     1746                        } 
     1747                        System.err.println("Destination URL is " + destinationURL); 
     1748                         
     1749                        File[] files = new File[15]; 
     1750                        //############ audio files ####################################  
     1751                        files[1] = uploadWavFile1; 
     1752                        files[2] = uploadWavFile2; 
     1753                        files[3] = uploadWavFile3; 
     1754                        files[4] = uploadWavFile4; 
     1755                        files[5] = uploadWavFile5; 
     1756                        files[6] = uploadWavFile6; 
     1757                        files[7] = uploadWavFile7; 
     1758                        files[8] = uploadWavFile8; 
     1759                        files[9] = uploadWavFile9; 
     1760                        files[10] = uploadWavFile10; 
     1761                        //############ prompt files ####################################  
     1762                        try { 
     1763                                BufferedWriter out_prompts = new BufferedWriter(new FileWriter(promptsFile)); 
     1764                                out_prompts.write(promptID1 + " " + prompt1 + System.getProperty("line.separator")); 
     1765                                out_prompts.write(promptID2 + " " + prompt2 + System.getProperty("line.separator")); 
     1766                                out_prompts.write(promptID3 + " " + prompt3 + System.getProperty("line.separator")); 
     1767                                out_prompts.write(promptID4 + " " + prompt4 + System.getProperty("line.separator")); 
     1768                            out_prompts.write(promptID5 + " " + prompt5 + System.getProperty("line.separator"));         
     1769                                out_prompts.write(promptID6 + " " + prompt6 + System.getProperty("line.separator")); 
     1770                                out_prompts.write(promptID7 + " " + prompt7 + System.getProperty("line.separator")); 
     1771                                out_prompts.write(promptID8 + " " + prompt8 + System.getProperty("line.separator")); 
     1772                                out_prompts.write(promptID9 + " " + prompt9 + System.getProperty("line.separator")); 
     1773                            out_prompts.write(promptID10 + " " + prompt10 + System.getProperty("line.separator"));       
     1774                            out_prompts.close(); 
     1775                        } catch (IOException e) { 
     1776                                    System.err.println("Problems with prompts"); 
     1777                        }  
     1778                        files[11] = promptsFile; 
     1779                        //############ ReadMe file####################################  
     1780                        try { 
     1781                                BufferedWriter out_readme = new BufferedWriter(new FileWriter(readmeFile)); 
     1782                                out_readme.write("User Name:" + userName + System.getProperty("line.separator")); 
     1783                                out_readme.write(System.getProperty("line.separator"));  
     1784                         
     1785                                out_readme.write("Speaker Characteristics:" + System.getProperty("line.separator") ); 
     1786                                out_readme.write(System.getProperty("line.separator"));  
     1787                                out_readme.write("Gender: " + gender + System.getProperty("line.separator") ); 
     1788                                out_readme.write("Age Range: " + ageRange + System.getProperty("line.separator"));  
     1789                                out_readme.write("Pronunciation dialect: " + dialect + System.getProperty("line.separator"));    
     1790                                out_readme.write(System.getProperty("line.separator")); 
     1791                         
     1792                                out_readme.write("Recording Information:" + System.getProperty("line.separator"));       
     1793                                out_readme.write(System.getProperty("line.separator")); 
     1794                                out_readme.write("Microphone make: n/a" + System.getProperty("line.separator"));         
     1795                                out_readme.write("Microphone type:" + microphone + System.getProperty("line.separator"));        
     1796                                out_readme.write("Audio card make: unknown" + System.getProperty("line.separator"));     
     1797                                out_readme.write("Audio card type: unknown" + System.getProperty("line.separator")); 
     1798                                out_readme.write("Audio Recording Software: VoxForge Speech Submission Application" + System.getProperty("line.separator")); 
     1799                                out_readme.write("O/S:" + System.getProperty("line.separator"));         
     1800                                out_readme.write(System.getProperty("line.separator"));  
     1801                                 
     1802                                out_readme.write("File Info:" + System.getProperty("line.separator")); 
     1803                                out_readme.write(System.getProperty("line.separator")); 
     1804                                out_readme.write("File type: " + fileType + System.getProperty("line.separator")); 
     1805                                out_readme.write("Sampling Rate: " + samplingRate + System.getProperty("line.separator")); 
     1806                                out_readme.write("Sample rate format: " + samplingRateFormat + System.getProperty("line.separator")); 
     1807                                out_readme.write("Number of channels: " + numberChannels + System.getProperty("line.separator"));        
     1808                                 
     1809                                out_readme.close();      
     1810                        } catch (IOException e) { 
     1811                            System.err.println("Problems with Gender, Age Range or Dialect"); 
     1812                        }  
     1813                        files[12] = readmeFile; 
     1814                        //############ License Notice File ####################################     
     1815                        try { 
     1816                                Calendar cal = Calendar.getInstance(); 
     1817                                int year = cal.get(Calendar.YEAR); 
     1818                                BufferedWriter out_licenseNoticeFile = new BufferedWriter(new FileWriter(licenseNoticeFile)); 
     1819                                String licenseNotice = "Copyright " + cal.get(Calendar.YEAR) + " " + copyrightName + System.getProperty("line.separator")  
     1820                                        + System.getProperty("line.separator")  
     1821                                        + licenseObject.getBlanklicenseNotice(); 
     1822                                out_licenseNoticeFile.write(licenseNotice); 
     1823                                out_licenseNoticeFile.close();   
     1824                        } catch (IOException e) { 
     1825                                    System.err.println("Problems with licenseNoticeFile file"); 
     1826                        }  
     1827                        files[13] = licenseNoticeFile; 
     1828                        //############ license file ####################################     
     1829                        try { 
     1830                                BufferedWriter out_licenseFile = new BufferedWriter(new FileWriter(licenseFile)); 
     1831                                out_licenseFile.write(licenseObject.getGPLLicense()); 
     1832                                out_licenseFile.close();         
     1833                        } catch (IOException e) { 
     1834                                System.err.println("Problems with license file"); 
     1835                        }  
     1836                        files[14] = licenseFile; 
     1837                        //############ create archive file ####################################  
     1838                        File archiveFile; 
     1839                        Calendar cal = Calendar.getInstance(); 
     1840                        int day = cal.get(Calendar.DATE); 
     1841                        int month = cal.get(Calendar.MONTH) + 1; 
     1842                        int year = cal.get(Calendar.YEAR); 
     1843                        StringBuffer sb = new StringBuffer(11); 
     1844                        sb.append(year); 
     1845                        if( month < 10 ) sb.append("0"); 
     1846                        sb.append(month); 
     1847                        if( day < 10 ) sb.append("0"); 
     1848                        sb.append(day); 
     1849                        String date = sb.toString(); 
     1850                         
     1851                        Random randomGenerator = new Random(); 
     1852                        int SMALL_LETTERS_BASE_VALUE = 97; 
     1853                        // int CAPITAL_LETTERS_BASE_VALUE = 65; 
     1854                        StringBuffer randomID = new StringBuffer("");  // required for jvm 1.4.2 
     1855                        //StringBuilder randomID = new StringBuilder(""); // will not work with JVM 1.4.2  
     1856                        for ( int i = 0; randomID.length() < 3; i++ ) 
     1857                        { 
     1858                                int currentValue = randomGenerator.nextInt(26); 
     1859                                currentValue += SMALL_LETTERS_BASE_VALUE;//convert to ASCII value for a-z 
     1860                                randomID.append((char)currentValue); 
     1861                        } 
     1862                         
     1863                        if (userName != null){ 
     1864                                archiveFile = new File(tempdir + userName + "-" + date + "-" + randomID + ".zip"); 
     1865                        } else { 
     1866                                archiveFile = new File(tempdir +"Anonymous-" + date + "-" + randomID + ".zip"); 
     1867                        } 
     1868                         
     1869                        createZipArchive(archiveFile, files); 
     1870                        System.err.println("Archive file location:" + archiveFile); 
     1871                        totalBytes = ((int)archiveFile.length()) ;  
     1872                        progBar.setMaximum((int)archiveFile.length()); 
     1873                        //############ Upload ####################################  
     1874                        // Upload manager needs an array but JavaUpload.php script can only handle one file at a time 
     1875                        File[] archiveFiles = new File[1]; 
     1876                        archiveFiles[0] = archiveFile; 
     1877            UploadManager u; 
     1878            try { 
     1879                u = new UploadManager(archiveFiles, capturePlayback, destinationURL, 1, fileFieldName); 
     1880            } catch(java.lang.NullPointerException npered){ 
     1881                u = new UploadManager(archiveFiles, capturePlayback, destinationURL, fileFieldName); 
     1882            } 
     1883            System.err.println("Uploading to " + destinationURL); 
     1884            u.start(); 
    19111885        } 
    19121886 
     
    19641938     */ 
    19651939    class SamplingGraph extends JPanel implements Runnable { 
    1966  
    19671940        private Thread thread; 
    19681941        private Font font10 = new Font("serif", Font.PLAIN, 10); 
     
    20021975            int h = d.height-15; 
    20031976            int[] audioData = null; 
    2004             // !!!!!! 
    20051977            int audioDatum = 0; // Will store values one-by-one 
    20061978            long numPeakValues = 0; // To help detect peaking 
     
    20081980 //           long nlengthInSamples = ais.getFrameLength() * ais.getFormat().getChannels(); 
    20091981            int nlengthInSamples =0; 
    2010             // !!!!!! 
    20111982            if (format.getSampleSizeInBits() == 16) { 
    2012                 // !!!!!! 
    20131983                // int nlengthInSamples = audioBytes.length / 2; 
    20141984                 nlengthInSamples = audioBytes.length / 2; 
    2015                 // !!!!!! 
    20161985                 audioData = new int[nlengthInSamples]; 
    20171986                 if (format.isBigEndian()) { 
     
    20221991                         int LSB = (int) audioBytes[2*i+1]; 
    20231992                         audioData[i] = MSB << 8 | (255 & LSB); 
    2024                          // !!!!!! 
    20251993                                                 audioDatum = MSB << 8 | (255 & LSB); 
    20261994                                                 if(audioDatum > peakThresh) { 
    20271995                                                         numPeakValues++; 
    20281996                                                 } 
    2029                                                  // !!!!!! 
    20301997                     } 
    20311998                 } else { 
     
    20362003                         int MSB = (int) audioBytes[2*i+1]; 
    20372004                         audioData[i] = MSB << 8 | (255 & LSB); 
    2038                          // !!!!!! 
    20392005                                                 audioDatum = MSB << 8 | (255 & LSB); 
    20402006                                                 if(audioDatum > peakThresh) { 
    20412007                                                         numPeakValues++; 
    20422008                                                 } 
    2043                                                  // !!!!!! 
    20442009                     } 
    20452010                 } 
     
    20672032            repaint(); 
    20682033        } 
    2069  
    20702034 
    20712035        public void paint(Graphics g) { 
     
    22042168        } else { 
    22052169//FORDEBUG 
    2206            System.err.println("setProgress(): Not reached end yet. sentBytes="+sentBytes+", totalBytes="+totalBytes); 
     2170        // debug   System.err.println("setProgress(): Not reached end yet. sentBytes="+sentBytes+", totalBytes="+totalBytes); 
    22072171        } 
    22082172     } 
     
    22232187                return cookie; 
    22242188        } 
    2225          
    2226   
    2227 /* Disabled - We don't want to be able to run it as a standalone app! 
    2228     public static void main(String s[]) { 
    2229         CapturePlayback capturePlayback = new CapturePlayback(); 
    2230         capturePlayback.open(); 
    2231         JFrame f = new JFrame("Capture/Playback"); 
    2232         f.addWindowListener(new WindowAdapter() { 
    2233             public void windowClosing(WindowEvent e) { System.exit(0); } 
    2234         }); 
    2235         f.getContentPane().add("Center", capturePlayback); 
    2236         f.pack(); 
    2237         Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
    2238         int w = 720; 
    2239         int h = 340; 
    2240         f.setLocation(screenSize.width/2 - w/2, screenSize.height/2 - h/2); 
    2241         f.setSize(w, h); 
    2242         f.show(); 
    2243     }  
    2244     */ 
    2245  
    2246   
    22472189}  
    22482190 
  • Trunk/SpeechSubmission/VFSpeechSubmission/java/src/speechrecorder/LabelLocalizer.java

    r2357 r2363  
    22 
    33class LabelLocalizer  { 
    4     String usernamePanelLabel; 
    5     String usernamePanelText; 
    6      
    7     String copyrightName; 
    8     String gplAccepted; 
    9      
    10     String pleaseSelect; 
    11     String notApplicable; 
    12      
    13     String genderPanelLabel; 
    14     String genderSelection []; 
    15      
    16     String ageRangePanelLabel; 
    17     String ageSelection []; 
    18  
    19     String dialectPanelLabel; 
    20     String dialectSelection []; 
    21      
    22     String microphonePanelLabel; 
    23     String microphoneSelection []; 
    24      
    25     String uploadText; 
    26     String uploadButtonLabel; 
    27      
    28     String moreInfoText; 
    29     String moreInfoButtonLabel;     
    30  
    31     String disclaimerText; 
    32     String aboutButtonLabel; 
    33      
    34     String recordButton;  
    35     String stopButton;  
    36     String playButton;  
    37     String peakWarningLabel;  
    38     String sampleGraphFileLabel; 
    39     String sampleGraphLengthLabel; 
    40     String sampleGraphPositionLabel; 
    41          
    42         public LabelLocalizer (String Language) { 
    43                 if (Language == "English") { 
     4    private String usernamePanelLabel; 
     5    private String usernamePanelText; 
     6     
     7    private String copyrightName; 
     8    private String gplAccepted; 
     9     
     10    private String pleaseSelect; 
     11    private String notApplicable; 
     12     
     13    private String genderPanelLabel; 
     14    private String genderSelection []; 
     15     
     16    private String ageRangePanelLabel; 
     17    private String ageSelection []; 
     18 
     19    private String dialectPanelLabel; 
     20    private String dialectSelection []; 
     21     
     22    private String microphonePanelLabel; 
     23    private String microphoneSelection []; 
     24     
     25    private String uploadText; 
     26    private String uploadButtonLabel; 
     27     
     28    private String moreInfoText; 
     29    private String moreInfoButtonLabel;     
     30 
     31    private String disclaimerText; 
     32    private String aboutButtonLabel; 
     33     
     34    private String recordButton;  
     35    private String stopButton;  
     36    private String playButton;  
     37    private String peakWarningLabel;  
     38&nbs