13 package ai.picovoice.rhino;
16 import java.io.IOException;
17 import java.util.LinkedHashMap;
58 public Rhino(String accessKey, String libraryPath, String modelPath, String contextPath,
float sensitivity,
boolean requireEndpoint)
throws RhinoException {
61 System.load(libraryPath);
62 }
catch (Exception exception) {
65 libraryHandle =
init(accessKey, modelPath, contextPath, sensitivity, requireEndpoint);
71 public void delete() {
107 String[] parts = intentPacked.split(
",");
108 if (parts.length == 0) {
109 throw new RhinoException(String.format(
"Failed to retrieve intent from '%s'.", intentPacked));
112 Map<String, String> slots =
new LinkedHashMap<>();
113 for (
int i = 1; i < parts.length; i++) {
114 String[] slotAndValue = parts[i].split(
":");
115 if (slotAndValue.length != 2) {
116 throw new RhinoException(String.format(
"Failed to retrieve intent from '%s'.", intentPacked));
118 slots.put(slotAndValue[0], slotAndValue[1]);
161 private native
long init(String accessKey, String modelPath, String contextPath,
float sensitivity,
boolean requireEndpoint);
163 private native
void delete(
long object);
165 private native
boolean process(
long object,
short[] pcm);
169 private native String
getIntent(
long object);
171 private native
boolean reset(
long object);
178 public static class Builder {
224 if (!Utils.isEnvironmentSupported()) {
226 "Execution environment not currently supported by Rhino Java.");
234 if (Utils.isResourcesAvailable()) {
238 "provide a native Rhino library path (-l <library_path>).");
247 if (Utils.isResourcesAvailable()) {
251 "valid Rhino model path (-m <model_path>).");
268 if (sensitivity < 0 || sensitivity > 1) {