Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
xuning
/
sherpaonnx
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Fangjun Kuang
2023-08-10 11:22:36 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2023-08-10 11:22:36 +0800
Commit
865fd1e0176540a1fcc83804acafce73df9833ad
865fd1e0
1 parent
a04221a1
Support pkg-config (#253)
显示空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
167 行增加
和
5 行删除
.github/workflows/pkg-config.yaml
CMakeLists.txt
cmake/cargs.cmake
cmake/portaudio.cmake
cmake/sherpa-onnx.pc.in
scripts/dotnet/generate.py
sherpa-onnx/csrc/text-utils.h
.github/workflows/pkg-config.yaml
0 → 100644
查看文件 @
865fd1e
name
:
pkg-config
on
:
push
:
branches
:
-
master
-
pkg-config
tags
:
-
'
*'
paths
:
-
'
.github/workflows/pkg-config.yaml'
-
'
CMakeLists.txt'
-
'
cmake/**'
-
'
sherpa-onnx/csrc/*'
-
'
sherpa-onnx/c-api/*'
-
'
c-api-examples/**'
pull_request
:
branches
:
-
master
paths
:
-
'
.github/workflows/pkg-config.yaml'
-
'
CMakeLists.txt'
-
'
cmake/**'
-
'
sherpa-onnx/csrc/*'
-
'
sherpa-onnx/c-api/*'
workflow_dispatch
:
concurrency
:
group
:
pkg-config-${{ github.ref }}
cancel-in-progress
:
true
jobs
:
linux
:
runs-on
:
${{ matrix.os }}
name
:
${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }}
strategy
:
fail-fast
:
false
matrix
:
os
:
[
ubuntu-latest
,
macos-latest
]
build_type
:
[
Release
,
Debug
]
lib_type
:
[
shared
,
static
]
steps
:
-
uses
:
actions/checkout@v2
with
:
fetch-depth
:
0
-
name
:
Configure CMake
shell
:
bash
run
:
|
mkdir build
cd build
if [[ ${{ matrix.lib_type }} == "shared" ]]; then
cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=ON ..
else
cmake -DSHERPA_ONNX_ENABLE_C_API=ON -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_INSTALL_PREFIX=./install -DBUILD_SHARED_LIBS=OFF ..
fi
-
name
:
Build sherpa-onnx for ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }}
shell
:
bash
run
:
|
cd build
make -j2
make install
ls -lh lib
ls -lh bin
-
name
:
Install tree
if
:
matrix.os == 'ubuntu-latest'
shell
:
bash
run
:
|
sudo apt-get install tree
-
name
:
Install tree
if
:
matrix.os == 'macos-latest'
shell
:
bash
run
:
|
brew install tree
-
name
:
Display generated files of sherpa-onnx for ${{ matrix.os }} ${{ matrix.build_type }} ${{ matrix.lib_type }}
shell
:
bash
run
:
|
tree build/install
ls -lh build/install
cat build/install/sherpa-onnx.pc
-
name
:
Build C API example
shell
:
bash
run
:
|
export PKG_CONFIG_PATH=$PWD/build/install:$PKG_CONFIG_PATH
cd c-api-examples
gcc -o decode-file-c-api $(pkg-config --cflags sherpa-onnx) ./decode-file-c-api.c $(pkg-config --libs sherpa-onnx)
./decode-file-c-api --help
-
name
:
Test online transducer (C API)
shell
:
bash
run
:
|
export PATH=$PWD/c-api-examples:$PATH
export EXE=decode-file-c-api
.github/scripts/test-online-transducer.sh
...
...
CMakeLists.txt
查看文件 @
865fd1e
cmake_minimum_required
(
VERSION 3.13 FATAL_ERROR
)
project
(
sherpa-onnx
)
set
(
SHERPA_ONNX_VERSION
"1.7.
0
"
)
set
(
SHERPA_ONNX_VERSION
"1.7.
1
"
)
# Disable warning about
#
...
...
@@ -167,3 +167,22 @@ if(SHERPA_ONNX_ENABLE_C_API)
add_subdirectory
(
c-api-examples
)
endif
()
message
(
STATUS
"CMAKE_CXX_FLAGS:
${
CMAKE_CXX_FLAGS
}
"
)
if
(
NOT BUILD_SHARED_LIBS
)
if
(
APPLE
)
set
(
SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS
"-lc++"
)
endif
()
if
(
UNIX AND NOT APPLE
)
set
(
SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS
"-lstdc++ -lm"
)
endif
()
endif
()
# See https://people.freedesktop.org/~dbn/pkg-config-guide.html
configure_file
(
cmake/sherpa-onnx.pc.in
${
PROJECT_BINARY_DIR
}
/sherpa-onnx.pc @ONLY
)
install
(
FILES
${
PROJECT_BINARY_DIR
}
/sherpa-onnx.pc
DESTINATION
.
)
...
...
cmake/cargs.cmake
查看文件 @
865fd1e
...
...
@@ -2,10 +2,11 @@ function(download_cargs)
include
(
FetchContent
)
set
(
cargs_URL
"https://github.com/likle/cargs/archive/refs/tags/v1.0.3.tar.gz"
)
set
(
cargs_URL2
"https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/cargs-1.0.3.tar.gz"
)
set
(
cargs_HASH
"SHA256=ddba25bd35e9c6c75bc706c126001b8ce8e084d40ef37050e6aa6963e836eb8b"
)
# If you don't have access to the Internet,
# please pre-download
asio
# please pre-download
cargs
set
(
possible_file_locations
$ENV{HOME}/Downloads/cargs-1.0.3.tar.gz
${
PROJECT_SOURCE_DIR
}
/cargs-1.0.3.tar.gz
...
...
@@ -19,11 +20,18 @@ function(download_cargs)
set
(
cargs_URL
"
${
f
}
"
)
file
(
TO_CMAKE_PATH
"
${
cargs_URL
}
"
cargs_URL
)
message
(
STATUS
"Found local downloaded cargs:
${
cargs_URL
}
"
)
set
(
cargs_URL2
)
break
()
endif
()
endforeach
()
FetchContent_Declare
(
cargs URL
${
cargs_URL
}
URL_HASH
${
cargs_HASH
}
)
FetchContent_Declare
(
cargs
URL
${
cargs_URL
}
${
cargs_URL2
}
URL_HASH
${
cargs_HASH
}
)
FetchContent_GetProperties
(
cargs
)
if
(
NOT cargs_POPULATED
)
...
...
@@ -32,6 +40,11 @@ function(download_cargs)
endif
()
message
(
STATUS
"cargs is downloaded to
${
cargs_SOURCE_DIR
}
"
)
add_subdirectory
(
${
cargs_SOURCE_DIR
}
${
cargs_BINARY_DIR
}
EXCLUDE_FROM_ALL
)
install
(
TARGETS cargs DESTINATION lib
)
install
(
FILES
${
cargs_SOURCE_DIR
}
/include/cargs.h
DESTINATION include
)
endfunction
()
download_cargs
()
...
...
cmake/portaudio.cmake
查看文件 @
865fd1e
...
...
@@ -57,6 +57,9 @@ function(download_portaudio)
if
(
BUILD_SHARED_LIBS
)
set_target_properties
(
portaudio PROPERTIES OUTPUT_NAME
"sherpa-onnx-portaudio"
)
if
(
NOT WIN32
)
target_compile_options
(
portaudio PRIVATE
"-Wno-deprecated-declarations"
)
endif
()
if
(
SHERPA_ONNX_ENABLE_PYTHON AND WIN32
)
install
(
TARGETS portaudio DESTINATION ..
)
...
...
@@ -65,6 +68,9 @@ function(download_portaudio)
endif
()
else
()
set_target_properties
(
portaudio_static PROPERTIES OUTPUT_NAME
"sherpa-onnx-portaudio_static"
)
if
(
NOT WIN32
)
target_compile_options
(
portaudio_static PRIVATE
"-Wno-deprecated-declarations"
)
endif
()
if
(
SHERPA_ONNX_ENABLE_PYTHON AND WIN32
)
install
(
TARGETS portaudio_static DESTINATION ..
)
else
()
...
...
cmake/sherpa-onnx.pc.in
0 → 100644
查看文件 @
865fd1e
prefix="@CMAKE_INSTALL_PREFIX@"
exec_prefix="${prefix}"
includedir="${prefix}/include"
libdir="${exec_prefix}/lib"
Name: sherpa-onnx
Description: pkg-config for sherpa-onnx
URL: https://github.com/k2-fsa/sherpa-onnx
Version: @SHERPA_ONNX_VERSION@
Cflags: -I"${includedir}"
# Note: -lcargs is required only for the following file
# https://github.com/k2-fsa/sherpa-onnx/blob/master/c-api-examples/decode-file-c-api.c
# We add it here so that users don't need to specify -lcargs when compiling decode-file-c-api.c
Libs: -L"${libdir}" -lsherpa-onnx-c-api -lsherpa-onnx-core -lonnxruntime -lkaldi-native-fbank-core -lcargs -Wl,-rpath,${libdir} @SHERPA_ONNX_PKG_CONFIG_EXTRA_LIBS@
...
...
scripts/dotnet/generate.py
查看文件 @
865fd1e
...
...
@@ -82,13 +82,17 @@ def process_windows(s):
"sherpa-onnx-c-api.dll"
,
"sherpa-onnx-core.dll"
,
]
version
=
get_version
()
prefix1
=
f
"{SHERPA_ONNX_DIR}/windows/sherpa_onnx/lib/"
prefix2
=
f
"{SHERPA_ONNX_DIR}/windows/sherpa_onnx/"
prefix3
=
f
"{SHERPA_ONNX_DIR}/windows/"
prefix4
=
f
"{SHERPA_ONNX_DIR}/windows/sherpa_onnx-${version}.data/data/bin/"
lib_list
=
[]
for
lib
in
libs
:
for
prefix
in
[
prefix1
,
prefix2
,
prefix3
]:
for
prefix
in
[
prefix1
,
prefix2
,
prefix3
,
prefix4
]:
f
=
Path
(
prefix
)
/
lib
if
f
.
is_file
():
lib_list
.
append
(
str
(
f
))
...
...
sherpa-onnx/csrc/text-utils.h
查看文件 @
865fd1e
...
...
@@ -4,7 +4,7 @@
// Copyright 2023 Xiaomi Corporation
#ifndef SHERPA_ONNX_CSRC_TEXT_UTILS_H_
#define SHERPA_ONNX_CSRC_TEXT_UTILS_H_
#include <errno.h>
.
#include <errno.h>
#include <stdlib.h>
#include <limits>
...
...
请
注册
或
登录
后发表评论