pull/3026/head
Hui Zhang 3 years ago
parent 9475fd630a
commit 7ce57074e5

@ -9,3 +9,5 @@ FetchContent_MakeAvailable(gflags)
# openfst need
include_directories(${gflags_BINARY_DIR}/include)
install(FILES ${gflags_BINARY_DIR}/libgflags_nothreads.a DESTINATION lib)

@ -28,7 +28,8 @@ endif()
if(ANDROID)
add_library(extern_glog INTERFACE)
add_dependencies(extern_glog gflags)
else() # UNIX
add_dependencies(glog gflags)
add_library(extern_glog ALIAS glog)
add_dependencies(extern_glog gflags)
endif()

@ -12,4 +12,8 @@ ${CMAKE_CURRENT_SOURCE_DIR}/frontend
add_subdirectory(frontend)
add_library(common INTERFACE)
target_link_libraries(common INTERFACE base utils kaldi-matrix frontend)
target_link_libraries(common INTERFACE base utils kaldi-matrix frontend)
install(TARGETS base DESTINATION lib)
install(TARGETS utils DESTINATION lib)
install(TARGETS kaldi-matrix DESTINATION lib)
install(TARGETS frontend DESTINATION lib)

@ -4,8 +4,4 @@ ${CMAKE_CURRENT_SOURCE_DIR}/../
add_subdirectory(nnet)
add_subdirectory(interface)
if(ANDROID)
add_subdirectory(jni)
endif()
add_subdirectory(interface)

@ -1,11 +0,0 @@
set(srcs
vad_jni_interface.cc
)
add_library(pps_vad_jni_interface ${srcs})
target_link_libraries(pps_vad_jni_interface PUBLIC 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})

@ -1,50 +0,0 @@
// 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_vadjni_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_vadjni_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_vadjni_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_vadjni_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_vadjni_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);
}

@ -1,57 +0,0 @@
// 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: vadjni
#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_vadjni_createInstance(JNIEnv* env,
jobject thiz,
jstring conf_path);
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_vadjni_destoryInstance(
JNIEnv* env, jobject thiz, PPSJniHandle_t instance);
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_vadjni_reset(
JNIEnv* env, jobject thiz, PPSJniHandle_t instance);
JNIEXPORT jint JNICALL Java_com_baidu_paddlespeech_vadjni_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_vadjni_feedForward(
JNIEnv* env, jobject thiz, PPSJniHandle_t instance, jfloatArray chunk);
#ifdef __cplusplus
}
#endif

@ -8,9 +8,9 @@ target_link_libraries(pps_vad PUBLIC ${FASTDEPLOY_LIBS} common extern_glog)
set(bin_name vad_nnet_main)
add_executable(${bin_name} ${CMAKE_CURRENT_SOURCE_DIR}/${bin_name}.cc)
# target_link_libraries(${bin_name} ${FASTDEPLOY_LIBS} vad gflags extern_glog)
target_link_libraries(${bin_name} pps_vad)
file(RELATIVE_PATH DEST_DIR ${ENGINE_ROOT} ${CMAKE_CURRENT_SOURCE_DIR})
install(TARGETS pps_vad DESTINATION lib)
install(TARGETS pps_vad DESTINATION lib)
install(TARGETS extern_glog DESTINATION lib)
Loading…
Cancel
Save