Pocketsphinxadroid offline speech recognition-getting started

Source: Internet
Author: User
Tags builtin
From: http://www.myexception.cn/mobile/425918.htmlpocketsphinxadroidvoice recognition ---getting started

Most of today's speech recognition is based on server-side development and can work well only with network support.
To develop a client-based recognition service that can be identified without the need for a network.
It can be used in various applications of the client. If a game is used for voice control, it will not be affected by the network.
I found something open-source...
It can recognize English and Chinese characters.

 

 

 

 

Pocketsphexample --- what is it?
This is the latest source code for the language recognition system developed by Microsoft researchers for embedded devices. It inherits the advantages of the excellent speech recognition software sphinx and is used to develop applications on embedded systems.

How?
Package these C source programs into. So and call the C interface in Java for speech recognition.

First download a pocketsphinxandroiddemo

Https://nodeload.github.com/cjac/cmusphinx/zipball/trunk

Description

Http://ucla.jamesyxu.com /? P = 118

 

Download a swig --- convert the C interface to Java and generate a Java class.

 

Download an ndk and Package C into A. So file.

 

 

 

This is done with cmusph00000.7 (So sphinxbase 0.7 and pocketsph00000.7). The files are archived at the end of the article. The process also require access to a Linux machine and the Eclipse IDE.

  1. Download sphsf-base and pocket sphinx (http://cmusphinx.sourceforge.net/wiki/download)
  2. Create a directory somewhere, untar both to./sphinxbase and./pocketsphinx (lose the-0.x version suffix)
  3. For each of the two, do the usual./autogen. Sh./configure, make, make install (make install require root)
  4. Check./pocketsphinx/swig has libpocketsphinx_jni.so in it. If not, do a make in that directory
  5. Download the pocketspinxandroidemo
  6. Untar it to the same directory created in 2
  7. CP-R./pocketsphinx/swig/EDU./pocketsphinxandroiddemo/JNI/
  8. CD./pocketsphinxandroiddemo/JNI/
  9. Update sphinx_path to the directory created in 2
  10. Open Android. mk, edit local_static_libraries from whatever it was before to "pocketsph?sphinxlm sphinxfeat sphinxfe sphinxutil" (without qoutes)
  11. Install Android ndk (http://developer.android.com/sdk/ndk/index.html)
  12. 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

  1. Open eclipse and import the project, ignore any build warnings/errors
  2. Untick project-> build automatically (this is personal choice, since the JNI build process is heavy I dont like it building all the time)
  3. Project-> properties-> builders
  4. 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 ).
  5. 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 ).
  6. Project-> build project. if you see any errors, check that step 4 and 5 are carried out correctly. the project shocould build without error. A console may appear with red texts, just confirm that they are warning messages from building the C code and you
    Shocould be OK

We shoshould now have a built Android Application ready for testing

  1. In the emulator (or phone), create under primary storage (whatever is returned by the getexternalstoragedirectory). For example if you have a sdcard this wocould be/mnt/sdcard
  2. 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)
  3. Create directory structure: Android/EDU. CMU. pocketsphinx/HMM/en_us/hub4wsj_ SC _8k, Android/edu/EDU. CMU. pocketsphinx/lm/en_us/
  4. Copy pocketsphinx/model/HMM/en_us/hub4wsj_ SC _8k/* Into the emulator/phone
  5. Copy pocketsphator/model/lm/en_us/* into emulator/phone
  6. In eclipse, open the recognizertask. Java file, look for C. setstring ("-lm"
  7. Make sure the files loaded in the code around step 6 exists (especially the. dict file may have a different name)
  8. Now we can run the application!

If the app crashes for any reason, go to sdcard/Android/EDU. CMU. pocketsphinx and there shoshould 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 installto/usr/local/lib which can cause problems on some systems. if you get errors with any of the sphsf-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 sph00000.7
  • Pocketsphinxandroiddemo

 

 

The following APK. Demo is in Chinese. [Speaking of China, the United States, and the United Kingdom] well recognized, but said something else. Haha ,,,

 

 

 

If you are interested, study together, and have questions or contacts.

 

 

Related information:

Http://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/

 

Project sharing: https://github.com/cjac/cmusphinx

Voice model: http://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/

Lcfeng1982 on the first floor 2012-02-02 could you tell me how to compile the project using cygwin in win7? After compilation several times, I failed to generate the libpocketsphinx_jni.so file, and an error was reported during make under the swig file:
Mkdir-P edu/CMU/pocketsphinx
Swig-I ../include-I.../sphinxbase/include \
-Java-package edu. CMU. pocketsphinx \
-Outdir edu/CMU/pocketsph?pocketsph=. I
CC-g-wall-dpic-FPIC-I/usr/lib/JVM/default-Java/include 'pkg-config -- cflags sphinxbase pocketsphsecret'-c-o pocketsphinx_wrap.o pocketsphinx_wrap.c
Package sphinxbase was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'sphinxbase. pc'
To the pkg_config_path environment variable
No package 'sphinxbase' found
Package pocketsph?was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'pocketsphworkflow. pc'
To the pkg_config_path environment variable
No package 'pocketsphsecret' found
Pocketsphinx_wrap.c: 1: 0: Warning:-FPIC ignored for target (all code is position independent)
Pocketsphinx_wrap.c: 760: 26: Fatal error: pocketsphworkflow. h: no such file or directory
Compilation terminated.
<Builtin>: recipe for target 'pocketsph?_ wrap. o' failed
Make: *** [pocketsphinx_wrap.o] Error 12 floor leiwuluan 2012-02-07 you can configure the full path on the third floor leiwuluan 2012-02-07. You can configure the full path.
For example: C:/work_space/sphinxbase/include4 floor lcfeng1982 2012-02-08 leiwuluan writes that you can configure the full path.
For example: C:/work_space/sphinxbase/include

Daniel, I have solved this problem. I tried it and the recognition accuracy rate is very low. As you said, "[Speaking of China, the United States, and the United Kingdom] is very well recognized ", other words won't work. To improve the recognition rate, I have searched the internet for a long time and have not found any valuable information. I think I should be able to establish my own word library to improve the recognition rate, do you have any experience in this area?

On the 5th floor, cs3230524 2012-04-20 the landlord knows Chinese characters and garbled characters. How can this problem be solved? Leiwuluan 2012-05-04 lcfeng1982 on the 6th floor wrote: Could you tell me how to compile the project using cygwin in win7? After compilation several times, I failed to generate the libpocketsphinx_jni.so file, and an error was reported during make under the swig file:
Mkdir-P edu/CMU/pocketsphinx
Swig-I ../include-I.../sphinxbase/include \
-Java-package edu. CMU. pocketsphinx \
-Outdir edu/CMU/pocketsph?pocketsph=. I
CC-g-wall-dpic-FPIC-I/usr/lib/JVM/default-Java/include 'pkg-config -- cflags sphinxbase pocketsphsecret'-c-o pocketsphinx_wrap.o pocketsphinx_wrap.c
Package sphinxbase was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'sphinxbase. pc'
To the pkg_config_path environment variable
No package 'sphinxbase' found
Package pocketsph?was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'pocketsphworkflow. pc'
To the pkg_config_path environment variable
No package 'pocketsphsecret' found
Pocketsphinx_wrap.c: 1: 0: Warning:-FPIC ignored for target (all code is position independent)
Pocketsphinx_wrap.c: 760: 26: Fatal error: pocketsphworkflow. h: no such file or directory
Compilation terminated.
<Builtin>: recipe for target 'pocketsph?_ wrap. o' failed
Make: *** [pocketsphinx_wrap.o] Error 1

Your path has a problem. On the 7th floor, leiwuluan 2012-05-04 leiwuluan wrote lcfeng1982. Could you tell me how to compile the project using cygwin in win7? After compilation several times, I failed to generate the libpocketsphinx_jni.so file, and an error was reported during make under the swig file:
Mkdir-P edu/CMU/pocketsphinx
Swig-I ../include-I.../sphinxbase/include \
-Java-package edu. CMU. pocketsphinx \
-Outdir edu/CMU/pocketsph?pocketsph=. I
CC-g-wall-dpic-FPIC-I/usr/lib/JVM/default-Java/include 'pkg-config -- cflags sphinxbase pocketsphsecret'-c-o pocketsphinx_wrap.o pocketsphinx_wrap.c
Package sphinxbase was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'sphinxbase. pc'
To the pkg_config_path environment variable
No package 'sphinxbase' found
Package pocketsph?was not found in the PKG-config search path.
Perhaps you shoshould Add the directory containing 'pocketsphworkflow. pc'
To the pkg_config_path environment variable
No package 'pocketsphsecret' found
Pocketsphinx_wrap.c: 1: 0: Warning:-FPIC ignored for target (all code is position independent)
Pocketsphinx_wrap.c: 760: 26: Fatal error: pocketsphworkflow. h: no such file or directory
Compilation terminated.
<Builtin>: recipe for target 'pocketsph?_ wrap. o' failed
Make: *** [pocketsphinx_wrap.o] Error 1

Your path has problems ,,

Write a full path .. For example, D:/workspace/project/android_deom

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.