Skip to content

Commit

Permalink
release
Browse files Browse the repository at this point in the history
  • Loading branch information
laves committed Jul 20, 2023
1 parent 005425b commit 29d6459
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 51 deletions.
2 changes: 1 addition & 1 deletion binding/android/Rhino/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
classpath 'ai.picovoice:android-voice-processor:1.0.1'
classpath 'ai.picovoice:android-voice-processor:1.0.2'
}
}

Expand Down
4 changes: 2 additions & 2 deletions binding/android/Rhino/rhino/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'com.android.library'

ext {
PUBLISH_GROUP_ID = 'ai.picovoice'
PUBLISH_VERSION = '2.2.1'
PUBLISH_VERSION = '2.2.2'
PUBLISH_ARTIFACT_ID = 'rhino-android'
}

Expand Down Expand Up @@ -35,7 +35,7 @@ if (file("${rootDir}/publish-mavencentral.gradle").exists()) {
}

dependencies {
implementation "ai.picovoice:android-voice-processor:1.0.1"
implementation "ai.picovoice:android-voice-processor:1.0.2"
}

task copyLibs(type: Copy) {
Expand Down
2 changes: 1 addition & 1 deletion demo/android/Activity/rhino-activity-demo-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ dependencies {
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.google.code.gson:gson:2.10'
implementation 'ai.picovoice:rhino-android:2.2.1'
implementation 'ai.picovoice:rhino-android:2.2.2'

// Espresso UI Testing
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
package ai.picovoice.rhinodemo;

import android.Manifest;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.util.Log;
Expand All @@ -35,59 +34,26 @@
import java.util.Map;
import java.util.Objects;

import ai.picovoice.rhino.*;
import ai.picovoice.rhino.RhinoActivationException;
import ai.picovoice.rhino.RhinoActivationLimitException;
import ai.picovoice.rhino.RhinoActivationRefusedException;
import ai.picovoice.rhino.RhinoActivationThrottledException;
import ai.picovoice.rhino.RhinoException;
import ai.picovoice.rhino.RhinoInference;
import ai.picovoice.rhino.RhinoInvalidArgumentException;
import ai.picovoice.rhino.RhinoManager;
import ai.picovoice.rhino.RhinoManagerCallback;
import ai.picovoice.rhino.RhinoManagerErrorCallback;


public class MainActivity extends AppCompatActivity {
private static final String ACCESS_KEY = "${YOUR_ACCESS_KEY_HERE}"; // AccessKey obtained from Picovoice Console (https://console.picovoice.ai/)

private String contextName = "";

private ToggleButton recordButton;
private TextView contextNameTextView;
private Button cheatSheetButton;
private TextView intentTextView;
private TextView errorTextView;
private Guideline errorGuideline;
private RhinoManager rhinoManager;

private void initRhino() {
try {
RhinoManager.Builder builder = new RhinoManager.Builder()
.setAccessKey(ACCESS_KEY)
.setContextPath("contexts/" + contextName + ".rhn")
.setSensitivity(0.25f)
.setErrorCallback(rhinoManagerErrorCallback);

String model;
if (Objects.equals(BuildConfig.FLAVOR, "en")) {
model = "rhino_params.pv";
} else {
model = "rhino_params_" + BuildConfig.FLAVOR + ".pv";
}
builder.setModelPath("models/" + model);

rhinoManager = builder.build(getApplicationContext(), rhinoManagerCallback);

Log.i("RhinoManager", rhinoManager.getContextInformation());
} catch (RhinoInvalidArgumentException e) {
onRhinoError(
String.format(
"%s\nMake sure your AccessKey '%s' is a valid access key.",
e.getMessage(),
ACCESS_KEY));
} catch (RhinoActivationException e) {
onRhinoError("AccessKey activation error");
} catch (RhinoActivationLimitException e) {
onRhinoError("AccessKey reached its device limit");
} catch (RhinoActivationRefusedException e) {
onRhinoError("AccessKey refused");
} catch (RhinoActivationThrottledException e) {
onRhinoError("AccessKey has been throttled");
} catch (RhinoException e) {
onRhinoError("Failed to initialize Porcupine " + e.getMessage());
}
}

private final RhinoManagerCallback rhinoManagerCallback = new RhinoManagerCallback() {
@Override
public void invoke(final RhinoInference inference) {
Expand Down Expand Up @@ -118,7 +84,8 @@ public void run() {
});
}
};

private TextView errorTextView;
private Guideline errorGuideline;
private final RhinoManagerErrorCallback rhinoManagerErrorCallback = new RhinoManagerErrorCallback() {
@Override
public void invoke(final RhinoException error) {
Expand All @@ -130,6 +97,45 @@ public void run() {
});
}
};
private RhinoManager rhinoManager;

private void initRhino() {
try {
RhinoManager.Builder builder = new RhinoManager.Builder()
.setAccessKey(ACCESS_KEY)
.setContextPath("contexts/" + contextName + ".rhn")
.setSensitivity(0.25f)
.setErrorCallback(rhinoManagerErrorCallback);

String model;
if (Objects.equals(BuildConfig.FLAVOR, "en")) {
model = "rhino_params.pv";
} else {
model = "rhino_params_" + BuildConfig.FLAVOR + ".pv";
}
builder.setModelPath("models/" + model);

rhinoManager = builder.build(getApplicationContext(), rhinoManagerCallback);

Log.i("RhinoManager", rhinoManager.getContextInformation());
} catch (RhinoInvalidArgumentException e) {
onRhinoError(
String.format(
"%s\nMake sure your AccessKey '%s' is a valid access key.",
e.getMessage(),
ACCESS_KEY));
} catch (RhinoActivationException e) {
onRhinoError("AccessKey activation error");
} catch (RhinoActivationLimitException e) {
onRhinoError("AccessKey reached its device limit");
} catch (RhinoActivationRefusedException e) {
onRhinoError("AccessKey refused");
} catch (RhinoActivationThrottledException e) {
onRhinoError("AccessKey has been throttled");
} catch (RhinoException e) {
onRhinoError("Failed to initialize Porcupine " + e.getMessage());
}
}

private void onRhinoError(String errorMessage) {
recordButton.setEnabled(false);
Expand All @@ -153,7 +159,7 @@ protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_rhino_demo);

recordButton = findViewById(R.id.startButton);
contextNameTextView = findViewById(R.id.contextName);
TextView contextNameTextView = findViewById(R.id.contextName);
cheatSheetButton = findViewById(R.id.cheatSheetButton);
intentTextView = findViewById(R.id.intentView);
errorTextView = findViewById(R.id.errorView);
Expand Down

0 comments on commit 29d6459

Please sign in to comment.