Menu

error with microphone

Help
salva
2007-11-22
2012-09-22
  • salva

    salva - 2007-11-22

    hello,

    I have this error when I execute the recognition for the second time (the first one works well):

    SEVERE microphone Can't open microphone line with format PCM_SIGNED 16000.0 Hz, 16 bit, mono, 2 bytes/frame, big-endian not supported. in edu.cmu.sphinx.frontend.util.Microphone:open-microphone

    If I stop the program and turn it to launching, the first time is executed well but when doing the second recognition returns to giving the mistake.

    the code of the method:
    public String iniciaEscucha() {

        Recognizer recognizer;
        Microphone microphone;
    
        ConfigurationManager cm;
    
        URL url= this.getClass().getResource("configuracion.xml");
    
        try {
    
            cm = new ConfigurationManager(url);
    
            try {
                    recognizer = (Recognizer) cm.lookup("recognizer");
                    microphone = (Microphone) cm.lookup("microphone");
    
                /* allocate the resource necessary for the recognizer */
                recognizer.allocate();
    
                /* the microphone will keep recording until the program exits */
                if (microphone.startRecording()) {
    
                    Result result = recognizer.recognize();
    
                    if (result != null) {
            String resultText = result.getBestResultNoFiller();
                recognizer.deallocate();
                        microphone.stopRecording();
                        microphone.clear();
            return("He escuchado: "+transformar(resultText));
                    } else {
                recognizer.deallocate();
                        microphone.stopRecording();
                        microphone.clear();
                return("No te entiendo");
                    }
                } else {
                    recognizer.deallocate();
                    return("No puedo inicializar el microfono");
                }
    
            } catch (InstantiationException ex) {
                    return ex.getMessage();
            } catch (PropertyException ex) {
                    return ex.getMsg();
            }
        } catch (IOException ex) {
            return ex.getMessage();
        } catch (PropertyException ex) {
            return ex.getMsg();
        }
    
    }
    
     
    • salva

      salva - 2007-11-23

      here the code modified:

      public String iniciaEscucha() {
      
          Recognizer recognizer;
          Microphone microphone;
      
          ConfigurationManager cm;
      
          URL url= this.getClass().getResource("configuracion.xml");
      
          try {
      
              cm = new ConfigurationManager(url);
      
              try {
                      recognizer = (Recognizer) cm.lookup("recognizer");
                      microphone = (Microphone) cm.lookup("microphone");
      
                  /* allocate the resource necessary for the recognizer */
                  recognizer.allocate();
      
                  /* the microphone will keep recording until the program exits */
                  if (microphone.startRecording()) {
      
                      Result result = recognizer.recognize();
      
                      if (result != null) {
              String resultText = result.getBestResultNoFiller();
              return("He escuchado: "+transformar(resultText));
                      } else {
                          microphone.stopRecording();
                  return("No te entiendo");
                      }
                  } else {
                      recognizer.deallocate();
                      return("No puedo inicializar el microfono");
                  }
      
              } catch (InstantiationException ex) {
                      return ex.getMessage();
              } catch (PropertyException ex) {
                      return ex.getMsg();
              }
          } catch (IOException ex) {
              return ex.getMessage();
          } catch (PropertyException ex) {
              return ex.getMsg();
          }
      
      }
      
       
    • Nickolay V. Shmyrev

      Do not close microphone and deallocate recognizer between calls, close it only once.

       
      • salva

        salva - 2007-11-22

        I finish of doing it just now, and it continues giving the same mistake.
        Some another idea???

         
        • Nickolay V. Shmyrev

          Paste updated code

           

Log in to post a comment.