Building PocketSphinxAndroidDemo (from CMUSphinx project)
来源:互联网 发布:tensorflow 图片 编辑:程序博客网 时间:2024/06/05 10:48
This is done with CMUSphinx 0.7 (so sphinxbase 0.7 and pocketsphinx 0.7). The files are archived at the end of the article. The process also require access to a linux machine and the Eclipse IDE.
- Download Sphinx base and pocket sphinx (http://cmusphinx.sourceforge.net/wiki/download/)
- Create a directory somewhere, untar both to ./sphinxbase and ./pocketsphinx (lose the -0.x version suffix)
- For each of the two, do the usual ./autogen.sh ./configure, make, make install (make install require root)
- Check ./pocketsphinx/swig has libpocketsphinx_jni.so in it. If not, do a make in that directory
- Download the PocketSpinxAndroiDemo
- untar it to the same directory created in 2
- cp -r ./pocketsphinx/swig/edu ./PocketSphinxAndroidDemo/jni/
- cd ./PocketSphinxAndroidDemo/jni/
- Update SPHINX_PATH to the directory created in 2
- Open Android.mk, edit LOCAL_STATIC_LIBRARIES from whatever it was before to “pocketsphinx sphinxlm sphinxfeat sphinxfe sphinxutil” (without qoutes)
- Install Android NDK (http://developer.android.com/sdk/ndk/index.html)
- stay in the jni directory, do a ndk-build (see the ndk link about for instructions on building if it is not clear)
Now we are ready to open this in Eclipse
- Open eclipse and import the project, ignore any build warnings/errors
- Untick Project -> Build Automatically (This is personal choice, since the JNI build process is heavy I dont like it building all the time)
- Project -> Properties -> Builders
- Select SWIG -> Edit -> for Working Directory, select Browse Workspace and pick the jni directory, In the Refresh tab, select The folder containing the selected resource, in Build Options, untick Specify working set of relevant resources (This option may be hidden in the dialog, if you dont see it, maximize the Configuration window).
- Select NDK build -> Edit -> Set the correct location for ndk-build, select the correct Working directory (Browse workspace and then select the jni directory). In the Refresh tab, select The project containing the selected resource, in Build Options, untick Specify working set of relevant resources (This option may be hidden in the dialog, if you dont see it, maximize the Configuration window).
- Project -> Build Project. If you see any errors, check that step 4 and 5 are carried out correctly. The project should build without error. A console may appear with red texts, just confirm that they are warning messages from building the c code and you should be ok
We should now have a built Android application ready for testing
- In the emulator (or phone), create under primary storage (whatever is returned by the getExternalStorageDirectory). For example if you have a sdcard this would be /mnt/sdcard
- If using the emulator, call adb shell from a console window, and use mkdir command for the step below (to create directories on the emulator)
- Create directory structure: Android/edu.cmu.pocketsphinx/hmm/en_US/hub4wsj_sc_8k, Android/edu/edu.cmu.pocketsphinx/lm/en_US/
- Copy pocketsphinx/model/hmm/en_US/hub4wsj_sc_8k/* into the emulator/phone
- Copy pocketsphinx/model/lm/en_US/* into emulator/phone
- In eclipse, open the RecognizerTask.java file, look for c.setString(“-lm”
- Make sure the files loaded in the code around step 6 exists (especially the .dict file may have a different name)
- Now we can run the application!
If the app crashes for any reason, go to sdcard/Android/edu.cmu.pocketsphinx and there should be a log file (pocketsphinx.log) from the native library.
Misc thought
- On my machine (OpenSuSE 11.3) the swig directory was empty after make. Go into swig directory and call make, the errors will be displayed (for me it was because I didn’t have swig installed)
- By default make install installs to /usr/local/lib which can cause problems on some systems. If you get errors with any of the sphinx stuff saying some library is not found, use the ldd and strace commands to see where they are looking for the libs, and symlink them. Alternatively supply another install location to make install
- While working in eclipse, if you see any errors along the lines of “Refresh scope invalid”, check step 4 and 5 are carried out from the Eclipse section above.
Files required **Before downloading these archives, try using the latest build from the official website first**:
- Sphinxbase 0.7
- Pocket Sphinx 0.7
- PocketSphinxAndroidDemo
- Building PocketSphinxAndroidDemo (from CMUSphinx project)
- CMUSphinx Learn - Building Language Model
- CMUSphinx Learn - Building application with pocketsphinx
- Android for MSM Project,Downloading and Building from Source
- CMUSphinx
- Building Project Gradle project info
- Xcode 8: issue “file xxx.png is missing from working copy” at project building
- Could not find method android() for arguments when building Android project from gradle
- Error while building project
- building gradle project info
- Building Kernel from source
- Building X10 from Source
- building "your project name" gradle project info
- jenkins-Building a software project
- Building Your Project with Gradle
- Building Your Project with Gradle
- building gradle project info问题
- Error while building/deploying project
- cocos2d-x 中CREATE_FUNC 宏
- 【代码】Android存储数据的5种方式
- A20 nand最大化命令
- 【Rails】Rails程序部署到heroku上无CSS效果的解决办法
- eclipse 打开资源文件所在的文件夹插件
- Building PocketSphinxAndroidDemo (from CMUSphinx project)
- Cocos2d-x开发移植到安卓平台横竖屏设置及相关
- 数据库启动时丢失数据文件模拟实验
- 百度2014招聘笔试解答1
- grep 高级例解
- 主机linux与开发板的连接问题
- PYthon中的元组
- android基础---AsyncTask, 后台执行任务并同步更新前端UI
- linux下md5sum的使用