This commit is contained in:
雾聪 2023-11-16 11:12:45 +08:00
commit 5297a2dc4b
37 changed files with 219 additions and 350 deletions

View File

@ -66,7 +66,7 @@ message为需要用json序列化
```text
`mode``offline`,表示推理模式为一句话识别;`online`,表示推理模式为实时语音识别;`2pass`:表示为实时语音识别,并且说话句尾采用离线模型进行纠错。
`wav_name`:表示需要推理音频文件名
`wav_format`表示音视频文件后缀名可选pcm、mp3、mp4等备注1.0版本只支持pcm音频流
`wav_format`表示音视频文件后缀名可选pcm、mp3、mp4等备注只支持pcm音频流
`is_speaking`表示断句尾点例如vad切割点或者一条wav结束
`chunk_size`表示流式模型latency配置`[5,10,5]`表示当前音频为600ms并且回看300ms又看300ms。
`audio_fs`当输入音频为pcm数据是需要加上音频采样率参数

View File

@ -20,12 +20,12 @@ endif()
# for onnxruntime
IF(WIN32)
# file(REMOVE ${PROJECT_SOURCE_DIR}/third_party/glog/src/config.h
# ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/export.h
# ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/logging.h
# ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/raw_logging.h
# ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/stl_logging.h
# ${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/vlog_is_on.h)
file(REMOVE ${PROJECT_SOURCE_DIR}/third_party/glog/src/config.h
${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/export.h
${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/logging.h
${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/raw_logging.h
${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/stl_logging.h
${PROJECT_SOURCE_DIR}/third_party/glog/src/glog/vlog_is_on.h)
ELSE()
link_directories(${ONNXRUNTIME_DIR}/lib)
link_directories(${FFMPEG_DIR}/lib)
@ -55,7 +55,10 @@ if(ENABLE_FST)
# with some patch to fix the make errors.
add_subdirectory(third_party/openfst)
include_directories(${openfst_SOURCE_DIR}/src/include)
if(WIN32)
include_directories(${openfst_SOURCE_DIR}/src/lib)
endif()
endif()
add_subdirectory(third_party/yaml-cpp)

View File

@ -7,6 +7,7 @@ message("files: "${files})
if(WIN32)
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/execution-charset:utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/source-charset:utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/bigobj>")
endif()
add_library(funasr SHARED ${files})

View File

@ -1,5 +1,7 @@
#include "bias-lm.h"
#ifdef _WIN32
#include "fst-types.cc"
#endif
namespace funasr {
void print(std::queue<StateId> &q) {
std::queue<StateId> data = q;

View File

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.21)
cmake_minimum_required (VERSION 3.16)
project (glog
VERSION 0.7.0
DESCRIPTION "C++ implementation of the Google logging module"
@ -131,7 +131,6 @@ check_function_exists (sigaltstack HAVE_SIGALTSTACK)
check_cxx_symbol_exists (backtrace execinfo.h HAVE_EXECINFO_BACKTRACE)
check_cxx_symbol_exists (backtrace_symbols execinfo.h
HAVE_EXECINFO_BACKTRACE_SYMBOLS)
check_cxx_symbol_exists (_chsize_s io.h HAVE__CHSIZE_S)
# NOTE gcc does not fail if you pass a non-existent -Wno-* option as an
# argument. However, it will happily fail if you pass the corresponding -W*
@ -214,61 +213,50 @@ if (WITH_TLS)
endif (WITH_TLS)
set (_PC_FIELDS
"uc_mcontext.gregs[REG_PC]" # Solaris x86 (32 + 64 bit)
"uc_mcontext.gregs[REG_EIP]" # Linux (i386)
"uc_mcontext.gregs[REG_RIP]" # Linux (x86_64)
"uc_mcontext.sc_ip" # Linux (ia64)
"uc_mcontext.pc" # Linux (mips)
"uc_mcontext.uc_regs->gregs[PT_NIP]" # Linux (ppc)
"uc_mcontext.gregs[R15]" # Linux (arm old [untested])
"uc_mcontext.arm_pc" # Linux (arm arch 5)
"uc_mcontext.gp_regs[PT_NIP]" # Suse SLES 11 (ppc64)
"uc_mcontext.mc_eip" # FreeBSD (i386)
"uc_mcontext.mc_rip" # FreeBSD (x86_64 [untested])
"uc_mcontext.__gregs[_REG_EIP]" # NetBSD (i386)
"uc_mcontext.__gregs[_REG_RIP]" # NetBSD (x86_64)
"uc_mcontext->ss.eip" # OS X (i386, <=10.4)
"uc_mcontext->__ss.__eip" # OS X (i386, >=10.5)
"uc_mcontext->ss.rip" # OS X (x86_64)
"uc_mcontext->__ss.__rip" # OS X (>=10.5 [untested])
"uc_mcontext->ss.srr0" # OS X (ppc, ppc64 [untested])
"uc_mcontext->__ss.__srr0" # OS X (>=10.5 [untested])
"gregs[REG_PC]"
"gregs[REG_EIP]"
"gregs[REG_RIP]"
"sc_ip"
"uc_regs->gregs[PT_NIP]"
"gregs[R15]"
"arm_pc"
"mc_eip"
"mc_rip"
"__gregs[REG_EIP]"
"__gregs[REG_RIP]"
"ss.eip"
"__ss.__eip"
"ss.rip"
"__ss.__rip"
"ss.srr0"
"__ss.__srr0"
)
if (HAVE_UCONTEXT_H AND NOT DEFINED PC_FROM_UCONTEXT)
cmake_push_check_state (RESET)
set (_PC_HEADERS ucontext.h signal.h)
set (CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
set (_PC_HEADERS ucontext.h signal.h)
if (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
foreach (_PC_FIELD ${_PC_FIELDS})
foreach (_PC_HEADER ${_PC_HEADERS})
set (_TMP
${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/uctfield.cpp)
file (WRITE ${_TMP} "
#define _GNU_SOURCE 1
#include <${_PC_HEADER}>
int main(void)
{
ucontext_t u;
return u.${_PC_FIELD} == 0;
}
")
try_compile (HAVE_PC_FROM_UCONTEXT ${CMAKE_CURRENT_BINARY_DIR} ${_TMP}
COMPILE_DEFINITIONS _GNU_SOURCE=1)
foreach (_PC_FIELD IN LISTS _PC_FIELDS)
foreach (_PC_HEADER IN LISTS _PC_HEADERS)
# Replace non-alphanumeric characters by underscores since the name will be
# used as preprocessor definition.
string (REGEX REPLACE "[^a-zA-Z0-9]" "_" HAVE_UCONTEXT_FIELD_NAME
"HAVE_PC_FROM_UCONTEXT_${_PC_FIELD}")
# Strip trailing underscores for readability
string (REGEX REPLACE "_+$" "" HAVE_UCONTEXT_FIELD_NAME
"${HAVE_UCONTEXT_FIELD_NAME}")
check_struct_has_member (ucontext_t ${_PC_FIELD} ${_PC_HEADER}
${HAVE_UCONTEXT_FIELD_NAME} LANGUAGE CXX)
if (${HAVE_UCONTEXT_FIELD_NAME})
set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE STRING
"<${_PC_HEADER}> ucontext_t PC member")
mark_as_advanced (PC_FROM_UCONTEXT)
break ()
endif (${HAVE_UCONTEXT_FIELD_NAME})
if (HAVE_PC_FROM_UCONTEXT)
set (PC_FROM_UCONTEXT ${_PC_FIELD} CACHE)
endif (HAVE_PC_FROM_UCONTEXT)
endforeach (_PC_HEADER)
if (${HAVE_UCONTEXT_FIELD_NAME})
break ()
endif (${HAVE_UCONTEXT_FIELD_NAME})
endforeach (_PC_FIELD)
cmake_pop_check_state ()
endif (HAVE_UCONTEXT_H AND NOT DEFINED PC_FROM_UCONTEXT)
endif (HAVE_UCONTEXT_H AND NOT PC_FROM_UCONTEXT)
set (GOOGLE_NAMESPACE google)
set (_START_GOOGLE_NAMESPACE_ "namespace ${GOOGLE_NAMESPACE} {")
@ -480,7 +468,6 @@ set (GLOG_SRCS
src/demangle.h
src/logging.cc
src/raw_logging.cc
src/signalhandler.cc
src/symbolize.cc
src/symbolize.h
src/utilities.cc
@ -488,6 +475,10 @@ set (GLOG_SRCS
src/vlog_is_on.cc
)
if (HAVE_PTHREAD OR WIN32 OR CYGWIN)
list (APPEND GLOG_SRCS src/signalhandler.cc)
endif (HAVE_PTHREAD OR WIN32 OR CYGWIN)
if (CYGWIN OR WIN32)
list (APPEND GLOG_SRCS
src/windows/port.cc
@ -500,20 +491,9 @@ add_library (glog_internal OBJECT
${GLOG_SRCS}
)
target_compile_features (glog_internal PUBLIC $<TARGET_PROPERTY:glog,COMPILE_FEATURES>)
set_target_properties (glog_internal PROPERTIES DEFINE_SYMBOL GOOGLE_GLOG_IS_A_DLL)
# Some generators (such as Xcode) do not generate any output if the target does
# not reference at least one source file.
set (_glog_EMPTY_SOURCE ${glog_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/glog.cc)
add_custom_command (
OUTPUT ${_glog_EMPTY_SOURCE}
COMMAND ${CMAKE_COMMAND} -E touch ${_glog_EMPTY_SOURCE}
)
add_library (glog
$<TARGET_OBJECTS:glog_internal>
${_glog_EMPTY_SOURCE}
)
target_compile_features (glog PUBLIC cxx_std_14)
@ -635,30 +615,38 @@ if (NOT WITH_FUZZING STREQUAL "none")
endif (NOT WITH_FUZZING STREQUAL "none")
if (BUILD_TESTING)
add_library (glog_test INTERFACE)
target_link_libraries (glog_test INTERFACE $<TARGET_OBJECTS:glog_internal> $<TARGET_PROPERTY:glog,LINK_LIBRARIES>)
target_compile_definitions (glog_test INTERFACE GLOG_STATIC_DEFINE $<TARGET_PROPERTY:glog,COMPILE_DEFINITIONS>)
target_include_directories (glog_test INTERFACE $<TARGET_PROPERTY:glog,INCLUDE_DIRECTORIES>)
add_library (glogtest STATIC
$<TARGET_OBJECTS:glog_internal>
)
target_include_directories (glogtest PUBLIC
$<TARGET_PROPERTY:glog,INCLUDE_DIRECTORIES>)
target_compile_definitions (glogtest PUBLIC
$<TARGET_PROPERTY:glog,COMPILE_DEFINITIONS> GLOG_STATIC_DEFINE)
target_link_libraries (glogtest PUBLIC
$<TARGET_PROPERTY:glog,LINK_LIBRARIES>)
set (_GLOG_TEST_LIBS glogtest)
if (HAVE_LIB_GTEST)
target_link_libraries (glog_test INTERFACE GTest::gtest)
list (APPEND _GLOG_TEST_LIBS GTest::gtest)
endif (HAVE_LIB_GTEST)
if (HAVE_LIB_GMOCK)
target_link_libraries (glog_test INTERFACE GTest::gmock)
list (APPEND _GLOG_TEST_LIBS GTest::gmock)
endif (HAVE_LIB_GMOCK)
add_executable (logging_unittest
src/logging_unittest.cc
)
target_link_libraries (logging_unittest PRIVATE glog_test)
target_link_libraries (logging_unittest PRIVATE ${_GLOG_TEST_LIBS})
add_executable (stl_logging_unittest
src/stl_logging_unittest.cc
)
target_link_libraries (stl_logging_unittest PRIVATE glog_test)
target_link_libraries (stl_logging_unittest PRIVATE ${_GLOG_TEST_LIBS})
if (HAVE_NO_DEPRECATED)
set_property (TARGET stl_logging_unittest APPEND PROPERTY COMPILE_OPTIONS
@ -675,35 +663,35 @@ if (BUILD_TESTING)
src/symbolize_unittest.cc
)
target_link_libraries (symbolize_unittest PRIVATE glog_test)
target_link_libraries (symbolize_unittest PRIVATE ${_GLOG_TEST_LIBS})
endif (HAVE_SYMBOLIZE)
add_executable (demangle_unittest
src/demangle_unittest.cc
)
target_link_libraries (demangle_unittest PRIVATE glog_test)
target_link_libraries (demangle_unittest PRIVATE ${_GLOG_TEST_LIBS})
if (HAVE_STACKTRACE)
add_executable (stacktrace_unittest
src/stacktrace_unittest.cc
)
target_link_libraries (stacktrace_unittest PRIVATE glog_test)
target_link_libraries (stacktrace_unittest PRIVATE ${_GLOG_TEST_LIBS})
endif (HAVE_STACKTRACE)
add_executable (utilities_unittest
src/utilities_unittest.cc
)
target_link_libraries (utilities_unittest PRIVATE glog_test)
target_link_libraries (utilities_unittest PRIVATE ${_GLOG_TEST_LIBS})
if (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
add_executable (signalhandler_unittest
src/signalhandler_unittest.cc
)
target_link_libraries (signalhandler_unittest PRIVATE glog_test)
target_link_libraries (signalhandler_unittest PRIVATE ${_GLOG_TEST_LIBS})
endif (HAVE_STACKTRACE AND HAVE_SYMBOLIZE)
add_test (NAME demangle COMMAND demangle_unittest)
@ -749,7 +737,7 @@ if (BUILD_TESTING)
src/mock-log.h
)
target_link_libraries (mock-log_unittest PRIVATE glog_test)
target_link_libraries (mock-log_unittest PRIVATE ${_GLOG_TEST_LIBS})
add_test (NAME mock-log COMMAND mock-log_unittest)
endif (HAVE_LIB_GMOCK)
@ -811,17 +799,17 @@ if (BUILD_TESTING)
add_executable (cleanup_immediately_unittest
src/cleanup_immediately_unittest.cc)
target_link_libraries (cleanup_immediately_unittest PRIVATE glog_test)
target_link_libraries (cleanup_immediately_unittest PRIVATE ${_GLOG_TEST_LIBS})
add_executable (cleanup_with_absolute_prefix_unittest
src/cleanup_with_absolute_prefix_unittest.cc)
target_link_libraries (cleanup_with_absolute_prefix_unittest PRIVATE glog_test)
target_link_libraries (cleanup_with_absolute_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS})
add_executable (cleanup_with_relative_prefix_unittest
src/cleanup_with_relative_prefix_unittest.cc)
target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE glog_test)
target_link_libraries (cleanup_with_relative_prefix_unittest PRIVATE ${_GLOG_TEST_LIBS})
set (CLEANUP_LOG_DIR ${CMAKE_CURRENT_BINARY_DIR}/cleanup_tests)

View File

@ -1,5 +1,5 @@
cmake_policy (PUSH)
cmake_policy (VERSION 3.16...3.27)
cmake_policy (VERSION 3.3)
include (CMakeParseArguments)

View File

@ -1,3 +1,13 @@
# Create the build directory
execute_process (
COMMAND ${CMAKE_COMMAND} -E make_directory ${TEST_BINARY_DIR}
RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED
)
if (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
message (FATAL_ERROR "Failed to create build directory")
endif (NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0)
if (GENERATOR_TOOLSET)
list (APPEND _ADDITIONAL_ARGS -T ${GENERATOR_TOOLSET})
endif (GENERATOR_TOOLSET)
@ -11,7 +21,7 @@ execute_process (
# Capture the PATH environment variable content set during project generation
# stage. This is required because later during the build stage the PATH is
# modified again (e.g., for MinGW AppVeyor CI builds) by adding back the
# directory containing git.exe. Incidentally, the Git installation directory
# directory containing git.exe. Incidently, the Git installation directory
# also contains sh.exe which causes MinGW Makefile generation to fail.
COMMAND ${CMAKE_COMMAND} -E env PATH=${PATH}
${CMAKE_COMMAND} -C ${INITIAL_CACHE}
@ -19,9 +29,9 @@ execute_process (
${_ADDITIONAL_ARGS}
-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON
-Dglog_ROOT=${PACKAGE_DIR}
-S ${SOURCE_DIR}
-B ${TEST_BINARY_DIR}
-DCMAKE_PREFIX_PATH=${PACKAGE_DIR}
${SOURCE_DIR}
WORKING_DIRECTORY ${TEST_BINARY_DIR}
RESULT_VARIABLE _GENERATE_SUCCEEDED
)

View File

@ -59,7 +59,7 @@
#else
#include "glog/logging.h"
#include <glog/logging.h>
#define DECLARE_VARIABLE(type, shorttype, name, tn) \
namespace fL##shorttype { \
@ -140,12 +140,9 @@
: memchr("tTyY1\0", getenv(envname)[0], 6) != nullptr)
#define EnvToInt(envname, dflt) \
(!getenv(envname) ? (dflt) \
: static_cast<int>(strtol(getenv(envname), nullptr, 10)))
(!getenv(envname) ? (dflt) : strtol(getenv(envname), nullptr, 10))
#define EnvToUInt(envname, dflt) \
(!getenv(envname) \
? (dflt) \
: static_cast<unsigned>(strtoul(getenv(envname), nullptr, 10)))
(!getenv(envname) ? (dflt) : strtoul(getenv(envname), nullptr, 10))
#endif // BASE_COMMANDLINEFLAGS_H__

View File

@ -130,15 +130,12 @@
/* define if gmtime_r is available in time.h */
#cmakedefine HAVE_GMTIME_R
/* define if _chsize_s is available in io.h */
#cmakedefine HAVE__CHSIZE_S
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#cmakedefine LT_OBJDIR
/* How to access the PC from a struct ucontext */
#cmakedefine PC_FROM_UCONTEXT ${PC_FROM_UCONTEXT}
#cmakedefine PC_FROM_UCONTEXT
/* define if we should print file offsets in traces instead of symbolizing. */
#cmakedefine PRINT_UNSYMBOLIZED_STACK_TRACES

View File

@ -36,9 +36,7 @@
#include "demangle.h"
#include <cstddef>
#include <cstdio> // for nullptr
#include <limits>
#include "utilities.h"
@ -111,9 +109,6 @@ struct State {
short nest_level; // For nested names.
bool append; // Append flag.
bool overflowed; // True if output gets overflowed.
uint32 local_level;
uint32 expr_level;
uint32 arg_level;
};
// We don't use strlen() in libc since it's not guaranteed to be async
@ -158,9 +153,6 @@ static void InitState(State *state, const char *mangled,
state->nest_level = -1;
state->append = true;
state->overflowed = false;
state->local_level = 0;
state->expr_level = 0;
state->arg_level = 0;
}
// Returns true and advances "mangled_cur" if we find "one_char_token"
@ -229,10 +221,6 @@ static bool ZeroOrMore(ParseFunc parse_func, State *state) {
// is set to true for later use. The output string is ensured to
// always terminate with '\0' as long as there is no overflow.
static void Append(State *state, const char * const str, ssize_t length) {
if (state->out_cur == nullptr) {
state->overflowed = true;
return;
}
for (ssize_t i = 0; i < length; ++i) {
if (state->out_cur + 1 < state->out_end) { // +1 for '\0'
*state->out_cur = str[i];
@ -306,7 +294,7 @@ static void MaybeAppendWithLength(State *state, const char * const str,
}
}
// A convenient wrapper around MaybeAppendWithLength().
// A convenient wrapper arount MaybeAppendWithLength().
static bool MaybeAppend(State *state, const char * const str) {
if (state->append) {
size_t length = StrLen(str);
@ -604,23 +592,9 @@ static bool ParseNumber(State *state, int *number_out) {
}
const char *p = state->mangled_cur;
int number = 0;
constexpr int int_max_by_10 = std::numeric_limits<int>::max() / 10;
for (;*p != '\0'; ++p) {
if (IsDigit(*p)) {
// Prevent signed integer overflow when multiplying
if (number > int_max_by_10) {
return false;
}
const int digit = *p - '0';
const int shifted = number * 10;
// Prevent signed integer overflow when summing
if (digit > std::numeric_limits<int>::max() - shifted) {
return false;
}
number = shifted + digit;
number = number * 10 + (*p - '0');
} else {
break;
}
@ -678,10 +652,6 @@ static bool ParseIdentifier(State *state, ssize_t length) {
} else {
MaybeAppendWithLength(state, state->mangled_cur, length);
}
if (length < 0 ||
static_cast<std::size_t>(length) > StrLen(state->mangled_cur)) {
return false;
}
state->mangled_cur += length;
return true;
}
@ -1097,33 +1067,22 @@ static bool ParseTemplateArgs(State *state) {
// ::= J <template-arg>* E # argument pack
// ::= X <expression> E
static bool ParseTemplateArg(State *state) {
// Avoid recursion above max_levels
constexpr uint32 max_levels = 5;
if (state->arg_level > max_levels) {
return false;
}
++state->arg_level;
State copy = *state;
if ((ParseOneCharToken(state, 'I') || ParseOneCharToken(state, 'J')) &&
ZeroOrMore(ParseTemplateArg, state) &&
ParseOneCharToken(state, 'E')) {
--state->arg_level;
return true;
}
*state = copy;
if (ParseType(state) ||
ParseExprPrimary(state)) {
--state->arg_level;
return true;
}
*state = copy;
if (ParseOneCharToken(state, 'X') && ParseExpression(state) &&
ParseOneCharToken(state, 'E')) {
--state->arg_level;
return true;
}
*state = copy;
@ -1144,20 +1103,11 @@ static bool ParseExpression(State *state) {
return true;
}
// Avoid recursion above max_levels
constexpr uint32 max_levels = 5;
if (state->expr_level > max_levels) {
return false;
}
++state->expr_level;
State copy = *state;
if (ParseOperatorName(state) &&
ParseExpression(state) &&
ParseExpression(state) &&
ParseExpression(state)) {
--state->expr_level;
return true;
}
*state = copy;
@ -1165,35 +1115,30 @@ static bool ParseExpression(State *state) {
if (ParseOperatorName(state) &&
ParseExpression(state) &&
ParseExpression(state)) {
--state->expr_level;
return true;
}
*state = copy;
if (ParseOperatorName(state) &&
ParseExpression(state)) {
--state->expr_level;
return true;
}
*state = copy;
if (ParseTwoCharToken(state, "st") && ParseType(state)) {
return true;
--state->expr_level;
}
*state = copy;
if (ParseTwoCharToken(state, "sr") && ParseType(state) &&
ParseUnqualifiedName(state) &&
ParseTemplateArgs(state)) {
--state->expr_level;
return true;
}
*state = copy;
if (ParseTwoCharToken(state, "sr") && ParseType(state) &&
ParseUnqualifiedName(state)) {
--state->expr_level;
return true;
}
*state = copy;
@ -1239,25 +1184,16 @@ static bool ParseExprPrimary(State *state) {
// [<discriminator>]
// := Z <(function) encoding> E s [<discriminator>]
static bool ParseLocalName(State *state) {
// Avoid recursion above max_levels
constexpr uint32 max_levels = 5;
if (state->local_level > max_levels) {
return false;
}
++state->local_level;
State copy = *state;
if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) &&
ParseOneCharToken(state, 'E') && MaybeAppend(state, "::") &&
ParseName(state) && Optional(ParseDiscriminator(state))) {
--state->local_level;
return true;
}
*state = copy;
if (ParseOneCharToken(state, 'Z') && ParseEncoding(state) &&
ParseTwoCharToken(state, "Es") && Optional(ParseDiscriminator(state))) {
--state->local_level;
return true;
}
*state = copy;

View File

@ -71,7 +71,7 @@
#define BASE_DEMANGLE_H_
#include "config.h"
#include "glog/logging.h"
#include <glog/logging.h>
_START_GOOGLE_NAMESPACE_

View File

@ -60,10 +60,10 @@
#define GLOG_MSVC_POP_WARNING()
#endif
#include "glog/platform.h"
#include <glog/platform.h>
#if @ac_cv_have_glog_export@
#include "glog/export.h"
#include <glog/export.h>
#endif
// We care a lot about number of bits things take up. Unfortunately,
@ -290,11 +290,11 @@ typedef void(*CustomPrefixCallback)(std::ostream& s, const LogMessageInfo& l, vo
// "program with --v=1 or more";
// VLOG_EVERY_N(1, 10)
// << "I'm printed every 10th occurrence, and when you run the program "
// "with --v=1 or more. Present occurrence is " << google::COUNTER;
// "with --v=1 or more. Present occurence is " << google::COUNTER;
// VLOG_IF_EVERY_N(1, (size > 1024), 10)
// << "I'm printed on every 10th occurrence of case when size is more "
// << "I'm printed on every 10th occurence of case when size is more "
// " than 1024, when you run the program with --v=1 or more. ";
// "Present occurrence is " << google::COUNTER;
// "Present occurence is " << google::COUNTER;
//
// The supported severity levels for macros that allow you to specify one
// are (in increasing order of severity) INFO, WARNING, ERROR, and FATAL.
@ -470,9 +470,6 @@ DECLARE_bool(stop_logging_if_full_disk);
// Use UTC time for logging
DECLARE_bool(log_utc_time);
// Mailer used to send logging email
DECLARE_string(logmailer);
// Log messages below the GOOGLE_STRIP_LOG level will be compiled away for
// security reasons. See LOG(severtiy) below.
@ -599,8 +596,8 @@ DECLARE_string(logmailer);
@ac_google_start_namespace@
// They need the definitions of integer types.
#include "glog/log_severity.h"
#include "glog/vlog_is_on.h"
#include <glog/log_severity.h>
#include <glog/vlog_is_on.h>
// Initialize google's logging library. You will see the program name
// specified by argv0 in log outputs.
@ -845,7 +842,7 @@ DEFINE_CHECK_OP_IMPL(Check_GT, > )
#define CHECK_OP_LOG(name, op, val1, val2, log) CHECK((val1) op (val2))
#elif DCHECK_IS_ON()
// In debug mode, avoid constructing CheckOpStrings if possible,
// to reduce the overhead of CHECK statements by 2x.
// to reduce the overhead of CHECK statments by 2x.
// Real DCHECK-heavy tests have seen 1.5x speedups.
// The meaning of "string" might be different between now and
@ -1045,13 +1042,13 @@ namespace google {
constexpr std::chrono::nanoseconds LOG_TIME_PERIOD = \
std::chrono::duration_cast<std::chrono::nanoseconds>( \
std::chrono::duration<double>(seconds)); \
static std::atomic<@ac_google_namespace@::int64> LOG_PREVIOUS_TIME_RAW; \
static std::atomic<@ac_google_namespace@ ::int64> LOG_PREVIOUS_TIME_RAW; \
GLOG_IFDEF_THREAD_SANITIZER( \
AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_TIME_PERIOD, \
sizeof(@ac_google_namespace@::int64), "")); \
sizeof(@ac_google_namespace @ ::int64), "")); \
GLOG_IFDEF_THREAD_SANITIZER( \
AnnotateBenignRaceSized(__FILE__, __LINE__, &LOG_PREVIOUS_TIME_RAW, \
sizeof(@ac_google_namespace@::int64), "")); \
sizeof(@ac_google_namespace @ ::int64), "")); \
const auto LOG_CURRENT_TIME = \
std::chrono::duration_cast<std::chrono::nanoseconds>( \
std::chrono::steady_clock::now().time_since_epoch()); \
@ -1065,8 +1062,8 @@ namespace google {
.count(), \
std::memory_order_relaxed); \
if (LOG_TIME_DELTA > LOG_TIME_PERIOD) \
@ac_google_namespace@::LogMessage( \
__FILE__, __LINE__, @ac_google_namespace@::GLOG_##severity) \
@ac_google_namespace@ ::LogMessage( \
__FILE__, __LINE__, @ac_google_namespace@ ::GLOG_##severity) \
.stream()
#define SOME_KIND_OF_LOG_EVERY_N(severity, n, what_to_do) \
@ -1347,15 +1344,6 @@ GLOG_MSVC_PUSH_DISABLE_WARNING(4275)
class GLOG_EXPORT LogStream : public std::ostream {
GLOG_MSVC_POP_WARNING()
public:
#if defined __has_attribute
# if __has_attribute (used)
// In some cases, like when compiling glog as a static library with GCC and
// linking against a Clang-built executable, this constructor will be
// removed by the linker. We use this attribute to prevent the linker from
// discarding it.
__attribute__ ((used))
# endif
#endif
LogStream(char *buf, int len, int64 ctr)
: std::ostream(NULL),
streambuf_(buf, len),
@ -1437,7 +1425,7 @@ public:
// is so that streaming can be done more efficiently.
static const size_t kMaxLogMessageLen;
// These should not be called directly outside of logging.*,
// Theses should not be called directly outside of logging.*,
// only passed as SendMethod arguments to other LogMessage methods:
void SendToLog(); // Actually dispatch to the logs
void SendToSyslogAndLog(); // Actually dispatch to syslog and the logs
@ -1664,8 +1652,8 @@ GLOG_EXPORT void LogToStderr();
GLOG_EXPORT void SetEmailLogging(LogSeverity min_severity,
const char* addresses);
// A simple function that sends email. dest is a comma-separated
// list of addresses. Thread-safe.
// A simple function that sends email. dest is a commma-separated
// list of addressess. Thread-safe.
GLOG_EXPORT bool SendEmail(const char* dest, const char* subject,
const char* body);
@ -1780,11 +1768,11 @@ class GLOG_EXPORT NullStream : public LogMessage::LogStream {
// (they'll never be actually displayed). This will be needed if a
// NullStream& is implicitly converted to LogStream&, in which case
// the overloaded NullStream::operator<< will not be invoked.
NullStream();
NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) { }
NullStream(const char* /*file*/, int /*line*/,
const CheckOpString& /*result*/);
NullStream& stream();
const CheckOpString& /*result*/) :
LogMessage::LogStream(message_buffer_, 1, 0) { }
NullStream &stream() { return *this; }
private:
// A very short buffer for messages (which we discard anyway). This
// will be needed if NullStream& converted to LogStream& (e.g. as a
@ -1805,8 +1793,17 @@ inline NullStream& operator<<(NullStream &str, const T &) { return str; }
// trace), like LogMessageFatal.
class GLOG_EXPORT NullStreamFatal : public NullStream {
public:
using NullStream::NullStream;
[[noreturn]] ~NullStreamFatal();
NullStreamFatal() { }
NullStreamFatal(const char* file, int line, const CheckOpString& result) :
NullStream(file, line, result) { }
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4722)
#endif // _MSC_VER
[[noreturn]] ~NullStreamFatal() throw() { _exit(EXIT_FAILURE); }
#if defined(_MSC_VER)
#pragma warning(pop)
#endif // _MSC_VER
};
// Install a signal handler that will dump signal information and a stack

View File

@ -39,9 +39,10 @@
#include <ctime>
@ac_google_start_namespace@
#include "glog/log_severity.h"
#include "glog/logging.h"
#include "glog/vlog_is_on.h"
#include <glog/log_severity.h>
#include <glog/logging.h>
#include <glog/vlog_is_on.h>
#if defined(__GNUC__)
#pragma GCC diagnostic push

View File

@ -61,9 +61,9 @@
#ifndef BASE_VLOG_IS_ON_H_
#define BASE_VLOG_IS_ON_H_
#include <cstddef>
#include <glog/log_severity.h>
#include "glog/log_severity.h"
#include <cstddef>
#if defined(__GNUC__)
// We emit an anonymous static int* variable at every VLOG_IS_ON(n) site.
@ -75,8 +75,6 @@
#define VLOG_IS_ON(verboselevel) \
__extension__ \
({ static @ac_google_namespace@::SiteFlag vlocal__ = {NULL, NULL, 0, NULL}; \
GLOG_IFDEF_THREAD_SANITIZER( \
AnnotateBenignRaceSized(__FILE__, __LINE__, &vlocal__, sizeof(@ac_google_namespace@::SiteFlag), "")); \
@ac_google_namespace@::int32 verbose_level__ = (verboselevel); \
(vlocal__.level == NULL ? @ac_google_namespace@::InitVLOG3__(&vlocal__, &FLAGS_v, \
__FILE__, verbose_level__) : *vlocal__.level >= verbose_level__); \
@ -106,7 +104,7 @@ struct SiteFlag {
SiteFlag* next;
};
// Helper routine which determines the logging info for a particular VLOG site.
// Helper routine which determines the logging info for a particalur VLOG site.
// site_flag is the address of the site-local pointer to the controlling
// verbosity level
// site_default is the default to use for *site_flag

View File

@ -33,11 +33,8 @@
#include <algorithm>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <iterator>
#include <string>
#ifdef HAVE_UNISTD_H
# include <unistd.h> // For _exit.
#endif
@ -59,23 +56,18 @@
#ifdef HAVE_SYSLOG_H
# include <syslog.h>
#endif
#ifdef HAVE__CHSIZE_S
#include <io.h> // for truncate log file
#endif
#include <vector>
#include <cerrno> // for errno
#include <sstream>
#include <regex>
#include <cctype> // for std::isspace
#ifdef GLOG_OS_WINDOWS
#include "windows/dirent.h"
#else
#include <dirent.h> // for automatic removal of old logs
#endif
#include "base/commandlineflags.h" // to get the program name
#include "base/commandlineflags.h" // to get the program name
#include <glog/logging.h>
#include <glog/raw_logging.h>
#include "base/googleinit.h"
#include "glog/logging.h"
#include "glog/raw_logging.h"
#ifdef HAVE_STACKTRACE
# include "stacktrace.h"
@ -1558,15 +1550,9 @@ static LogMessage::LogMessageData fatal_msg_data_shared;
// allocations).
static thread_local bool thread_data_available = true;
#if defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
// std::aligned_storage is deprecated in C++23
alignas(LogMessage::LogMessageData) static thread_local std::byte
thread_msg_data[sizeof(LogMessage::LogMessageData)];
#else // !(defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L)
static thread_local std::aligned_storage<
sizeof(LogMessage::LogMessageData),
alignof(LogMessage::LogMessageData)>::type thread_msg_data;
#endif // defined(__cpp_lib_byte) && __cpp_lib_byte >= 201603L
#endif // defined(GLOG_THREAD_LOCAL_STORAGE)
LogMessage::LogMessageData::LogMessageData()
@ -1932,14 +1918,6 @@ void LogMessage::RecordCrashReason(
GLOG_EXPORT logging_fail_func_t g_logging_fail_func =
reinterpret_cast<logging_fail_func_t>(&abort);
NullStream::NullStream() : LogMessage::LogStream(message_buffer_, 1, 0) {}
NullStream::NullStream(const char* /*file*/, int /*line*/,
const CheckOpString& /*result*/)
: LogMessage::LogStream(message_buffer_, 1, 0) {}
NullStream& NullStream::stream() { return *this; }
NullStreamFatal::~NullStreamFatal() { _exit(EXIT_FAILURE); }
void InstallFailureFunction(logging_fail_func_t fail_func) {
g_logging_fail_func = fail_func;
}
@ -2227,13 +2205,6 @@ static string ShellEscape(const string& src) {
}
return result;
}
// Trim whitespace from both ends of the provided string.
static inline void trim(std::string &s) {
const auto toRemove = [](char ch) { return std::isspace(ch) == 0; };
s.erase(s.begin(), std::find_if(s.begin(), s.end(), toRemove));
s.erase(std::find_if(s.rbegin(), s.rend(), toRemove).base(), s.end());
}
#endif
// use_logging controls whether the logging functions LOG/VLOG are used
@ -2243,47 +2214,6 @@ static bool SendEmailInternal(const char*dest, const char *subject,
const char*body, bool use_logging) {
#ifndef GLOG_OS_EMSCRIPTEN
if (dest && *dest) {
// Split the comma-separated list of email addresses, validate each one and
// build a sanitized new comma-separated string without whitespace.
std::istringstream ss(dest);
std::ostringstream sanitized_dests;
std::string s;
while (std::getline(ss, s, ',')) {
trim(s);
if (s.empty()) {
continue;
}
// We validate the provided email addresses using the same regular
// expression that HTML5 uses[1], except that we require the address to
// start with an alpha-numeric character. This is because we don't want to
// allow email addresses that start with a special character, such as a
// pipe or dash, which could be misunderstood as a command-line flag by
// certain versions of `mail` that are vulnerable to command injection.[2]
// [1] https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
// [2] e.g. https://nvd.nist.gov/vuln/detail/CVE-2004-2771
if (!std::regex_match(
s,
std::regex("^[a-zA-Z0-9]"
"[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]*@[a-zA-Z0-9]"
"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9]"
"(?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$"))) {
if (use_logging) {
VLOG(1) << "Invalid destination email address:" << s;
} else {
fprintf(stderr, "Invalid destination email address: %s\n",
s.c_str());
}
return false;
}
if (!sanitized_dests.str().empty()) {
sanitized_dests << ",";
}
sanitized_dests << s;
}
// Avoid dangling reference
const std::string& tmp = sanitized_dests.str();
dest = tmp.c_str();
if ( use_logging ) {
VLOG(1) << "Trying to send TITLE:" << subject
<< " BODY:" << body << " to " << dest;
@ -2305,8 +2235,8 @@ static bool SendEmailInternal(const char*dest, const char *subject,
FILE* pipe = popen(cmd.c_str(), "w");
if (pipe != nullptr) {
// Add the body if we have one
if (body) {
// Add the body if we have one
if (body) {
fwrite(body, sizeof(char), strlen(body), pipe);
}
bool ok = pclose(pipe) != -1;
@ -2398,13 +2328,8 @@ const vector<string>& GetLoggingDirectories() {
logging_directories_list = new vector<string>;
if ( !FLAGS_log_dir.empty() ) {
// Ensure the specified path ends with a directory delimiter.
if (std::find(std::begin(possible_dir_delim), std::end(possible_dir_delim),
FLAGS_log_dir.back()) == std::end(possible_dir_delim)) {
logging_directories_list->push_back(FLAGS_log_dir + "/");
} else {
logging_directories_list->push_back(FLAGS_log_dir);
}
// A dir was specified, we should use it
logging_directories_list->push_back(FLAGS_log_dir);
} else {
GetTempDirectories(logging_directories_list);
#ifdef GLOG_OS_WINDOWS
@ -2442,7 +2367,7 @@ void GetExistingTempDirectories(vector<string>* list) {
}
void TruncateLogFile(const char *path, uint64 limit, uint64 keep) {
#if defined(HAVE_UNISTD_H) || defined(HAVE__CHSIZE_S)
#ifdef HAVE_UNISTD_H
struct stat statbuf;
const int kCopyBlockSize = 8 << 10;
char copybuf[kCopyBlockSize];
@ -2463,11 +2388,7 @@ void TruncateLogFile(const char *path, uint64 limit, uint64 keep) {
// all of base/...) with -D_FILE_OFFSET_BITS=64 but that's
// rather scary.
// Instead just truncate the file to something we can manage
#ifdef HAVE__CHSIZE_S
if (_chsize_s(fd, 0) != 0) {
#else
if (truncate(path, 0) == -1) {
#endif
PLOG(ERROR) << "Unable to truncate " << path;
} else {
LOG(ERROR) << "Truncated " << path << " due to EFBIG error";
@ -2512,11 +2433,7 @@ void TruncateLogFile(const char *path, uint64 limit, uint64 keep) {
// Truncate the remainder of the file. If someone else writes to the
// end of the file after our last read() above, we lose their latest
// data. Too bad ...
#ifdef HAVE__CHSIZE_S
if (_chsize_s(fd, write_offset) != 0) {
#else
if (ftruncate(fd, write_offset) == -1) {
#endif
PLOG(ERROR) << "Unable to truncate " << path;
}

View File

@ -36,12 +36,13 @@
#define GLOG_SRC_MOCK_LOG_H_
// For GOOGLE_NAMESPACE. This must go first so we get _XOPEN_SOURCE.
#include <gmock/gmock.h>
#include "utilities.h"
#include <string>
#include "glog/logging.h"
#include "utilities.h"
#include <gmock/gmock.h>
#include <glog/logging.h>
_START_GOOGLE_NAMESPACE_
namespace glog_testing {

View File

@ -39,14 +39,12 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for close() and write()
#endif
#include <fcntl.h> // for open()
#include <fcntl.h> // for open()
#include <ctime>
#include "base/commandlineflags.h"
#include "config.h"
#include "glog/logging.h" // To pick up flag settings etc.
#include "glog/raw_logging.h"
#include <glog/logging.h> // To pick up flag settings etc.
#include <glog/raw_logging.h>
#include "base/commandlineflags.h"
#ifdef HAVE_STACKTRACE
# include "stacktrace.h"
@ -62,8 +60,7 @@
#endif
#if (defined(HAVE_SYSCALL_H) || defined(HAVE_SYS_SYSCALL_H)) && \
(!(defined(GLOG_OS_MACOSX)) && !(defined(GLOG_OS_OPENBSD))) && \
!defined(GLOG_OS_EMSCRIPTEN)
(!(defined(GLOG_OS_MACOSX))) && !defined(GLOG_OS_EMSCRIPTEN)
#define safe_write(fd, s, len) syscall(SYS_write, fd, s, len)
#else
// Not so safe, but what can you do?

View File

@ -31,13 +31,13 @@
//
// Implementation of InstallFailureSignalHandler().
#include <csignal>
#include <ctime>
#include "glog/logging.h"
#include "utilities.h"
#include "stacktrace.h"
#include "symbolize.h"
#include "utilities.h"
#include <glog/logging.h>
#include <csignal>
#include <ctime>
#ifdef HAVE_UCONTEXT_H
# include <ucontext.h>
#endif

View File

@ -34,7 +34,7 @@
#define BASE_STACKTRACE_H_
#include "config.h"
#include "glog/logging.h"
#include <glog/logging.h>
_START_GOOGLE_NAMESPACE_

View File

@ -37,7 +37,7 @@ extern "C" {
#define UNW_LOCAL_ONLY
#include <libunwind.h>
}
#include "glog/raw_logging.h"
#include <glog/raw_logging.h>
#include "stacktrace.h"
_START_GOOGLE_NAMESPACE_

View File

@ -121,7 +121,7 @@ int GetStackTrace(void** result, int max_depth, int skip_count) {
// This check is in case the compiler doesn't define _CALL_SYSV.
result[n++] = *(sp+1);
#else
#error Need to specify the PPC ABI for your architecture.
#error Need to specify the PPC ABI for your archiecture.
#endif
}
// Use strict unwinding rules.

View File

@ -27,15 +27,14 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "stacktrace.h"
#include "utilities.h"
#include <cstdio>
#include <cstdlib>
#include "base/commandlineflags.h"
#include "config.h"
#include "glog/logging.h"
#include "utilities.h"
#include "base/commandlineflags.h"
#include <glog/logging.h>
#include "stacktrace.h"
#ifdef HAVE_EXECINFO_BACKTRACE_SYMBOLS
# include <execinfo.h>

View File

@ -119,6 +119,7 @@ _END_GOOGLE_NAMESPACE_
#include <elf.h>
#endif
#include <fcntl.h>
#include <glog/raw_logging.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@ -132,7 +133,6 @@ _END_GOOGLE_NAMESPACE_
#include <cstring>
#include "config.h"
#include "glog/raw_logging.h"
#include "symbolize.h"
// Re-runs fn until it doesn't cause EINTR.
@ -535,8 +535,10 @@ OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,
// Iterate over maps and look for the map containing the pc. Then
// look into the symbol tables inside.
char buf[1024]; // Big enough for line of sane /proc/self/maps
unsigned num_maps = 0;
LineReader reader(wrapped_maps_fd.get(), buf, sizeof(buf), 0);
while (true) {
num_maps++;
const char *cursor;
const char *eol;
if (!reader.ReadLine(&cursor, &eol)) { // EOF or malformed line.

View File

@ -54,9 +54,9 @@
#ifndef BASE_SYMBOLIZE_H_
#define BASE_SYMBOLIZE_H_
#include "config.h"
#include "glog/logging.h"
#include "utilities.h"
#include "config.h"
#include <glog/logging.h>
#ifdef HAVE_SYMBOLIZE

View File

@ -292,8 +292,6 @@ pid_t GetTID() {
return getpid(); // Linux: getpid returns thread ID when gettid is absent
#elif defined GLOG_OS_WINDOWS && !defined GLOG_OS_CYGWIN
return static_cast<pid_t>(GetCurrentThreadId());
#elif defined GLOG_OS_OPENBSD
return getthrid();
#elif defined(HAVE_PTHREAD)
// If none of the techniques above worked, we use pthread_self().
return (pid_t)(uintptr_t)pthread_self();

View File

@ -29,7 +29,7 @@
//
// Author: Shinichiro Hamaji
//
// Define utilities for glog internal usage.
// Define utilties for glog internal usage.
#ifndef UTILITIES_H__
#define UTILITIES_H__
@ -52,10 +52,11 @@
#define PRIXS __PRIS_PREFIX "X"
#define PRIoS __PRIS_PREFIX "o"
#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE
#include <string>
#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE
#include "glog/logging.h"
#include <glog/logging.h>
#if defined(GLOG_OS_WINDOWS)
# include "port.h"
@ -173,7 +174,7 @@ inline T sync_val_compare_and_swap(T* ptr, T oldval, T newval) {
:"=a"(ret)
// GCC may produces %sil or %dil for
// constraint "r", but some of apple's gas
// doesn't know the 8 bit registers.
// dosn't know the 8 bit registers.
// We use "q" to avoid these registers.
:"q"(newval), "q"(ptr), "a"(oldval)
:"memory", "cc");

View File

@ -32,17 +32,17 @@
// Broken out from logging.cc by Soren Lassen
// logging_unittest.cc covers the functionality herein
#include "utilities.h"
#include <cstring>
#include <cstdlib>
#include <cerrno>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include "base/commandlineflags.h"
#include <glog/logging.h>
#include <glog/raw_logging.h>
#include "base/googleinit.h"
#include "glog/logging.h"
#include "glog/raw_logging.h"
#include "utilities.h"
// glog doesn't have annotation
#define ANNOTATE_BENIGN_RACE(address, description)

View File

@ -1,6 +1,20 @@
FILE(GLOB HEADER_FILES ../include/fst/*.h)
if(WIN32)
add_library(fst STATIC
compat.cc
flags.cc
fst-types.cc
fst.cc
mapped-file.cc
properties.cc
symbol-table.cc
symbol-table-ops.cc
util.cc
weight.cc
${HEADER_FILES}
)
else()
add_library(fst
compat.cc
flags.cc
@ -14,6 +28,8 @@ add_library(fst
weight.cc
${HEADER_FILES}
)
endif()
set_target_properties(fst PROPERTIES
SOVERSION "${SOVERSION}"
)

View File

@ -1,6 +1,7 @@
# Libtorch-python
## Export the model
### Install [modelscope and funasr](https://github.com/alibaba-damo-academy/FunASR#installation)
```shell
@ -18,14 +19,16 @@ pip install onnx onnxruntime # Optional, for onnx quantization
python -m funasr.export.export_model --model-name damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch --export-dir ./export --type torch --quantize True
```
## Install the `funasr_torch`.
## Install the `funasr_torch`
install from pip
```shell
pip install -U funasr_torch
# For the users in China, you could install with the command:
# pip install -U funasr_torch -i https://mirror.sjtu.edu.cn/pypi/web/simple
```
or install from source code
```shell
@ -36,11 +39,13 @@ pip install -e ./
# pip install -e ./ -i https://mirror.sjtu.edu.cn/pypi/web/simple
```
## Run the demo.
## Run the demo
- Model_dir: the model path, which contains `model.torchscripts`, `config.yaml`, `am.mvn`.
- Input: wav formt file, support formats: `str, np.ndarray, List[str]`
- Output: `List[str]`: recognition result.
- Example:
```python
from funasr_torch import Paraformer
@ -55,7 +60,7 @@ pip install -e ./
## Performance benchmark
Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/funasr/runtime/python/benchmark_libtorch.md)
Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/runtime/docs/benchmark_libtorch.md)
## Speed
@ -70,4 +75,5 @@ Test [wav, 5.53s, 100 times avg.](https://isv-data.oss-cn-hangzhou.aliyuncs.com/
| Onnx | 0.038 |
## Acknowledge
This project is maintained by [FunASR community](https://github.com/alibaba-damo-academy/FunASR).

View File

@ -180,7 +180,7 @@ Output: `List[str]`: recognition result
## Performance benchmark
Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/funasr/runtime/docs/benchmark_onnx.md)
Please ref to [benchmark](https://github.com/alibaba-damo-academy/FunASR/blob/main/runtime/docs/benchmark_onnx.md)
## Acknowledge

View File

@ -111,7 +111,9 @@ if(ENABLE_FST)
# with some patch to fix the make errors.
add_subdirectory(${PROJECT_SOURCE_DIR}/../onnxruntime/third_party/openfst openfst)
include_directories(${openfst_SOURCE_DIR}/src/include)
if(WIN32)
include_directories(${openfst_SOURCE_DIR}/src/lib)
endif()
endif()