parent
b35fc01a3a
commit
7489e399f1
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
ANDROID_NDK=/workspace/zhanghui/android-sdk/android-ndk-r25c
|
||||
|
||||
# Setting up Android toolchanin
|
||||
ANDROID_ABI=arm64-v8a # 'arm64-v8a', 'armeabi-v7a'
|
||||
ANDROID_PLATFORM="android-21" # API >= 21
|
||||
ANDROID_STL=c++_shared # 'c++_shared', 'c++_static'
|
||||
ANDROID_TOOLCHAIN=clang # 'clang' only
|
||||
TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
|
||||
|
||||
# Create build directory
|
||||
BUILD_ROOT=build/Android
|
||||
BUILD_DIR=${BUILD_ROOT}/${ANDROID_ABI}-api-21
|
||||
#FASDEPLOY_INSTALL_DIR="${BUILD_DIR}/install"
|
||||
#mkdir build && mkdir ${BUILD_ROOT} && mkdir ${BUILD_DIR}
|
||||
mkdir -p ${BUILD_DIR}
|
||||
cd ${BUILD_DIR}
|
||||
|
||||
# CMake configuration with Android toolchain
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FILE} \
|
||||
-DCMAKE_BUILD_TYPE=MinSizeRel \
|
||||
-DANDROID_ABI=${ANDROID_ABI} \
|
||||
-DANDROID_NDK=${ANDROID_NDK} \
|
||||
-DANDROID_PLATFORM=${ANDROID_PLATFORM} \
|
||||
-DANDROID_STL=${ANDROID_STL} \
|
||||
-DANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN} \
|
||||
-DWITH_ASR=OFF \
|
||||
-DWITH_CLS=OFF \
|
||||
-Wno-dev ../../..
|
||||
#-DFASTDEPLOY_INSTALL_DIR=${FASTDEPLOY_INSTALL_DIR} \
|
||||
|
||||
# Build FastDeploy Android C++ SDK
|
||||
make
|
@ -1,44 +1,42 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
set(ARCH "mserver_x86_64" CACHE STRING "Target Architecture:
|
||||
android_arm, android_armv7, android_armv8, android_x86, android_x86_64,
|
||||
mserver_x86_64, ubuntu_x86_64, ios_armv7, ios_armv7s, ios_armv8, ios_x86_64, ios_x86,
|
||||
windows_x86")
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||
|
||||
set(FASTDEPLOY_DIR ${CMAKE_SOURCE_DIR}/fc_patch/fastdeploy)
|
||||
if(NOT EXISTS ${FASTDEPLOY_DIR}/fastdeploy-linux-x64-1.0.4.tgz)
|
||||
exec_program("mkdir -p ${FASTDEPLOY_DIR} &&
|
||||
wget https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-x64-1.0.4.tgz -P ${FASTDEPLOY_DIR} &&
|
||||
wget -c https://bj.bcebos.com/fastdeploy/release/cpp/fastdeploy-linux-x64-1.0.4.tgz -P ${FASTDEPLOY_DIR} &&
|
||||
tar xzvf ${FASTDEPLOY_DIR}/fastdeploy-linux-x64-1.0.4.tgz -C ${FASTDEPLOY_DIR} &&
|
||||
mv ${FASTDEPLOY_DIR}/fastdeploy-linux-x64-1.0.4 ${FASTDEPLOY_DIR}/linux-x64")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${FASTDEPLOY_DIR}/fastdeploy-android-1.0.0-shared.tgz)
|
||||
if(NOT EXISTS ${FASTDEPLOY_DIR}/fastdeploy-android-1.0.4-shared.tgz)
|
||||
exec_program("mkdir -p ${FASTDEPLOY_DIR} &&
|
||||
wget https://bj.bcebos.com/fastdeploy/release/android/fastdeploy-android-1.0.0-shared.tgz -P ${FASTDEPLOY_DIR} &&
|
||||
tar xzvf ${FASTDEPLOY_DIR}/fastdeploy-android-1.0.0-shared.tgz -C ${FASTDEPLOY_DIR} &&
|
||||
mv ${FASTDEPLOY_DIR}/fastdeploy-android-1.0.0-shared ${FASTDEPLOY_DIR}/android-armv7v8")
|
||||
wget -c https://bj.bcebos.com/fastdeploy/release/android/fastdeploy-android-1.0.4-shared.tgz -P ${FASTDEPLOY_DIR} &&
|
||||
tar xzvf ${FASTDEPLOY_DIR}/fastdeploy-android-1.0.4-shared.tgz -C ${FASTDEPLOY_DIR} &&
|
||||
mv ${FASTDEPLOY_DIR}/fastdeploy-android-1.0.4-shared ${FASTDEPLOY_DIR}/android-armv7v8")
|
||||
endif()
|
||||
|
||||
if (ARCH STREQUAL "mserver_x86_64")
|
||||
|
||||
if(ANDROID)
|
||||
set(FASTDEPLOY_INSTALL_DIR ${FASTDEPLOY_DIR}/android-armv7v8)
|
||||
add_definitions("-DUSE_PADDLE_LITE_BAKEND")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -mfloat-abi=softfp -mfpu=vfpv3 -mfpu=neon -fPIC -pie -fPIE")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g0 -O3 -mfloat-abi=softfp -mfpu=vfpv3 -mfpu=neon -fPIC -pie -fPIE")
|
||||
elseif(UNIX)
|
||||
set(FASTDEPLOY_INSTALL_DIR ${FASTDEPLOY_DIR}/linux-x64)
|
||||
add_definitions("-DUSE_PADDLE_INFERENCE_BACKEND")
|
||||
# add_definitions("-DUSE_ORT_BACKEND")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -msse -msse2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -msse -msse2 -mavx -O3")
|
||||
elseif (ARCH STREQUAL "android_armv7")
|
||||
set(FASTDEPLOY_INSTALL_DIR ${FASTDEPLOY_DIR}/android-armv7v8)
|
||||
add_definitions("-DUSE_PADDLE_LITE_BAKEND")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -mfloat-abi=softfp -mfpu=vfpv3 -mfpu=neon -fPIC -pie -fPIE")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g0 -O3 -mfloat-abi=softfp -mfpu=vfpv3 -mfpu=neon -fPIC -pie -fPIE")
|
||||
endif()
|
||||
|
||||
message(STATUS "FASTDEPLOY_INSTALL_DIR=${FASTDEPLOY_INSTALL_DIR} ${UNIX}")
|
||||
include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake)
|
||||
|
||||
# fix compiler flags conflict, since fastdeploy using c++11 for project
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD ${PPS_CXX_STANDARD})
|
||||
|
||||
include_directories(${FASTDEPLOY_INCS})
|
||||
message(STATUS "FASTDEPLOY_INCS=${FASTDEPLOY_INCS}")
|
@ -1,8 +1,20 @@
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
glog
|
||||
URL https://paddleaudio.bj.bcebos.com/build/glog-0.4.0.zip
|
||||
URL_HASH SHA256=9e1b54eb2782f53cd8af107ecf08d2ab64b8d0dc2b7f5594472f3bd63ca85cdc
|
||||
)
|
||||
FetchContent_MakeAvailable(glog)
|
||||
include_directories(${glog_BINARY_DIR} ${glog_SOURCE_DIR}/src)
|
||||
|
||||
if(ANDROID)
|
||||
else() # UNIX
|
||||
add_definitions(-DWITH_GLOG)
|
||||
FetchContent_Declare(
|
||||
extern_glog
|
||||
URL https://paddleaudio.bj.bcebos.com/build/glog-0.4.0.zip
|
||||
URL_HASH SHA256=9e1b54eb2782f53cd8af107ecf08d2ab64b8d0dc2b7f5594472f3bd63ca85cdc
|
||||
)
|
||||
FetchContent_MakeAvailable(extern_glog)
|
||||
include_directories(${glog_BINARY_DIR} ${glog_SOURCE_DIR}/src)
|
||||
endif()
|
||||
|
||||
add_library(glog INTERFACE)
|
||||
|
||||
if(ANDROID)
|
||||
else() # UNIX
|
||||
add_dependencies(gtest extern_glog)
|
||||
endif()
|
@ -0,0 +1,56 @@
|
||||
# Copyright (c) 2022 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.
|
||||
|
||||
function(pps_summary)
|
||||
message(STATUS "")
|
||||
message(STATUS "*************PaddleSpeech Building Summary**********")
|
||||
message(STATUS " CMake version : ${CMAKE_VERSION}")
|
||||
message(STATUS " CMake command : ${CMAKE_COMMAND}")
|
||||
message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS " C++ compiler : ${CMAKE_CXX_COMPILER}")
|
||||
message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
|
||||
message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
|
||||
message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
|
||||
get_directory_property(tmp DIRECTORY ${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
|
||||
message(STATUS " Compile definitions : ${tmp}")
|
||||
message(STATUS " CMAKE_PREFIX_PATH : ${CMAKE_PREFIX_PATH}")
|
||||
message(STATUS " CMAKE_INSTALL_PREFIX : ${CMAKE_INSTALL_PREFIX}")
|
||||
message(STATUS " CMAKE_MODULE_PATH : ${CMAKE_MODULE_PATH}")
|
||||
message(STATUS " CMAKE_SYSTEM_NAME : ${CMAKE_SYSTEM_NAME}")
|
||||
message(STATUS "")
|
||||
|
||||
message(STATUS " WITH_ASR : ${WITH_ASR}")
|
||||
message(STATUS " WITH_CLS : ${WITH_CLS}")
|
||||
message(STATUS " WITH_VAD : ${WITH_VAD}")
|
||||
message(STATUS " WITH_GPU : ${WITH_GPU}")
|
||||
message(STATUS " WITH_TESTING : ${WITH_TESTING}")
|
||||
message(STATUS " WITH_PROFILING : ${WITH_PROFILING}")
|
||||
message(STATUS " FASTDEPLOY_INSTALL_DIR : ${FASTDEPLOY_INSTALL_DIR}")
|
||||
if(WITH_GPU)
|
||||
message(STATUS " CUDA_DIRECTORY : ${CUDA_DIRECTORY}")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
message(STATUS " ANDROID_ABI : ${ANDROID_ABI}")
|
||||
message(STATUS " ANDROID_PLATFORM : ${ANDROID_PLATFORM}")
|
||||
message(STATUS " ANDROID_NDK : ${ANDROID_NDK}")
|
||||
message(STATUS " ANDROID_NDK_VERSION : ${CMAKE_ANDROID_NDK_VERSION}")
|
||||
endif()
|
||||
if (WITH_ASR)
|
||||
message(STATUS " Python executable : ${PYTHON_EXECUTABLE}")
|
||||
message(STATUS " Python includes : ${PYTHON_INCLUDE_DIR}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
pps_summary()
|
@ -1,7 +1 @@
|
||||
project(cls)
|
||||
|
||||
include(fastdeploy)
|
||||
# add_definitions("-DTEST_DEBUG")
|
||||
# add_definitions("-DPRINT_TIME")
|
||||
|
||||
add_subdirectory(nnet)
|
@ -1,8 +1,11 @@
|
||||
set(srcs panns_nnet.cc panns_interface.cc)
|
||||
set(srcs
|
||||
panns_nnet.cc
|
||||
panns_interface.cc
|
||||
)
|
||||
|
||||
add_library(cls SHARED ${srcs})
|
||||
target_link_libraries(cls -static-libstdc++;-Wl,-Bsymbolic ${FASTDEPLOY_LIBS} kaldi-matrix kaldi-base frontend utils)
|
||||
target_link_libraries(cls INTERFACE -static-libstdc++;-Wl,-Bsymbolic ${FASTDEPLOY_LIBS} kaldi-matrix kaldi-base frontend utils )
|
||||
|
||||
set(bin_name panns_nnet_main)
|
||||
add_executable(${bin_name} ${CMAKE_CURRENT_SOURCE_DIR}/${bin_name}.cc)
|
||||
target_link_libraries(${bin_name} -static-libstdc++;-Wl,-Bsymbolic cls gflags glog)
|
||||
target_link_libraries(${bin_name} -static-libstdc++;-Wl,-Bsymbolic gflags glog)
|
||||
|
@ -1,3 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
|
||||
|
||||
add_subdirectory(glog)
|
||||
if(ANDROID)
|
||||
else() #Unix
|
||||
add_subdirectory(glog)
|
||||
endif()
|
@ -0,0 +1,12 @@
|
||||
|
||||
#include "base/glog_utils.h"
|
||||
|
||||
namespace google {
|
||||
void InitGoogleLogging(const char* name) {
|
||||
LOG(INFO) << "dummpy InitGoogleLogging.";
|
||||
}
|
||||
|
||||
void InstallFailureSignalHandler(){
|
||||
LOG(INFO) << "dummpy InstallFailureSignalHandler.";
|
||||
}
|
||||
} // namespace google
|
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "base/common.h"
|
||||
|
||||
namespace google {
|
||||
void InitGoogleLogging(const char* name);
|
||||
|
||||
void InstallFailureSignalHandler();
|
||||
} // namespace google
|
@ -0,0 +1,91 @@
|
||||
#include "base/log.h"
|
||||
|
||||
DEFINE_int32(logtostderr, 0, "logging to stderr");
|
||||
|
||||
namespace ppspeech {
|
||||
|
||||
static char __progname[] = "paddlespeech";
|
||||
|
||||
namespace log {
|
||||
|
||||
std::mutex LogMessage::lock_;
|
||||
std::string LogMessage::s_debug_logfile_("");
|
||||
std::string LogMessage::s_info_logfile_("");
|
||||
std::string LogMessage::s_warning_logfile_("");
|
||||
std::string LogMessage::s_error_logfile_("");
|
||||
std::string LogMessage::s_fatal_logfile_("");
|
||||
|
||||
void LogMessage::get_curr_proc_info(std::string* pid, std::string* proc_name) {
|
||||
std::stringstream ss;
|
||||
ss << getpid();
|
||||
ss >> *pid;
|
||||
*proc_name = ::ppspeech::__progname;
|
||||
}
|
||||
|
||||
LogMessage::LogMessage(const char* file, int line, Severity level, bool verbose, bool out_to_file /* = false */) : level_(level), verbose_(verbose), out_to_file_(out_to_file) {
|
||||
|
||||
if (FLAGS_logtostderr == 0){
|
||||
stream_ = std::shared_ptr<std::ostream>(&std::cout);
|
||||
} else if (FLAGS_logtostderr == 1){
|
||||
stream_ = std::shared_ptr<std::ostream>(&std::cerr);
|
||||
}else if (out_to_file_){
|
||||
// logfile
|
||||
lock_.lock();
|
||||
init(file, line);
|
||||
}
|
||||
}
|
||||
|
||||
LogMessage:: ~LogMessage(){
|
||||
stream() << std::endl;
|
||||
|
||||
if(out_to_file_){
|
||||
lock_.unlock();
|
||||
}
|
||||
|
||||
if (level_ == FATAL){
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
void LogMessage::init(const char* file, int line) {
|
||||
time_t t = time(0);
|
||||
char tmp[100];
|
||||
strftime(tmp, sizeof(tmp), "%Y%m%d-%H%M%S", localtime(&t));
|
||||
|
||||
if (s_info_logfile_.empty()) {
|
||||
std::string pid;
|
||||
std::string proc_name;
|
||||
get_curr_proc_info(&pid, &proc_name);
|
||||
|
||||
s_debug_logfile_ = std::string("log." + proc_name + ".log.DEBUG." + tmp + "." + pid);
|
||||
s_info_logfile_ = std::string("log." + proc_name + ".log.INFO." + tmp + "." + pid);
|
||||
s_warning_logfile_ = std::string("log." + proc_name + ".log.WARNING." + tmp + "." + pid);
|
||||
s_error_logfile_ = std::string("log." + proc_name + ".log.ERROR." + tmp + "." + pid);
|
||||
s_fatal_logfile_ = std::string("log." + proc_name + ".log.FATAL." + tmp + "." + pid);
|
||||
}
|
||||
|
||||
std::ofstream ofs;
|
||||
if (level_ == DEBUG) {
|
||||
stream_ = std::make_shared<std::ofstream>(s_debug_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
// ofs.open(s_debug_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
} else if (level_ == INFO) {
|
||||
// ofs.open(s_warning_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
stream_ = std::make_shared<std::ofstream>(s_warning_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
} else if (level_ == WARNING) {
|
||||
// ofs.open(s_warning_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
stream_ = std::make_shared<std::ofstream>(s_warning_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
} else if (level_ == ERROR) {
|
||||
// ofs.open(s_error_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
stream_ = std::make_shared<std::ofstream>(s_error_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
} else {
|
||||
// ofs.open(s_fatal_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
stream_ = std::make_shared<std::ofstream>(s_fatal_logfile_.c_str(), std::ios::out | std::ios::app);
|
||||
}
|
||||
|
||||
// stream_ = &ofs;
|
||||
|
||||
stream() << tmp << " " << file << " line " << line << "; ";
|
||||
stream() << std::flush;
|
||||
}
|
||||
} // namespace log
|
||||
} // namespace ppspeech
|
@ -0,0 +1,155 @@
|
||||
// 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.
|
||||
|
||||
// modified from https://github.com/Dounm/dlog
|
||||
// modified form https://android.googlesource.com/platform/art/+/806defa/src/logging.h
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fstream>
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "base/common.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/glog_utils.h"
|
||||
|
||||
DECLARE_int32(logtostderr);
|
||||
|
||||
namespace ppspeech{
|
||||
|
||||
namespace log {
|
||||
|
||||
enum Severity {
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
ERROR,
|
||||
FATAL,
|
||||
NUM_SEVERITIES,
|
||||
};
|
||||
|
||||
class LogMessage {
|
||||
public:
|
||||
static void get_curr_proc_info(std::string* pid, std::string* proc_name);
|
||||
|
||||
LogMessage(const char* file, int line, Severity level, bool verbose, bool out_to_file = false);
|
||||
|
||||
~LogMessage();
|
||||
|
||||
std::ostream& stream() { return *stream_; }
|
||||
|
||||
private:
|
||||
void init(const char* file, int line);
|
||||
|
||||
private:
|
||||
std::shared_ptr<std::ostream> stream_;
|
||||
Severity level_;
|
||||
bool verbose_;
|
||||
bool out_to_file_;
|
||||
|
||||
static std::mutex lock_; // stream write lock
|
||||
static std::string s_debug_logfile_;
|
||||
static std::string s_info_logfile_;
|
||||
static std::string s_warning_logfile_;
|
||||
static std::string s_error_logfile_;
|
||||
static std::string s_fatal_logfile_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(LogMessage);
|
||||
};
|
||||
|
||||
|
||||
} //namespace log
|
||||
|
||||
} //namespace ppspeech
|
||||
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DLOG_DEBUG ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::DEBUG, false)
|
||||
#else
|
||||
#define DLOG_DEBUG ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::DEBUG, true)
|
||||
#endif
|
||||
|
||||
#define DLOG_INFO ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::INFO, true)
|
||||
#define DLOG_WARNING ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::WARNING, true)
|
||||
#define DLOG_ERROR ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::ERROR, true)
|
||||
#define DLOG_FATAL ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::FATAL, true)
|
||||
|
||||
#define DLOG_0 DLOG_DEBUG
|
||||
#define DLOG_1 DLOG_INFO
|
||||
#define DLOG_2 DLOG_WARNING
|
||||
#define DLOG_3 DLOG_ERROR
|
||||
#define DLOG_4 DLOG_FATAL
|
||||
|
||||
#define LOG(level) DLOG_##level.stream()
|
||||
|
||||
#define VLOG(verboselevel) LOG(verboselevel)
|
||||
|
||||
|
||||
#define CHECK(exp) ppspeech::log::LogMessage \
|
||||
(__FILE__, __LINE__, ppspeech::log::FATAL, !(exp)).stream() << "Check Failed: " #exp
|
||||
|
||||
#define CHECK_EQ(x, y) CHECK((x) == (y))
|
||||
#define CHECK_NE(x, y) CHECK((x) != (y))
|
||||
#define CHECK_LE(x, y) CHECK((x) <= (y))
|
||||
#define CHECK_LT(x, y) CHECK((x) < (y))
|
||||
#define CHECK_GE(x, y) CHECK((x) >= (y))
|
||||
#define CHECK_GT(x, y) CHECK((x) > (y))
|
||||
#ifndef NDEBUG
|
||||
#define DCHECK(x) CHECK(x)
|
||||
#define DCHECK_EQ(x, y) CHECK_EQ(x, y)
|
||||
#define DCHECK_NE(x, y) CHECK_NE(x, y)
|
||||
#define DCHECK_LE(x, y) CHECK_LE(x, y)
|
||||
#define DCHECK_LT(x, y) CHECK_LT(x, y)
|
||||
#define DCHECK_GE(x, y) CHECK_GE(x, y)
|
||||
#define DCHECK_GT(x, y) CHECK_GT(x, y)
|
||||
#else // NDEBUG
|
||||
#define DCHECK(condition) \
|
||||
while (false) \
|
||||
CHECK(condition)
|
||||
#define DCHECK_EQ(val1, val2) \
|
||||
while (false) \
|
||||
CHECK_EQ(val1, val2)
|
||||
#define DCHECK_NE(val1, val2) \
|
||||
while (false) \
|
||||
CHECK_NE(val1, val2)
|
||||
#define DCHECK_LE(val1, val2) \
|
||||
while (false) \
|
||||
CHECK_LE(val1, val2)
|
||||
#define DCHECK_LT(val1, val2) \
|
||||
while (false) \
|
||||
CHECK_LT(val1, val2)
|
||||
#define DCHECK_GE(val1, val2) \
|
||||
while (false) \
|
||||
CHECK_GE(val1, val2)
|
||||
#define DCHECK_GT(val1, val2) \
|
||||
while (false) \
|
||||
CHECK_GT(val1, val2)
|
||||
#define DCHECK_STREQ(str1, str2) \
|
||||
while (false) \
|
||||
CHECK_STREQ(str1, str2)
|
||||
#endif
|
@ -1,20 +1,27 @@
|
||||
|
||||
add_library(utils
|
||||
|
||||
set(csrc
|
||||
file_utils.cc
|
||||
math.cc
|
||||
strings.cc
|
||||
audio_process.cc
|
||||
)
|
||||
|
||||
add_library(utils ${csrc})
|
||||
|
||||
if(WITH_TESTING)
|
||||
enable_testing()
|
||||
link_libraries(gtest_main gmock)
|
||||
|
||||
add_executable(strings_test strings_test.cc)
|
||||
target_link_libraries(strings_test PUBLIC utils)
|
||||
add_test(
|
||||
NAME strings_test
|
||||
COMMAND strings_test
|
||||
)
|
||||
if(ANDROID)
|
||||
else() # UNIX
|
||||
link_libraries(gtest_main gmock)
|
||||
|
||||
add_executable(strings_test strings_test.cc)
|
||||
target_link_libraries(strings_test PUBLIC utils)
|
||||
add_test(
|
||||
NAME strings_test
|
||||
COMMAND strings_test
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -1,18 +1,4 @@
|
||||
# set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
# # 指定下载解压后的fastdeploy库路径
|
||||
# set(FASTDEPLOY_INSTALL_DIR "fdlib/fastdeploy-linux-x64-1.0.4" CACHE STRING force)
|
||||
|
||||
# if(NOT EXISTS ${FASTDEPLOY_INSTALL_DIR})
|
||||
# message(FATAL_ERROR "Please using cmake -B build -DFASTDEPLOY_INSTALL_DIR=${FASTDEPLOY_INSTALL_DIR}")
|
||||
# endif()
|
||||
|
||||
# include(${FASTDEPLOY_INSTALL_DIR}/FastDeploy.cmake)
|
||||
|
||||
# # 添加FastDeploy依赖头文件
|
||||
# include_directories(${FASTDEPLOY_INCS})
|
||||
|
||||
add_executable(infer_onnx_silero_vad ${CMAKE_CURRENT_SOURCE_DIR}/infer_onnx_silero_vad.cc wav.h vad.cc vad.h)
|
||||
|
||||
# 添加FastDeploy库依赖
|
||||
target_link_libraries(infer_onnx_silero_vad ${FASTDEPLOY_LIBS})
|
||||
target_link_libraries(infer_onnx_silero_vad ${FASTDEPLOY_LIBS} gflags glog)
|
||||
|
Loading…
Reference in new issue