Search code examples
c#androidxamarinpocketsphinx

Pocket Sphinx for Xamarin Android


I was trying to do a Java Binding on pocketsphinx for its Speech Recognition Features (I used aar method), it seems that i successfully done the Java Binding Part (no errors), but then it crashed after i called:

 Assets assets = new Assets(this);
 File assetDir = assets.SyncAssets();
 SpeechRecognizer recognizer = SpeechRecognizerSetup.DefaultSetup().SetAcousticModel(new File(assetsDir,"sync/en-us-ptm")).SetKeywordThreshold(1e-20f).SetDictionary(new Java.IO.File(assetsDir,"sync/cmudict-en-us.dict")).Recognizer;
 recognizer.AddListener(this);

What i already found is the error is on the line :

 File assetDir = assets.SyncAssets();

Where the SyncAssets() method need Assets.lst. How do I auto generate the Assets.lst like in the : PocketSphinx for Android tutorial or does anyone have any other java binding method that works?

Thank you


Solution

  • So I tried several method, and one working for me is :

    1. Install Android Studio and SDK

    2. Open the pocketsphinx demo project on Android Studio

    3. Make sure all the assets folder for pocketsphinx are the same name and path
    4. Build!
    5. The assets.lst and .md5 files (for each file) are being generated by the Android Studio
    6. Copy those files to the visual studio project
    7. Done!

    And also my method of creating the recognizer is wrong. It should be :

    SpeechRecognizerSetup.DefaultSetup().SetAcousticModel(new File(assetDir,"en-us-ptm")).SetKeywordThreshold(1e-20f).SetDictionary(new Java.IO.File(assetDir,"cmudict-en-us.dict")).Recognizer;
    

    (without sync/)

    Special Note : You have to put all the assets for pocketsphinx on sync folder Click to see the Image