I am trying to implement Speech Recognition using Pocket Sphinx Library .
What was my approach
I just downloaded their demo project for Android. Imported it into Eclipse, cleaned it up, and ran it on the device. He worked successfully.
After that, I copied the libs folder from the demo project to my own project. I copied the contents of the assets folder as it is in my own project. Then I edited the contents of the digits.gram file according to this post .
Then implemented Listener in my activity and added addKeywordSearch to it.
My questions:
Is this approach right for implementing this library in our own projects? Can we just copy all the files, change the .gram files as needed and run it? Or do we need to take several other steps to create .gram files?
When I tried to use the above approach, the project successfully ran several times on the device. But after that, he began to show the following error.
E/cmusphinx(10470): ERROR: "kws_search.c", line 158: The word '/1e-20/' is missing in the dictionary E/AndroidRuntime(10470): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.uwemo.myvdemo/com.uwemo.myvdemo.MainActivity}: java.lang.RuntimeException: Decoder_setSearch returned -1
However, /1e-20/ exists in my digits.gram file.
digits.gram file contents:
up /1e-20/ down /1e-15/ left /1e-15/ right /1e-15/ here /1e-15/
I noticed one thing: when I make a clean build of the Pocket Sphinx demo project and run it, it updates the digits.gram.md5 files. But when I copied everything into my project and made it cleant-build, these files were not recreated. This is normal?
Do I need to have all the files in our project, as in a demo project? Or can I delete some unused files from my own project? Any list of necessary files (either in the resource folder, or in libraries or others) will be very useful.
Please let me know which approach should I successfully implement in my own project.
My activity code
public class MainActivity extends Activity implements RecognitionListener{ private static final String DIGITS_SEARCH = "digits"; private SpeechRecognizer recognizer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); try { Assets assets = new Assets(MainActivity.this); File assetDir = assets.syncAssets(); setupRecognizer(assetDir); Toast.makeText(getApplicationContext(), "Speech Recognizer Started", Toast.LENGTH_SHORT).show(); } catch (IOException e){ e.printStackTrace(); } } @Override public void onBeginningOfSpeech() {
My project structure is consistent

java android pocketsphinx pocketsphinx-android
Dark Drake Jul 21 '15 at 15:04 2015-07-21 15:04
source share