Menu

Pocketsphinx implementation on iOS

Help
2015-11-26
2016-08-27
  • nayan kalita

    nayan kalita - 2015-11-26

    Hi , I am using pocket sphinx for speech recognition in a project. I am using customize pocket sphinx C code to take input speech file in raw PCM format. I am using modifed C program for phoneme recognition. I am able to compile and run succesfully these program in PC and also able to bulid library for this for Anroid System following tutorial from cmu sphinx. Now I am trying to bulid the library for these C program for iOS System. Kindly give me some suggestion create the same library for iOS system.

     
  • nayan kalita

    nayan kalita - 2015-11-28

    Hi,

    I tried to pocketsphinx bulid library for iphone using ./build_iphone.sh and get following errors.

    ld: warning: ignoring file PocketSphinxApp01/Libraries/sphinxbase/arm64/lib/libsphinxbase.dylib, file was built for arm64 which is not the architecture being linked (armv7): PocketSphinxApp01/Libraries/sphinxbase/arm64/lib/libsphinxbase.dylib
    Undefined symbols for architecture armv7:
    "_ps_args", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_cmd_ln_init", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_start_utt", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_get_hyp", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_init", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_end_utt", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_free", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_process_raw", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_cmd_ln_free_r", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    ld: symbol(s) not found for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

     
    • Nickolay V. Shmyrev

      You need to build for specific architecture you want to run on. It is not possible to mix architectures.

       
  • nayan kalita

    nayan kalita - 2015-12-14

    Hi Nickolay,

    Thanks for your suggestion. We followed your suggestion. Our target system architecutres is armv7 and we build the pocketsphinx library for armv7 architecure. while integration i am getting following errors.

    Undefined symbols for architecture armv7:
    "_ps_args", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_cmd_ln_init", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_start_utt", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_get_hyp", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_init", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_end_utt", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_free", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_ps_process_raw", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    "_cmd_ln_free_r", referenced from:
    -[ViewController initPocketSphinx] in ViewController.o
    ld: symbol(s) not found for architecture armv7
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    For your reference here i have attached the ViewController.m file.

     
    • Nickolay V. Shmyrev

      To get help on this problem you'd better provide the full project including xcode files and library you have built.

       
  • nayan kalita

    nayan kalita - 2015-12-15

    Hi Nickolay,

    Thanks for your help. I am sharing the Xcode project files and bulid libraray on the below link.

    https://drive.google.com/folderview?id=0B5r-5MmR-hW7QnJXbjE5TmZMZUU&usp=sharing

     
    • Nickolay V. Shmyrev

      Ok, there are issues on how you organized your project

      1) You should have add library folder into sources, not as reference. Right click on PocketSphinxApp04 and remove reference. Then add them as files, not as reference.

      2) For the library search path you may specify recursive from root folder, there is no need to specify full folder path

      3) Beside adding to the library path you need to link to the libraries. This is an entry Linked frameworks and libraries in Project/General tab. If you do everything properly, libraries will appear there automatically. If you still want references, you can add libraries there.

      You need to make sure that "Link Binaries With Libraries" is also not empty on Project / Build Phases step

      To get more details on this, study documentation:

      http://blog.carbonfive.com/2011/04/04/using-open-source-static-libraries-in-xcode-4/

       
  • nayan kalita

    nayan kalita - 2015-12-23

    Hi Nickolay,

    Thanks for your help. We followed your suggestions and able to bulid, load and run pocketsphinx successfully in iOS Simulator ( architecture is i386.). But when we build pocket sphinx library for iphone (architecture is armv7), we are able to successfully bulid the project. but when we try to load the application on iphone5, getting following error.

    dyld: Library not loaded: /Users/si-lab003/Documents/Dev/PocketSphinx/Temp/sphinxbase/bin/armv7/lib/libsphinxbase.3.dylib
    Referenced from: /private/var/mobile/Containers/Bundle/Application/F7D54467-57C6-40A6-8214-A25EDBEEDACE/PocketSphinxApp05.app/PocketSphinxApp05
    Reason: image not found

    I am sharing the Xcode project files and build library for your reference on the below link.

    https://drive.google.com/folderview?id=0B5r-5MmR-hW7bjhvaWJSVDJxSjQ&usp=sharing

     
    • Nickolay V. Shmyrev

      You can easily find solution in google:

      http://stackoverflow.com/questions/23712201/xcode-5-how-to-linking-dynamic-libraries-from-app-bundle

      You need to add a copy step to copy dynamic libraries into Frameworks folder in application bundle. This is Build Phases tab, you need to add additional "Copy Files" step and copy dylibs there.

       

      Last edit: Nickolay V. Shmyrev 2015-12-24
      • Nickolay V. Shmyrev

        If dynamic linking is too complex for you, you can remove dynamic libraries (dylib extension) and leave only static libraries with extension .a. This is "Linked Frameworks and Libraries" section.

        You also do not need to add la files, binary files and pkg-config files into ios application, you only need headers and static libraries with .a extension.

         
  • Jerry Kalkhof

    Jerry Kalkhof - 2016-08-27

    I ran into problems with dynamic linking in the pocketsphinx build for ios as well.

    I got around it by using static libraries, but I had to delete the following dylib files so XCode wouldn't get confused (and try to link dylib instead)
    (.la, pkginconfig/.pc, *.dylib)

    cmusphinx/pocketsphinx/bin/arm64/lib/libpocketsphinx.3.dylib
    cmusphinx/pocketsphinx/bin/arm64/lib/libpocketsphinx.dylib
    cmusphinx/pocketsphinx/bin/arm64/lib/libpocketsphinx.la
    cmusphinx/pocketsphinx/bin/arm64/lib/pkgconfig/pocketsphinx.pc
    cmusphinx/sphinxbase/bin/arm64/lib/libsphinxad.3.dylib
    cmusphinx/sphinxbase/bin/arm64/lib/libsphinxad.dylib
    cmusphinx/sphinxbase/bin/arm64/lib/libsphinxad.la
    cmusphinx/sphinxbase/bin/arm64/lib/libsphinxbase.3.dylib
    cmusphinx/sphinxbase/bin/arm64/lib/libsphinxbase.dylib
    cmusphinx/sphinxbase/bin/arm64/lib/libsphinxbase.la
    cmusphinx/sphinxbase/bin/arm64/lib/pkgconfig/sphinxbase.pc

    Here are my ios settings as well:
    header search paths
    $PROJECT_DIR/../cmusphinx/pocketsphinx/bin/$CURRENT_ARCH/include
    $PROJECT_DIR/../cmusphinx/sphinxbase/bin/$CURRENT_ARCH/include

    library search paths
    $PROJECT_DIR/../cmusphinx/pocketsphinx/bin/$CURRENT_ARCH/lib
    $PROJECT_DIR/../cmusphinx/sphinxbase/bin/$CURRENT_ARCH/lib

    other link flags
    -lsphinxbase
    -lpocketsphinx

     

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.