setContextPath() not found

All we need is an easy explanation of the problem, so here it is.

I am trying to use the library Porcupine on Android. I have now downloaded a Rhino context file (.rhn) but can’t find a way how to implement that file into my code.

The documentation says that I should use setContextPath() but this gives me the error:

Cannot resolve method ‘setContextPath’ in ‘Builder’

That’s how I tried it:

try {
    porcupineManager = new PorcupineManager.Builder()
            .setModelPath("porcupine_params_de.pv")
            .setAccessKey(ACCESS_KEY)
            .setKeywordPath("my_file_de_android_v2_0_0.ppn")
            .setContextPath("my_file_de_android_v2_0_0.rhn");
            .setSensitivity(0.7f).build(
                    getApplicationContext(),
                    porcupineManagerCallback);
    porcupineManager.start();
}
...

I don’t know what this method is good for since I can’t even find it in its class.

So how can I use my .rhn file?

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

In the sample code from the link you provide, this method is called on different class:

PicovoiceManager picovoiceManager = new PicovoiceManager.Builder()
  .setAccessKey("${ACCESS_KEY}")
  .setKeywordPath("${KEYWORD_FILE_PATH}")
  .setWakeWordCallback(wakeWordCallback)
  .setContextPath("${CONTEXT_FILE_PATH}")
  .setInferenceCallback(inferenceCallback)
  .build(context);

you use PorcupineManager while sample code uses PicovoiceManager.

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply