parent
a718ffe823
commit
27ae3482d4
@ -1,9 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
|
||||
BUILD_ROOT=build/Linux
|
||||
BUILD_DIR=${BUILD_ROOT}/x86_64
|
||||
|
||||
mkdir -p ${BUILD_DIR}
|
||||
|
||||
# the build script had verified in the paddlepaddle docker image.
|
||||
# please follow the instruction below to install PaddlePaddle image.
|
||||
# https://www.paddlepaddle.org.cn/documentation/docs/zh/install/docker/linux-docker.html
|
||||
#cmake -B build -DBUILD_SHARED_LIBS=OFF -DWITH_ASR=OFF -DWITH_CLS=OFF -DWITH_VAD=ON -DFASTDEPLOY_INSTALL_DIR=/workspace/zhanghui/paddle/FastDeploy/build/Android/arm64-v8a-api-21/install
|
||||
cmake -B build -DBUILD_SHARED_LIBS=OFF -DWITH_ASR=OFF -DWITH_CLS=OFF -DWITH_VAD=ON -DFASTDEPLOY_INSTALL_DIR=/workspace/zhanghui/paddle/FastDeploy/build/Linux/x86_64/install
|
||||
cmake --build build -j
|
||||
cmake -B ${BUILD_DIR} -DBUILD_SHARED_LIBS=OFF -DWITH_ASR=OFF -DWITH_CLS=OFF -DWITH_VAD=ON -DFASTDEPLOY_INSTALL_DIR=/workspace/zhanghui/paddle/FastDeploy/build/Linux/x86_64/install
|
||||
cmake --build ${BUILD_DIR} -j
|
||||
|
@ -0,0 +1,11 @@
|
||||
set(srcs
|
||||
vad_jni_interface.cc
|
||||
)
|
||||
|
||||
add_library(pps_vad_jni_interface ${srcs})
|
||||
target_link_libraries(pps_vad_jni_interface PUBLIC ${FASTDEPLOY_LIBS} pps_vad_interface)
|
||||
|
||||
|
||||
file(RELATIVE_PATH DEST_DIR ${ENGINE_ROOT} ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
install(TARGETS pps_vad_jni_interface DESTINATION lib)
|
||||
install(FILES vad_jni_interface.h DESTINATION include/${DEST_DIR})
|
@ -0,0 +1,50 @@
|
||||
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// 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
|
||||
// limitations under the License.
|
||||
|
||||
#include "vad/jni/vad_jni_interface.h"
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_baidu_paddlespeech_PPSVadJni_createInstance(
|
||||
JNIEnv* env, jobject thiz, jstring conf_path) {
|
||||
const char* path = env->GetStringUTFChars(conf_path, JNI_FALSE);
|
||||
PPSHandle_t handle = PPSVadCreateInstance(path);
|
||||
|
||||
return (jlong)(handle);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_destoryInstance(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance) {
|
||||
PPSHandle_t handle = (PPSHandle_t)(instance);
|
||||
return (jint)PPSVadDestroyInstance(handle);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_reset(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance) {
|
||||
PPSHandle_t handle = (PPSHandle_t)(instance);
|
||||
return (jint)PPSVadReset(handle);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_chunkSizeSamples(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance) {
|
||||
PPSHandle_t handle = (PPSHandle_t)(instance);
|
||||
return (jint)PPSVadChunkSizeSamples(handle);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_feedForward(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance, jfloatArray chunk) {
|
||||
PPSHandle_t handle = (PPSHandle_t)(instance);
|
||||
jsize num_elms = env->GetArrayLength(chunk);
|
||||
jfloat* chunk_ptr = env->GetFloatArrayElements(chunk, JNI_FALSE);
|
||||
return (jint)PPSVadFeedForward(handle, (float*)chunk_ptr, (int)num_elms);
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
// Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// 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
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
// PackageName: paddlespeech.baidu.com
|
||||
// ClassName: PPSVadJni
|
||||
#include <jni.h>
|
||||
|
||||
#include "vad/interface/vad_interface.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef jlong PPSJniHandle_t;
|
||||
|
||||
JNIEXPORT PPSJniHandle_t JNICALL
|
||||
Java_com_baidu_paddlespeech_PPSVadJni_createInstance(JNIEnv* env,
|
||||
jobject thiz,
|
||||
jstring conf_path);
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_destoryInstance(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance);
|
||||
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_reset(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance);
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_chunkSizeSamples(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance);
|
||||
|
||||
// typedef enum {
|
||||
// PPS_VAD_ILLEGAL = 0, // error
|
||||
// PPS_VAD_SIL, // silence
|
||||
// PPS_VAD_START, // start speech
|
||||
// PPS_VAD_SPEECH, // in speech
|
||||
// PPS_VAD_END, // end speech
|
||||
// PPS_VAD_NUMSTATES, // number of states
|
||||
// } PPSVadState_t;
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_PPSVadJni_feedForward(
|
||||
JNIEnv* env, jobject thiz, PPSJniHandle_t instance, jfloatArray chunk);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Loading…
Reference in new issue