Menu

Error when creating AudioRecord

Help
2014-02-16
2015-03-21
  • rompelstilchen2

    rompelstilchen2 - 2014-02-16

    hello,

    on my phone the Demo application works fine (svn repository)
    but on another phone, i get an error

    Could not get audio input for record source 6
    Error creating AudioRecord instance: initialization check failed.
    [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.

    after investigation, i checked the code in SpeechRecognizer.java

    this is the line causing problem

    recorder = new AudioRecord(MediaRecorder.AudioSource.VOICE_RECOGNITION,
    (int) config.getFloat("-samprate"),
    AudioFormat.CHANNEL_IN_MONO,
    AudioFormat.ENCODING_PCM_16BIT,
    8192);

    if i add

    config.setFloat("-samprate", 8000);

    to PocketSphinxActivity.java, it works but i get another Filter error

    FATAL: "fe_sigproc.c", line 657: Failed to create filterbank, frequency range does not match. Sample rate 8000.000000, FFT size 512, lowerf 5125.000000 < freq -15.625000 > upperf 4218.750000.

    so nomatter what i say, it keeps displayn "Withdraw two two two one"

    can you enlight me ?

    thx

     

    Last edit: rompelstilchen2 2014-02-16
  • Nickolay V. Shmyrev

    Please, tell us phone models and OS versions. Thanks.

     
    • rompelstilchen2

      rompelstilchen2 - 2014-02-17

      phone is actually a dev board ODROID XU-E
      android 4.2.2

       
  • rompelstilchen2

    rompelstilchen2 - 2014-02-17

    so i had the same issue with another app and it is definetely a problem that occurs becos of an unsupported sampling rate

     
  • rompelstilchen2

    rompelstilchen2 - 2014-02-18

    did you had the opportunity to look at the problem ?

     
  • Nickolay V. Shmyrev

    If hardware doesn't support recording with required sampling rate there is little we can do about that.

     
    • rompelstilchen2

      rompelstilchen2 - 2014-02-18

      the AudioRecord is created without any frame rate in the Demo code

      (int) config.getFloat("-samprate") will return nothing, so how could this work
      what is the default frame rate ?

       

      Last edit: rompelstilchen2 2014-02-18
  • rompelstilchen2

    rompelstilchen2 - 2014-02-18

    if i remember well the previous versions were using a sample rate of 8000

    ... not in the current (sf svn) code :

    Config config = Decoder.defaultConfig();
    config.setString("-dict", joinPath(appDir, "models/lm/cmu07a.dic"));
    config.setString("-hmm", joinPath(appDir, "models/hmm/en-us-semi"));
    config.setString("-rawlogdir", appDir.getPath());
    config.setInt("-maxhmmpf", 10000);
    config.setBoolean("-fwdflat", false);
    config.setBoolean("-bestpath", false);
    config.setFloat("-kws_threshold", 1e-5);
    recognizer = new SpeechRecognizer(config);

    where SpeechRecognizer uses

    (int) config.getFloat("-samprate")

    how could this even work ?? i dont get it

     

    Last edit: rompelstilchen2 2014-02-18
    • Alexander Solovets

      You sound offensive though you don't even bother to look at the code or debug that piece of code. Config object has many options set implicitly. The default sampling rate should be 16000.

       
      • rompelstilchen2

        rompelstilchen2 - 2014-02-21

        i did not mean anything offensive

        it works on my other phone and there is no config.getFloat("-samprate") in the code
        so i wondered how could this work ... that's all

        why be so irritable? i try to write the best english i can, although i am french so sorry if i wrote something that could be interpreted the wrong way

        and i did not have much time to go deep in the debugging cos i also try to make other libraries work on the dev platform

         

        Last edit: rompelstilchen2 2014-02-21
  • Nickolay V. Shmyrev

    so i wondered how could this work ... that's all

    It works as written in the code. Default value 16000 is configured in recognizer and used in AudioRecord.

    You can not use 8000 anymore, en-us-semi is 16khz model

     
  • Jaspreet Sahota

    Jaspreet Sahota - 2015-03-19

    Hello All

    Is there a fix for the issue? Please let me know.
    Facing exactly same issue on Odroid-XU.

     
    • Nickolay V. Shmyrev

      Get better phone.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.