Menu

PocketSphinx for Android - Problems building

Help
Anonymous
2010-12-21
2012-09-22
<< < 1 2 (Page 2 of 2)
  • Swathi EP

    Swathi EP - 2010-12-23

    As i was able to build successfully in emulator, i tried to install the .apk
    file in HTC EVO 4G, but the installation failed with message:

    Failure

    And log message was as below:

    12-23 11:50:15.399: WARN/ResourceType(84): Bad string block: string #5 extends
    to 4441, past end at 94
    12-23 11:50:15.409: WARN/PackageParser(84): /data/app/vmdl14507.tmp
    12-23 11:50:15.409: WARN/PackageParser(84):
    java.lang.IndexOutOfBoundsException
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.res.StringBlock.nativeGetString(Native Method)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.res.StringBlock.get(StringBlock.java:81)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.res.AssetManager.getPooledString(AssetManager.java:258)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.res.TypedArray.loadStringValueAt(TypedArray.java:675)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.res.TypedArray.getValueAt(TypedArray.java:659)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.res.TypedArray.peekValue(TypedArray.java:620)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.pm.PackageParser.parseApplication(PackageParser.java:1353)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.pm.PackageParser.parsePackage(PackageParser.java:734)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.content.pm.PackageParser.parsePackage(PackageParser.java:390)
    12-23 11:50:15.409: WARN/PackageParser(84): at com.android.server.PackageManag
    erService.installPackageLI(PackageManagerService.java:4312)
    12-23 11:50:15.409: WARN/PackageParser(84): at com.android.server.PackageManag
    erService.access$1600(PackageManagerService.java:109)
    12-23 11:50:15.409: WARN/PackageParser(84): at com.android.server.PackageManag
    erService$5.run(PackageManagerService.java:3816)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.os.Handler.handleCallback(Handler.java:587)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.os.Handler.dispatchMessage(Handler.java:92)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.os.Looper.loop(Looper.java:123)
    12-23 11:50:15.409: WARN/PackageParser(84): at
    android.os.HandlerThread.run(HandlerThread.java:60)

    please tell me what is going wrong?
    I found that there are some java exceptions defined in the file
    pocketsphinx_wrap.c, is this exception coming from that file?

    And also please answer for my above comment as well.

    Thanks,
    Swathi EP

     
  • Anonymous

    Anonymous - 2010-12-23

    Swathi - You can build your own corpus and use that to generate a language
    model and dictionary files. See this link on the wiki for more information:

    http://cmusphinx.sourceforge.net/wiki/tutoriallm

     
  • Swathi EP

    Swathi EP - 2010-12-23

    Jason L. - Thank you. This link is going to be very helpful.

    Do you have any idea on the issue, i have posted above? Did you run the
    project in emulator or on android device?

     
  • Anonymous

    Anonymous - 2010-12-23

    I'm running the project directly on my Droid X. The error to me looks like
    your .apk file was not built properly. Are you building against Android 2.2?

    Also, have you tried deploying directly from Eclipse or are you building the
    apk and then sending it to your device?

     
  • Swathi EP

    Swathi EP - 2010-12-24

    I am building the project first through eclipse, then i am installing the
    generated apk file in the device.

     
  • Swathi EP

    Swathi EP - 2010-12-24

    Got to know the problem, the device was having eclair i.e., android 2.1, so i
    was not able to install.

     
  • Shad Ansari

    Shad Ansari - 2011-01-05

    I have just started out trying to build the PocketSphinxAndroidDemo and am
    running into a compile error similar to something reported earlier (Jason).
    Appreciate if someone could help me get over this as you folks seem to have
    figured it out:

    /home/shad/android/android-ndk-r5/toolchains/arm-linux-
    androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++
    -Wl,-soname,libpocketsphinx_jni.so -shared --sysroot=/home/shad/android
    /android-ndk-r5/platforms/android-8/arch-arm
    /home/shad/cmusphinx/trunk/PocketSphinxAndroidDemo/obj/local/armeabi/objs-
    debug/pocketsphinx_jni/pocketsphinx_wrap.o /home/shad/cmusphinx/trunk/PocketSp
    hinxAndroidDemo/obj/local/armeabi/libsphinxutil.a /home/shad/cmusphinx/trunk/P
    ocketSphinxAndroidDemo/obj/local/armeabi/libsphinxfe.a /home/shad/cmusphinx/tr
    unk/PocketSphinxAndroidDemo/obj/local/armeabi/libsphinxfeat.a /home/shad/cmusp
    hinx/trunk/PocketSphinxAndroidDemo/obj/local/armeabi/libsphinxlm.a /home/shad/
    cmusphinx/trunk/PocketSphinxAndroidDemo/obj/local/armeabi/libpocketsphinx.a
    /home/shad/android/android-ndk-r5/platforms/android-8/arch-arm/usr/lib/libc.so
    /home/shad/android/android-ndk-r5/platforms/android-8/arch-
    arm/usr/lib/libstdc++.so /home/shad/android/android-ndk-r5/platforms/android-8
    /arch-arm/usr/lib/libm.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-rpath-
    link=/home/shad/android/android-ndk-r5/platforms/android-8/arch-arm/usr/lib
    -lsupc++ -o /home/shad/cmusphinx/trunk/PocketSphinxAndroidDemo/obj/local/armea
    bi/libpocketsphinx_jni.so
    /home/shad/cmusphinx/trunk/PocketSphinxAndroidDemo/obj/local/armeabi/libpocket
    sphinx.a(pocketsphinx.o): In function `ps_reinit':
    /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:228
    undefined reference to `logmath_get_base'
    /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:231
    undefined reference to `logmath_free'
    /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:232
    undefined reference to `logmath_init'
    /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:293
    undefined reference to `ptmr_init'

    Many thanks in advance

     
  • Shad Ansari

    Shad Ansari - 2011-01-06

    Figured the compile errors reported above. Changed the order of the libs
    during link:

    LOCAL_STATIC_LIBRARIES := sphinxutil sphinxfe sphinxfeat sphinxlm

    pocketsphinx
    LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil

    Now running into the No JNI_OnLoad method error - which means Im making
    progress!

     
  • Anonymous

    Anonymous - 2011-01-08

    I found the JNI_OnLoad error to be misleading. Once I eliminated the
    JNI_OnLoad error message, the program still (quietly) terminated.

    If you wish to remove the JNI_OnLoad message, try adding a "dummy" function to
    the bottom of pocketsphinx_wrap.c

    int JNI_OnLoad(JavaVM* vm, void* reserved)  
    {  
      return JNI_VERSION_1_4; 
    }
    

    ~~
    I was able to solve the "quiet exit" problem after determining that the
    program failed when attempting to initialize the Decoder object with a Config
    object. If I initialized the decoder without a Config object, the program
    would run. If I sent in the object, the project would fail. I found my problem
    line to be: c.setFloat("-samprate", 8000); inside RecognizerTask.java. once I
    replaced "8000" with "16000", the program loaded. (Don't forget to set the
    language-files & paths)

    Change:

            //c.setFloat("-samprate", 8000);   #Change this to 16000(?)
            c.setFloat("-samprate", 16000);
            c.setInt("-maxhmmpf", 2000);
            c.setInt("-maxwpf", 10);
            c.setInt("-pl_window", 2);
            c.setBoolean("-backtrace", true);
            c.setBoolean("-bestpath", false);
            this.ps = new Decoder(c);
    

    The program now loads. However, moments after clicking the button, it crashes
    again. I've yet to determine if the problem is with this project, my emulator
    or desktop... Basic logcat files are below & I will update when I know
    something!

    http://pastebin.com/1zF64e52 (with JNI_OnLoad
    error)
    http://pastebin.com/TwP2aF2v (without
    JNI_OnLoad error)

    Good Luck!

     
  • Nickolay V. Shmyrev

    was able to solve the "quiet exit" problem after determining that the
    program failed when attempting to initialize the Decoder object with a Config
    object. If I initialized the decoder without a Config object, the program
    would run. If I sent in the object, the project would fail. I found my problem
    line to be: c.setFloat("-samprate", 8000); inside RecognizerTask.java. once I
    replaced "8000" with "16000", the program loaded. (Don't forget to set the
    language-files & paths)

    That was a bad idea which caused your trouble, you need to revert it back as
    it was. I suggest you need to be very careful when you change something in the
    code. Instead, it's better to read the logs to find out real issue.

     
  • Shad Ansari

    Shad Ansari - 2011-01-10

    vlb10, yes I too realized that the JNI_OnLoad error is not related to the
    "quiet exit". In my case, the application is exiting at fe_sigproc.c:399 in
    fe_build_melfilters():

    394 for (j = 0; j < mel_fb->filt_width_; ++j) {
    395 float32 hz, loslope, hislope;
    396
    397 hz = (mel_fb->spec_start_ + j) * fftfreq;
    398 if (hz < freqs || hz > freqs) {
    399 E_FATAL("WTF, %f < %f > %f\n", freqs, hz, freqs);
    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    400 }
    401 loslope = (hz - freqs) / (freqs - freqs);
    402 hislope = (freqs - hz) / (freqs - freqs);

    The stack trace is:

    (gdb) bt

    0 fe_build_melfilters (mel_fb=0x2035c8) at

    /home/shad/cmusphinx/trunk/sphinxbase/src/libsphinxbase/fe/fe_sigproc.c:399

    1 0x80952b78 in fe_init_auto_r (config=0xa43b0)

    at
    /home/shad/cmusphinx/trunk/sphinxbase/src/libsphinxbase/fe/fe_interface.c:248

    2 0x80913002 in acmod_init (config=0xa43b0, lmath=0x203170, fe=0x0, fcb=0x0)

    at /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/acmod.c:252

    3 0x8090d3fc in ps_reinit (ps=0x2030f0, config=0xa43b0)

    at
    /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:248

    4 0x8090d7ec in ps_init (config=0xa43b0) at

    /home/shad/cmusphinx/trunk/pocketsphinx/src/libpocketsphinx/pocketsphinx.c:327

    5 0x8090c052 in new_Decoder__SWIG_1 (c=0xa43b0)

    at
    /home/shad/cmusphinx/trunk/PocketSphinxAndroidDemo/jni/pocketsphinx_wrap.c:843

    6 0x8090cbb2 in

    Java_edu_cmu_pocketsphinx_pocketsphinxJNI_new_1Decoder_1_1SWIG_11
    (jenv=0xaa50, jcls=0x43e449b0,
    jarg1=672688, jarg1_=0x43e44cb8) at /home/shad/cmusphinx/trunk/PocketSphinxAnd
    roidDemo/jni/pocketsphinx_wrap.c:1336

    7 0x80813978 in ?? ()

    The problem seems to be caused by mel_fb->spec_start possibly having an
    invalid value = -1. I have no idea of the internals of sphinx so cannot debug
    intelligently:

    (gdb) p i
    $10 = 33
    (gdb) p mel_fb->spec_start
    $11 = -1 <<<<<<<<<<<<<< looks like an invalid value
    (gdb) p mel_fb->spec_start
    $12 = 253 <<<<<<<<<<<<<< looks like a valid value
    (gdb) p mel_fb->spec_start
    $13 = -1

    (gdb) p *mel_fb
    $17 = {sampling_rate = 8000, num_cepstra = 13, num_filters = 40, fft_size =
    512, lower_filt_freq = 133.333344,
    upper_filt_freq = 6855.49756, mel_cosine = 0x0, filt_coeffs = 0x205240,
    spec_start = 0x203620, filt_start = 0x203678,
    filt_width = 0x2036d0, doublewide = 0, warp_type = 0x204790 "inverse_linear",
    warp_params = 0x0, warp_id = 0,
    sqrt_inv_n = 0, sqrt_inv_2n = 0, lifter_val = 0, lifter = 0x0, unit_area = 1,
    round_filters = 1}

    Im working on this on and off but I will post any progress I make on this. Im
    just trying to run the demo out-of-the box right now - not sure if I need to
    do some configuration, model definition etc before running ?

    -shad
    __

     
  • Shad Ansari

    Shad Ansari - 2011-01-10

    nshmyrev, you mentioned logs. Where can I find the logs from the demo app - Im
    running on Android virtual device?

     
  • Anonymous

    Anonymous - 2011-01-10

    nshmyrev: You sir are correct. Reading the logs is almost always the preferred
    method of troubleshooting. My goal was to load the project in Android, without
    experiencing the "quiet exit". My change accomplished that, but not any
    further.

    sa69:

    As of 20-minutes ago, I was able to compile and successfully run the project.
    While I'm sure there is a much more efficient method, I will try to explain
    the steps I took below.

    1. LogFile:

    The demo project sets the PocketSphinx log file using the following attribute:
    pocketsphinx.setLogfile(). To make life easy, this file path to this log-file
    should be somewhere easily accessible for the Activity, JNI-code and the user.
    I choose to write it to the SD-Card via the following code.

    // Create a path where we will place our private file on external storage
    File file = new File(instance.getExternalFilesDir(null), "pocketsphinx.log");
    pocketsphinx.setLogfile(jniApp.getExternalJNIpath(file.getAbsolutePath()));

    While the Android Virtual Device is running, in a terminal, I can use ADB to
    display the log file:

    adb shell cat
    /mnt/sdcard/Android/data/edu.cmu.pocketsphinx.demo/files/pocketsphinx.log

    If your path is different, add a line similar to the one below to the code to
    write the path into Android's logcat.

    Log.e("vlb10:", "PocketSphinxLog Path is" + file.getAbsolutePath());

    This file can then be accessed by typing "adb logcat" in a terminal window.
    Scan through until you find your entry.

    1. Looking through the Log file, I discovered that the Decoder Config files were not loading as expected. Once I was able correctly access the files referenced in the project, the program ran without issue. There are a few things to consider:

    a) Files placed within Assets aren't readily accessible through the file-
    system.
    b) A few of the files are larger than the 1mb limit
    c) Long-term, different dictionaries / file access will need to be addressed.

    There are a couple ways to address the above situation. I'm not thrilled with
    the method I choose, so I will leave it up for discussion and hope you can
    come up with something better!

    Good Luck!

    -Vic

     
  • Shad Ansari

    Shad Ansari - 2011-01-11

    Vic, that was a big help. The app was exiting because the decoder config files
    were not placed in the right directory on /mnt/sdcard. I was finally able to
    run on AVD but its very very very slow. A bit of a disappointment after all
    that fight. Will try on real device next. Is there something in the config,
    etc to speed things up - like suppressing logging, or relaxing some criteria
    in the decoder...

    -shad

     
  • Mikaandy

    Mikaandy - 2011-01-11

    Hi to everyone,I ask for your help!! I change "c.setFloat("-samprate", 8000)"
    with #Change this to 16000(?) but after I click on the button
    "this.ps.startUtt (); " generate error "Refresh Scope Invalid"!i not
    understand why!

     
  • Anonymous

    Anonymous - 2011-01-11

    That line NEEDS to read "8000" for the program to function properly. By
    changing it, I was able to generate an error before the program aborted,
    allowing me to circumvent the "quiet exit" issue, which in return, allowed me
    to load, (but not run!) the activity. PocketSphinx will fail, unless the value
    is set to "8000".

    In order for detection to work, ALL the config files MUST be loaded properly.
    Once the files are loaded onto the Android Device in a place where
    PocketSphinx can access them, the original code provided will function as-
    expected.

     
  • Mikaandy

    Mikaandy - 2011-01-11

    Thanks for your answer but if..That line NEEDS to read "8000" how can I not
    generate the exception on the call "this.ps = new Decoder(c);"?..thanks

     
  • lloyd89

    lloyd89 - 2011-02-01

    hi i'm new to android apps development.i along with my friends are trying to
    implement a project using pocketsphinx.wanted to know how to start compiling
    pocketsphinx in android ndk.

     
  • Anonymous

    Anonymous - 2011-02-04

    Hi, my demo app exits when clicked on the "Hold and Speak" button. vlb10
    mentioned above that ALL the config files MUST be loaded properly. My question
    is where are the config files and where should I put them? I am using
    Emulator. Thanks!

     
  • Nickolay V. Shmyrev

    rly. My question is where are the config files and where should I put them?
    I am using Emulator. Thanks!

    There is no config files. The application exits because it fails to find the
    model files on path specified in application sources. You can learn more about
    pocketsphinx and model files by reading the tutorial

    http://cmusphinx.sourceforge.net/wiki/tutorial

     
  • Anonymous

    Anonymous - 2011-02-05

    Thanks, I found the model file in "pocketsphinx\model" and where to put them
    under "/sdcard/Android/data/edu.cmu.pocketsphinx/" on sdcard.

     
  • Nickolay V. Shmyrev

    and where to put them under "/sdcard/Android/data/edu.cmu.pocketsphinx/" on
    sdcard.

    See the sources

                   c.setString("-hmm",
                                    "/sdcard/Android/data/edu.cmu.pocketsphinx/hmm/en_US/hub4wsj_sc_8k");
                    c.setString("-dict",
                                    "/sdcard/Android/data/edu.cmu.pocketsphinx/lm/en_US/hub4.5000.dic");
                    c.setString("-lm",
                                    "/sdcard/Android/data/edu.cmu.pocketsphinx/lm/en_US/hub4.5000.DMP");
    
     
  • amal matruk

    amal matruk - 2011-02-20

    Hello,
    i am trying to rub NDK build system through this command in the terminal but I
    get this error:

    amal@ubuntu:~/Desktop/android-ndk-r3$ make apps = PocketSphinx
    make: *** empty variable name. Stop.

    can some one help me please?

     
<< < 1 2 (Page 2 of 2)

Log in to post a comment.