Menu

Can't load libpocketsphinx_jni.so

Help
Hitarth
2012-05-18
2012-09-22
  • Hitarth

    Hitarth - 2012-05-18

    Hi,

    In my PocketSphinxDemo activity the following bit of the code is what seems to
    be making my demo stop almost straight after it starts with a message saying
    "Unfortunately PocketSphinxDemo has stopped" coming up on the tablet.

    static {
    try{
    System.loadLibrary("pocketsphinx_jni");
    Log.e("JNI", "CONGRATULATIONS: Loaded library successfully!");
    }catch(UnsatisfiedLinkError use){
    Log.e("JNI", "WARNING: Could not load libpocketsphinx_jni.so");
    }
    }

    I understand that its looking for the library libpocketsphinx_jni.so but the
    path that its looking at is
    /data/data/edu/cmu/pocketsphinx/demo/lib/libpocketsphix_jni.so

    However, when I went and looked inside the PocketSphinxDemo.apk the
    library(libpocketsphinx_jni.so) is actually located in the libs folder inside
    the apk, not in the
    /data/data/edu/cmu/pocketsphinx/demo/lib/libpocketsphix_jni.so.

    So I tried to change the path it looks at for the library to,
    /data/data/lib/libpocketsphix_jni.so but that doesn't seem to make any
    difference either.

    My question is, how can I redirect it to that lib folder that is inside the
    apk in order to find the library?

    Please let me know if any more clarification is needed.

    Cheers

     
  • bic-user

    bic-user - 2012-05-18

    Hi there. /data/data/edu/cmu/pocketsphinx/demo/lib/libpocketsphix_jni.so - is
    a path on your phone after apk will be installed. don't take care of that. If
    you built pocketsphinx with NDK correctly it will be automatically located
    there. Be more careful at the build part. Are you shure you compiled your code
    without errors? Also take a look on builders screen. check if you feel the
    required fields correctly and put flags in checkboxes near NDK and SWIG. Hope
    this helps.

     
  • Hitarth

    Hitarth - 2012-05-18

    Hi Bic-User,

    I just wanted to ascertain that the libpocketsphinx_jni.so file was actually
    there and it is. However, I still get the message saying that it can't be
    loaded.

    However, the point that you mention about taking care during the building part
    is an interesting one as I noticed that when the application is doing the NDK
    build, 2 warnings pop up in red (I am using Eclipse btw). The problem though
    is that before I can see what the error is, the console switched to the one
    where it show the deployment progress of PocketSphinxDemo.apk.

    Have you got any suggestions about that?

    Cheers

     
  • bic-user

    bic-user - 2012-05-18

    no. I mean build progress from terminal after the-path-to-your-ndk-folder/ndk-
    build -B you are using this tutorial:
    http://cmusphinx.sourceforge.net/2011/05/building-pocketsphinx-on-
    android/
    ???

     
  • Hitarth

    Hitarth - 2012-05-18

    Oh I see what you mean. Well i did the ndk-build again and got the following
    output:

    hsha077@ubuntu:~/se700p4p/PocketSphinxDemo/jni$ ~/android-ndk-r8/ndk-build -B
    Gdbserver      : [arm-linux-androideabi-4.4.3] libs/armeabi/gdbserver
    Gdbsetup       : libs/armeabi/gdb.setup
    Compile thumb  : pocketsphinx_jni <= pocketsphinx_wrap.c
    /home/hsha077/se700p4p/PocketSphinxDemo/jni/pocketsphinx_wrap.c: In function 'Java_edu_cmu_pocketsphinx_pocketsphinxJNI_Decoder_1processRaw_1_1SWIG_10':
    /home/hsha077/se700p4p/PocketSphinxDemo/jni/pocketsphinx_wrap.c:1441: warning: assignment discards qualifiers from pointer target type
    Compile thumb  : sphinxutil <= bio.c
    Compile thumb  : sphinxutil <= bitvec.c
    Compile thumb  : sphinxutil <= case.c
    Compile thumb  : sphinxutil <= ckd_alloc.c
    Compile thumb  : sphinxutil <= cmd_ln.c
    Compile thumb  : sphinxutil <= dtoa.c
    Compile thumb  : sphinxutil <= err.c
    Compile thumb  : sphinxutil <= errno.c
    Compile thumb  : sphinxutil <= f2c_lite.c
    Compile thumb  : sphinxutil <= filename.c
    Compile thumb  : sphinxutil <= genrand.c
    Compile thumb  : sphinxutil <= glist.c
    Compile thumb  : sphinxutil <= hash_table.c
    Compile thumb  : sphinxutil <= heap.c
    Compile thumb  : sphinxutil <= huff_code.c
    Compile thumb  : sphinxutil <= info.c
    Compile thumb  : sphinxutil <= listelem_alloc.c
    Compile arm    : sphinxutil <= logmath.c
    Compile thumb  : sphinxutil <= matrix.c
    Compile thumb  : sphinxutil <= mmio.c
    Compile thumb  : sphinxutil <= pio.c
    Compile thumb  : sphinxutil <= profile.c
    Compile thumb  : sphinxutil <= sbthread.c
    Compile thumb  : sphinxutil <= strfuncs.c
    Compile thumb  : sphinxutil <= utf8.c
    StaticLibrary  : libsphinxutil.a
    Compile arm    : sphinxfe <= fe_interface.c
    Compile arm    : sphinxfe <= fe_sigproc.c
    Compile arm    : sphinxfe <= fe_warp_affine.c
    Compile arm    : sphinxfe <= fe_warp.c
    Compile arm    : sphinxfe <= fe_warp_inverse_linear.c
    Compile arm    : sphinxfe <= fe_warp_piecewise_linear.c
    Compile arm    : sphinxfe <= fixlog.c
    StaticLibrary  : libsphinxfe.a
    Compile thumb  : sphinxfeat <= agc.c
    Compile thumb  : sphinxfeat <= cmn.c
    Compile thumb  : sphinxfeat <= cmn_prior.c
    Compile thumb  : sphinxfeat <= feat.c
    Compile thumb  : sphinxfeat <= lda.c
    StaticLibrary  : libsphinxfeat.a
    Compile thumb  : sphinxlm <= fsg_model.c
    Compile thumb  : sphinxlm <= jsgf.c
    Compile thumb  : sphinxlm <= jsgf_parser.c
    Compile thumb  : sphinxlm <= jsgf_scanner.c
    Compile thumb  : sphinxlm <= lm3g_model.c
    Compile thumb  : sphinxlm <= ngram_model_arpa.c
    Compile thumb  : sphinxlm <= ngram_model_dmp.c
    Compile thumb  : sphinxlm <= ngram_model_set.c
    Compile thumb  : sphinxlm <= ngram_model.c
    StaticLibrary  : libsphinxlm.a
    Compile thumb  : pocketsphinx <= acmod.c
    Compile thumb  : pocketsphinx <= bin_mdef.c
    Compile thumb  : pocketsphinx <= blkarray_list.c
    Compile thumb  : pocketsphinx <= dict.c
    Compile thumb  : pocketsphinx <= dict2pid.c
    Compile thumb  : pocketsphinx <= fsg_history.c
    Compile thumb  : pocketsphinx <= fsg_lextree.c
    Compile thumb  : pocketsphinx <= fsg_search.c
    Compile arm    : pocketsphinx <= hmm.c
    Compile thumb  : pocketsphinx <= mdef.c
    Compile arm    : pocketsphinx <= ms_gauden.c
    Compile arm    : pocketsphinx <= ms_mgau.c
    Compile arm    : pocketsphinx <= ms_senone.c
    Compile thumb  : pocketsphinx <= ngram_search.c
    Compile thumb  : pocketsphinx <= ngram_search_fwdtree.c
    Compile thumb  : pocketsphinx <= ngram_search_fwdflat.c
    Compile thumb  : pocketsphinx <= phone_loop_search.c
    Compile thumb  : pocketsphinx <= pocketsphinx.c
    Compile thumb  : pocketsphinx <= ps_lattice.c
    Compile thumb  : pocketsphinx <= ps_mllr.c
    Compile arm    : pocketsphinx <= ptm_mgau.c
    Compile arm    : pocketsphinx <= s2_semi_mgau.c
    Compile thumb  : pocketsphinx <= tmat.c
    Compile thumb  : pocketsphinx <= vector.c
    StaticLibrary  : libpocketsphinx.a
    SharedLibrary  : libpocketsphinx_jni.so
    Install        : libpocketsphinx_jni.so => libs/armeabi/libpocketsphinx_jni.so
    

    The only out of place thing I can spot is the warning on top.. but even that
    doesn't make too much sense to me.

    /home/hsha077/se700p4p/PocketSphinxDemo/jni/pocketsphinx_wrap.c:1441: warning: assignment discards qualifiers from pointer target type
    
     
  • bic-user

    bic-user - 2012-05-18

    yeah. seems to be ok. Are you sure you configured SWIG and NDK build
    properly?? did you put checks near them? Try to make this part again:

    In the Navigator View look for PocketSphinxDemo project. Right click on it and select properties. The properties screen will pop up and you will need to select Builders. In the Builders screen you will see SWIG and NDK build.
    
    Click on NDK build and edit.
    
    In the edit screen change the field Location to point to your ndk-folder you have on your machine. Click on the Refresh tab and select The project containing the selected resource
    Click on the Build Options tab and deselect Specify working set of relevant resources
    Apply changes and exit the configuration for NDK build.
    
    Click on SWIG and edit.
    
    You will not need to change the Location since downloaded swig at the start of the tutorial.
    In the refresh tab select The folder containing the selected resource
    In the Build Options tab deselect Specifiy working set of relevant resources
    Apply changes and exit the configuration for SWIG.
    

    if that doesn't help, upload please your project...

     
  • Hitarth

    Hitarth - 2012-05-20

    Sorry for the late reply. I configured them as per the paragraph that you
    pasted from the tutorial thats why I cant seem to figure out what is going
    wrong.

    How and what checks can I put near them?

    Here is a link to my compressed project:

    [url]https://www.dropbox.com/s/nfnnhne9vt14kt3/Bl00dr3d%28PocketSphinxDemo%29.tar.gz[/url]
    

    Its a 3.2 mb tar.gz file which when uncompressed is around 10.3 mb in size.

    Please have a look and let me know what I can do to get this deom up and
    running.

    Cheers!

     
  • bic-user

    bic-user - 2012-05-21

    You are missing libpocketsphinx_jni.so in the /libs/armeabi. You haven't
    compiled sources with ndk in a right way. You need to do all the tutorial from
    the very beginning and to change 162 line of Android.mk. There should be

    LOCAL_STATIC_LIBRARIES := pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil
    

    over there.

     
  • Hitarth

    Hitarth - 2012-05-21

    Hi Bic-user

    libpocketsphinx_jni.so is present in the libs/armeabi directory in the
    PocketSphinxDemo folder.

    However, the order of the static libraries was different so I have changed it
    to make it look like what you have got there.

    I just zipped up my demo folder and sent it to you so are you sure that
    PocketSphinxDemo/libs/armeabi/libpocketsphinx_jni.so doesnt exist?

    Cheers

     
  • Hitarth

    Hitarth - 2012-05-21

    The following screenshot shows that the lib does exist in that folder. I went
    and looked for it straight after I saw your post so I did not build the
    project or do anything like that:

    [url]http://tinypic.com/r/2vblk6x/6[/url]
    
     
  • Hitarth

    Hitarth - 2012-05-21

    I just changed the Android.mk file as you suggested and on running the demo
    again, got the same problem.

    I will try to re do the whole thing and get back to you but I doubt I will get
    a different result.

    In the mean time, let me know if you come up with anything else.

    Cheers

     
  • bic-user

    bic-user - 2012-05-21

    No. you need to redo everything with changing Android.mk I suggested. It's
    working OK. You just need to be accurate.
    1) download Pocketsphinx demo
    2) change Android,mk lines 162 and 5
    3) build c-source with ndk
    4) change builders setting in eclipse
    5) push models on the cell.

     
  • Hitarth

    Hitarth - 2012-05-22

    Thank you so much bic-user! You are a life saver.

    I did everything that you said in those 5 steps above and then carefully did
    the last part of the tutorial about changing some of the hardcoded paths in
    the RecognizerTask.java.

    Thats when I realized that I missed out on that part the first time round
    because it just looks so similar to whats in the code:

    There are declared paths to a structure that is not valid on a 2.2 phone. We will need to change the paths so that they work correctly. Here is my code for the section.
    
    
    pocketsphinx.setLogfile("/mnt/sdcard/edu.cmu.pocketsphinx/pocketsphinx.log");
    Config c = new Config();
    /*
    * In 2.2 and above we can use getExternalFilesDir() or whatever it's called
    */
    c.setString("-hmm", "/mnt/sdcard/edu.cmu.pocketsphinx/hmm/en_US/hub4wsj_sc_8k");
    c.setString("-dict", "/mnt/sdcard/edu.cmu.pocketsphinx/lm/en_US/hub4.5000.dic");
    c.setString("-lm", "/mnt/sdcard/edu.cmu.pocketsphinx/lm/en_US/hub4.5000.DMP");
    c.setString("-rawlogdir", "/mnt/sdcard/edu.cmu.pocketsphinx"); // Only use it to store the audio
    
    If your model is different, you will have to use different paths, for example fo rthe mandarin model
    
    c.setString("-hmm", "/sdcard/Android/data/edu.cmu.pocketsphinx/hmm/zh/tdt_sc_8k");
    c.setString("-dict", "/sdcard/Android/data/edu.cmu.pocketsphinx/lm/zh_TW/mandarin_notone.dic");
    c.setString("-lm", "/sdcard/Android/data/edu.cmu.pocketsphinx/lm/zh_TW/gigatdt.5000.DMP");
    

    The part above changes the hardcoded paths in the code that used to work well
    till Android 2.2, in order to make them work for the later versions.

    That was what I overlooked due to which my model and all the other things were
    in the wrong place.

    Thank you so much for your help!

    However, I noticed that in the models folder, there are 2 other folder, en and
    zh. Are those folders for different languages?

    I used the PocketSphinxDemo and found that it was extremely inaccurate for
    me(probably since I have a slight Kiwi accent). Do you reckon that using the
    en model might work better?

    Also is there any documentation on how I can create my own english language
    model but with only like 50 or so words?

    Cheers

     
  • bic-user

    bic-user - 2012-05-22

    Are those folders for different languages?

    Do you reckon that using the en model might work better?

    Don't ask. try. it depends.

    Also is there any documentation on how I can create my own english language
    model but with only like 50 or so words?

    http://cmusphinx.sourceforge.net/wiki/tutoriallm. But you better should learn whole wiki.

    For new question start new thread.

     
  • bic-user

    bic-user - 2012-05-22

    "Do you reckon that using the en model might work better?"

    Don't ask. try. it depends.

    Sorry. en is for digits. Anyway you can find other models on the project site.

     
  • Hitarth

    Hitarth - 2012-05-27

    Thanks! Really appreciate it mate.

     

Log in to post a comment.