android-studiopocketsphinx

Importing PocketSphinx resources into Android Studio


I am trying to start a project using PocketSphinx resources. What is the method for importing PocketSphinx resources into my Android Studio workspace?

import edu.cmu.pocketsphinx.Assets; //"unused import statement"
import edu.cmu.pocketsphinx.Hypothesis; //"unused import statement"
import edu.cmu.pocketsphinx.RecognitionListener; //"unused import statement"
import edu.cmu.pocketsphinx.SpeechRecognizer; //"unused import statement"
import edu.cmu.pocketsphinx.SpeechRecognizerSetup; //"unused import statement"

 public class MainActivity extends AppCompatActivity implements RecognitionListener {...

As expected, I am getting a, "Cannot resolve symbol 'RecognitionListener' " on the last line. Thanks in advance.


Solution

  • The library is distributed as an Android Archive (AAR). Download from https://github.com/cmusphinx/pocketsphinx-android-demo/blob/master/aars/pocketsphinx-android-5prealpha-release.aar

    Move pocketsphinx-android-5prealpha-release.aar into helloworld/app/lib/ directory.

    In Android Studio go to File > New > New module, scroll down and choose Import .JAR/.AAR Package. Browse to /app/lib and select the .aar file. Click "Okay". Keep the apps module selected, click dependencies tab, click "+" on far right side, choose "Module Dependency". Select Module and click "Okay". For further information go to How to manually include external aar package using new Gradle Android Build System, scroll to Oliver Kranz's answer for nice screen grabs of the process.