Skip to content

Commit

Permalink
v2.0 android (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
laves authored Nov 23, 2023
1 parent bc14c30 commit 206caec
Show file tree
Hide file tree
Showing 24 changed files with 175 additions and 37 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions binding/android/Cheetah/cheetah/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 = '1.1.2'
PUBLISH_VERSION = '2.0.0'
PUBLISH_ARTIFACT_ID = 'cheetah-android'
}

Expand Down Expand Up @@ -38,7 +38,7 @@ dependencies {
}

task copyLibs(type: Copy) {
from("${rootDir}/../../lib/android")
from("${rootDir}/../../../lib/android")
into("${rootDir}/cheetah/src/main/jniLibs")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -48,6 +54,8 @@ private Cheetah(
String modelPath,
float endpointDuration,
boolean enableAutomaticPunctuation) throws CheetahException {
CheetahNative.setSdk(Cheetah._sdk);

handle = CheetahNative.init(
accessKey,
modelPath,
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahActivationException(Throwable cause) {
public CheetahActivationException(String message) {
super(message);
}
}

public CheetahActivationException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahActivationLimitException(Throwable cause) {
public CheetahActivationLimitException(String message) {
super(message);
}
}

public CheetahActivationLimitException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahActivationRefusedException(Throwable cause) {
public CheetahActivationRefusedException(String message) {
super(message);
}
}

public CheetahActivationRefusedException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahActivationThrottledException(Throwable cause) {
public CheetahActivationThrottledException(String message) {
super(message);
}
}

public CheetahActivationThrottledException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahIOException(Throwable cause) {
public CheetahIOException(String message) {
super(message);
}
}

public CheetahIOException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahInvalidArgumentException(Throwable cause) {
public CheetahInvalidArgumentException(String message) {
super(message);
}
}

public CheetahInvalidArgumentException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahInvalidStateException(Throwable cause) {
public CheetahInvalidStateException(String message) {
super(message);
}
}

public CheetahInvalidStateException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahKeyException(Throwable cause) {
public CheetahKeyException(String message) {
super(message);
}
}

public CheetahKeyException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahMemoryException(Throwable cause) {
public CheetahMemoryException(String message) {
super(message);
}
}

public CheetahMemoryException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahRuntimeException(Throwable cause) {
public CheetahRuntimeException(String message) {
super(message);
}
}

public CheetahRuntimeException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -18,5 +20,8 @@ public CheetahStopIterationException(Throwable cause) {
public CheetahStopIterationException(String message) {
super(message);
}
}

public CheetahStopIterationException(String message, String[] messageStack) {
super(message, messageStack);
}
}
Loading

0 comments on commit 206caec

Please sign in to comment.