From 206caec7be597716d715c9c41efd3e88945338db Mon Sep 17 00:00:00 2001 From: Ian Lavery Date: Thu, 23 Nov 2023 14:51:11 -0800 Subject: [PATCH] v2.0 android (#264) --- .github/workflows/android-perf.yml | 8 ++--- binding/android/Cheetah/cheetah/build.gradle | 4 +-- .../java/ai/picovoice/cheetah/Cheetah.java | 8 +++++ .../ai/picovoice/cheetah/CheetahNative.java | 6 ++-- .../picovoice/cheetah/CheetahTranscript.java | 4 ++- .../exception/CheetahActivationException.java | 9 +++-- .../CheetahActivationLimitException.java | 9 +++-- .../CheetahActivationRefusedException.java | 9 +++-- .../CheetahActivationThrottledException.java | 9 +++-- .../cheetah/exception/CheetahException.java | 36 +++++++++++++++++-- .../cheetah/exception/CheetahIOException.java | 9 +++-- .../CheetahInvalidArgumentException.java | 9 +++-- .../CheetahInvalidStateException.java | 9 +++-- .../exception/CheetahKeyException.java | 9 +++-- .../exception/CheetahMemoryException.java | 9 +++-- .../exception/CheetahRuntimeException.java | 9 +++-- .../CheetahStopIterationException.java | 9 +++-- binding/android/CheetahTestApp/build.gradle | 6 ++++ .../cheetah-test-app/build.gradle | 2 +- .../cheetah/testapp/CheetahTest.java | 27 ++++++++++++++ demo/android/CheetahDemo/build.gradle | 6 ++++ .../CheetahDemo/cheetah-demo-app/build.gradle | 2 +- .../picovoice/cheetahdemo/MainActivity.java | 2 +- resources/.lint/java/suppress.xml | 2 +- 24 files changed, 175 insertions(+), 37 deletions(-) diff --git a/.github/workflows/android-perf.yml b/.github/workflows/android-perf.yml index d9ea4b5a..033ea6d4 100644 --- a/.github/workflows/android-perf.yml +++ b/.github/workflows/android-perf.yml @@ -29,11 +29,11 @@ jobs: device: [single-android, 32bit-android] include: - device: single-android - initPerformanceThresholdSec: 3.25 - procPerformanceThresholdSec: 0.75 + initPerformanceThresholdSec: 4.0 + procPerformanceThresholdSec: 2.3 - device: 32bit-android - initPerformanceThresholdSec: 10.0 - procPerformanceThresholdSec: 4.0 + initPerformanceThresholdSec: 11.0 + procPerformanceThresholdSec: 15.0 steps: - uses: actions/checkout@v3 diff --git a/binding/android/Cheetah/cheetah/build.gradle b/binding/android/Cheetah/cheetah/build.gradle index 410aab2d..253acca1 100644 --- a/binding/android/Cheetah/cheetah/build.gradle +++ b/binding/android/Cheetah/cheetah/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ext { PUBLISH_GROUP_ID = 'ai.picovoice' - PUBLISH_VERSION = '1.1.2' + PUBLISH_VERSION = '2.0.0' PUBLISH_ARTIFACT_ID = 'cheetah-android' } @@ -38,7 +38,7 @@ dependencies { } task copyLibs(type: Copy) { - from("${rootDir}/../../lib/android") + from("${rootDir}/../../../lib/android") into("${rootDir}/cheetah/src/main/jniLibs") } diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/Cheetah.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/Cheetah.java index 05794f7b..08f1ef06 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/Cheetah.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/Cheetah.java @@ -25,12 +25,18 @@ */ public class Cheetah { + private static String _sdk = "android"; + static { System.loadLibrary("pv_cheetah"); } private long handle; + public static void setSdk(String sdk) { + Cheetah._sdk = sdk; + } + /** * Constructor. * @@ -48,6 +54,8 @@ private Cheetah( String modelPath, float endpointDuration, boolean enableAutomaticPunctuation) throws CheetahException { + CheetahNative.setSdk(Cheetah._sdk); + handle = CheetahNative.init( accessKey, modelPath, diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahNative.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahNative.java index b7d142fa..4f50f809 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahNative.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahNative.java @@ -1,5 +1,5 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. @@ -14,11 +14,13 @@ class CheetahNative { + static native String getVersion(); + static native int getFrameLength(); static native int getSampleRate(); - static native String getVersion(); + static native void setSdk(String sdk) throws CheetahException; static native long init( String accessKey, diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahTranscript.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahTranscript.java index 32c2061f..6c2880cf 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahTranscript.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/CheetahTranscript.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationException.java index 7a12e1fe..71f11c09 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahActivationException(Throwable cause) { public CheetahActivationException(String message) { super(message); } -} + public CheetahActivationException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationLimitException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationLimitException.java index b365b5ac..63a06c9a 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationLimitException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationLimitException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahActivationLimitException(Throwable cause) { public CheetahActivationLimitException(String message) { super(message); } -} + public CheetahActivationLimitException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationRefusedException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationRefusedException.java index 6ee72ad9..9a2b7673 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationRefusedException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationRefusedException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahActivationRefusedException(Throwable cause) { public CheetahActivationRefusedException(String message) { super(message); } -} + public CheetahActivationRefusedException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationThrottledException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationThrottledException.java index f3688d6d..9d597d2c 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationThrottledException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahActivationThrottledException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahActivationThrottledException(Throwable cause) { public CheetahActivationThrottledException(String message) { super(message); } -} + public CheetahActivationThrottledException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahException.java index e712eefa..f527eba8 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -11,12 +13,42 @@ package ai.picovoice.cheetah; public class CheetahException extends Exception { + private final String message; + private final String[] messageStack; + public CheetahException(Throwable cause) { super(cause); + this.message = cause.getMessage(); + this.messageStack = null; } public CheetahException(String message) { super(message); + this.message = message; + this.messageStack = null; } -} + public CheetahException(String message, String[] messageStack) { + super(message); + this.message = message; + this.messageStack = messageStack; + } + + public String[] getMessageStack() { + return this.messageStack; + } + + @Override + public String getMessage() { + StringBuilder sb = new StringBuilder(message); + if (messageStack != null) { + if (messageStack.length > 0) { + sb.append(":"); + for (int i = 0; i < messageStack.length; i++) { + sb.append(String.format("\n [%d] %s", i, messageStack[i])); + } + } + } + return sb.toString(); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahIOException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahIOException.java index 1b1473f0..853569ed 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahIOException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahIOException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahIOException(Throwable cause) { public CheetahIOException(String message) { super(message); } -} + public CheetahIOException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidArgumentException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidArgumentException.java index 4583773a..49bf69cd 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidArgumentException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidArgumentException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahInvalidArgumentException(Throwable cause) { public CheetahInvalidArgumentException(String message) { super(message); } -} + public CheetahInvalidArgumentException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidStateException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidStateException.java index 2c6c1129..b27ac39f 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidStateException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahInvalidStateException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahInvalidStateException(Throwable cause) { public CheetahInvalidStateException(String message) { super(message); } -} + public CheetahInvalidStateException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahKeyException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahKeyException.java index 744537f0..d4bebf11 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahKeyException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahKeyException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahKeyException(Throwable cause) { public CheetahKeyException(String message) { super(message); } -} + public CheetahKeyException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahMemoryException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahMemoryException.java index e7026aaf..d6b55af9 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahMemoryException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahMemoryException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahMemoryException(Throwable cause) { public CheetahMemoryException(String message) { super(message); } -} + public CheetahMemoryException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahRuntimeException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahRuntimeException.java index 4b49ba0f..b13c9d0c 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahRuntimeException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahRuntimeException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahRuntimeException(Throwable cause) { public CheetahRuntimeException(String message) { super(message); } -} + public CheetahRuntimeException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahStopIterationException.java b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahStopIterationException.java index 529ae915..9f3326ff 100644 --- a/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahStopIterationException.java +++ b/binding/android/Cheetah/cheetah/src/main/java/ai/picovoice/cheetah/exception/CheetahStopIterationException.java @@ -1,7 +1,9 @@ /* - Copyright 2022 Picovoice Inc. + Copyright 2022-2023 Picovoice Inc. + You may not use this file except in compliance with the license. A copy of the license is located in the "LICENSE" file accompanying this source. + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and @@ -18,5 +20,8 @@ public CheetahStopIterationException(Throwable cause) { public CheetahStopIterationException(String message) { super(message); } -} + public CheetahStopIterationException(String message, String[] messageStack) { + super(message, messageStack); + } +} diff --git a/binding/android/CheetahTestApp/build.gradle b/binding/android/CheetahTestApp/build.gradle index ebfdad29..ec749f7b 100644 --- a/binding/android/CheetahTestApp/build.gradle +++ b/binding/android/CheetahTestApp/build.gradle @@ -6,6 +6,9 @@ buildscript { repositories { google() mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } dependencies { classpath 'com.android.tools.build:gradle:7.2.2' @@ -16,6 +19,9 @@ allprojects { repositories { google() mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } } diff --git a/binding/android/CheetahTestApp/cheetah-test-app/build.gradle b/binding/android/CheetahTestApp/cheetah-test-app/build.gradle index 356f4006..93995241 100644 --- a/binding/android/CheetahTestApp/cheetah-test-app/build.gradle +++ b/binding/android/CheetahTestApp/cheetah-test-app/build.gradle @@ -116,7 +116,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'ai.picovoice:cheetah-android:1.1.2' + implementation 'ai.picovoice:cheetah-android:2.0.0' // Espresso UI Testing androidTestImplementation 'androidx.test.ext:junit:1.1.3' diff --git a/binding/android/CheetahTestApp/cheetah-test-app/src/androidTest/java/ai/picovoice/cheetah/testapp/CheetahTest.java b/binding/android/CheetahTestApp/cheetah-test-app/src/androidTest/java/ai/picovoice/cheetah/testapp/CheetahTest.java index 69e95ca5..349ec73f 100644 --- a/binding/android/CheetahTestApp/cheetah-test-app/src/androidTest/java/ai/picovoice/cheetah/testapp/CheetahTest.java +++ b/binding/android/CheetahTestApp/cheetah-test-app/src/androidTest/java/ai/picovoice/cheetah/testapp/CheetahTest.java @@ -101,4 +101,31 @@ public void getSampleRate() throws CheetahException { assertTrue(sampleRate > 0); } + + @Test + public void testErrorStack() { + String[] error = {}; + try { + new Cheetah.Builder() + .setAccessKey("invalid") + .setModelPath(defaultModelPath) + .build(appContext); + } catch (CheetahException e) { + error = e.getMessageStack(); + } + + assertTrue(0 < error.length); + assertTrue(error.length <= 8); + + try { + new Cheetah.Builder() + .setAccessKey("invalid") + .setModelPath(defaultModelPath) + .build(appContext); + } catch (CheetahException e) { + for (int i = 0; i < error.length; i++) { + assertEquals(e.getMessageStack()[i], error[i]); + } + } + } } diff --git a/demo/android/CheetahDemo/build.gradle b/demo/android/CheetahDemo/build.gradle index ebfdad29..ec749f7b 100644 --- a/demo/android/CheetahDemo/build.gradle +++ b/demo/android/CheetahDemo/build.gradle @@ -6,6 +6,9 @@ buildscript { repositories { google() mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } dependencies { classpath 'com.android.tools.build:gradle:7.2.2' @@ -16,6 +19,9 @@ allprojects { repositories { google() mavenCentral() + maven { + url 'https://s01.oss.sonatype.org/content/repositories/aipicovoice-1302/' + } } } diff --git a/demo/android/CheetahDemo/cheetah-demo-app/build.gradle b/demo/android/CheetahDemo/cheetah-demo-app/build.gradle index 2685918c..1e22cee8 100644 --- a/demo/android/CheetahDemo/cheetah-demo-app/build.gradle +++ b/demo/android/CheetahDemo/cheetah-demo-app/build.gradle @@ -31,7 +31,7 @@ dependencies { implementation 'androidx.appcompat:appcompat:1.4.2' implementation 'com.google.android.material:material:1.6.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'ai.picovoice:cheetah-android:1.1.2' + implementation 'ai.picovoice:cheetah-android:2.0.0' implementation 'ai.picovoice:android-voice-processor:1.0.2' } diff --git a/demo/android/CheetahDemo/cheetah-demo-app/src/main/java/ai/picovoice/cheetahdemo/MainActivity.java b/demo/android/CheetahDemo/cheetah-demo-app/src/main/java/ai/picovoice/cheetahdemo/MainActivity.java index 6d635622..dbc0f336 100644 --- a/demo/android/CheetahDemo/cheetah-demo-app/src/main/java/ai/picovoice/cheetahdemo/MainActivity.java +++ b/demo/android/CheetahDemo/cheetah-demo-app/src/main/java/ai/picovoice/cheetahdemo/MainActivity.java @@ -61,7 +61,7 @@ protected void onCreate(Bundle savedInstanceState) { .setEnableAutomaticPunctuation(true) .build(getApplicationContext()); } catch (CheetahInvalidArgumentException e) { - displayError(String.format("%s\nEnsure your AccessKey '%s' is valid", e.getMessage(), ACCESS_KEY)); + displayError(e.getMessage()); } catch (CheetahActivationException e) { displayError("AccessKey activation error"); } catch (CheetahActivationLimitException e) { diff --git a/resources/.lint/java/suppress.xml b/resources/.lint/java/suppress.xml index 290f2c28..02787ef3 100644 --- a/resources/.lint/java/suppress.xml +++ b/resources/.lint/java/suppress.xml @@ -10,7 +10,7 @@ - +