-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ccb1879
commit 503eacc
Showing
11 changed files
with
190 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
name: build-pip | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- '.github/workflows/build-pip.yml' | ||
- 'CMakeLists.txt' | ||
- 'cmake/**' | ||
- 'kaldi-decoder/csrc/**' | ||
- 'kaldi-decoder/python/**' | ||
- 'setup.py' | ||
pull_request: | ||
branches: | ||
- master | ||
paths: | ||
- '.github/workflows/build-pip.yml' | ||
- 'CMakeLists.txt' | ||
- 'cmake/**' | ||
- 'kaldi-decoder/csrc/**' | ||
- 'kaldi-decoder/python/**' | ||
- 'setup.py' | ||
|
||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: build-pip-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-pip: | ||
name: ${{ matrix.os }} ${{ matrix.python-version }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | ||
fail-fast: false | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: ccache | ||
uses: hendrikmuhs/ccache-action@v1.2 | ||
with: | ||
key: ${{ matrix.os }}-${{ matrix.python-version }} | ||
|
||
# see https://github.com/microsoft/setup-msbuild | ||
- name: Add msbuild to PATH | ||
if: startsWith(matrix.os, 'windows') | ||
uses: microsoft/setup-msbuild@v1.0.2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Build | ||
shell: bash | ||
run: | | ||
export CMAKE_CXX_COMPILER_LAUNCHER=ccache | ||
export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" | ||
cmake --version | ||
python3 -m pip install -U pip wheel numpy setuptools | ||
python3 setup.py bdist_wheel | ||
ls -lh dist | ||
python3 -m pip install ./dist/kaldi*.whl | ||
cd ../.. | ||
python3 -c "import kaldi_decoder; print(kaldi_decoder.__version__)" | ||
python3 -c "import kaldi_decoder; print(kaldi_decoder.__file__)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Copyright (c) 2020 Xiaomi Corporation (author: Fangjun Kuang) | ||
|
||
function(download_openfst) | ||
include(FetchContent) | ||
|
||
set(openfst_URL "https://github.com/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-06-13.tar.gz") | ||
set(openfst_URL2 "https://hub.nuaa.cf/csukuangfj/openfst/archive/refs/tags/sherpa-onnx-2024-06-13.tar.gz") | ||
set(openfst_HASH "SHA256=f10a71c6b64d89eabdc316d372b956c30c825c7c298e2f20c780320e8181ffb6") | ||
|
||
# If you don't have access to the Internet, | ||
# please pre-download it | ||
set(possible_file_locations | ||
$ENV{HOME}/Downloads/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
${CMAKE_SOURCE_DIR}/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
${CMAKE_BINARY_DIR}/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
/tmp/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
/star-fj/fangjun/download/github/openfst-sherpa-onnx-2024-06-13.tar.gz | ||
) | ||
|
||
foreach(f IN LISTS possible_file_locations) | ||
if(EXISTS ${f}) | ||
set(openfst_URL "${f}") | ||
file(TO_CMAKE_PATH "${openfst_URL}" openfst_URL) | ||
set(openfst_URL2) | ||
break() | ||
endif() | ||
endforeach() | ||
|
||
set(HAVE_BIN OFF CACHE BOOL "" FORCE) | ||
set(HAVE_SCRIPT OFF CACHE BOOL "" FORCE) | ||
set(HAVE_COMPACT OFF CACHE BOOL "" FORCE) | ||
set(HAVE_COMPRESS OFF CACHE BOOL "" FORCE) | ||
set(HAVE_CONST OFF CACHE BOOL "" FORCE) | ||
set(HAVE_FAR OFF CACHE BOOL "" FORCE) | ||
set(HAVE_GRM OFF CACHE BOOL "" FORCE) | ||
set(HAVE_PDT OFF CACHE BOOL "" FORCE) | ||
set(HAVE_MPDT OFF CACHE BOOL "" FORCE) | ||
set(HAVE_LINEAR OFF CACHE BOOL "" FORCE) | ||
set(HAVE_LOOKAHEAD OFF CACHE BOOL "" FORCE) | ||
set(HAVE_NGRAM OFF CACHE BOOL "" FORCE) | ||
set(HAVE_PYTHON OFF CACHE BOOL "" FORCE) | ||
set(HAVE_SPECIAL OFF CACHE BOOL "" FORCE) | ||
|
||
if(NOT WIN32) | ||
FetchContent_Declare(openfst | ||
URL | ||
${openfst_URL} | ||
${openfst_URL2} | ||
URL_HASH ${openfst_HASH} | ||
PATCH_COMMAND | ||
sed -i.bak s/enable_testing\(\)//g "src/CMakeLists.txt" && | ||
sed -i.bak s/add_subdirectory\(test\)//g "src/CMakeLists.txt" && | ||
sed -i.bak /message/d "src/script/CMakeLists.txt" | ||
# sed -i.bak s/add_subdirectory\(script\)//g "src/CMakeLists.txt" && | ||
# sed -i.bak s/add_subdirectory\(extensions\)//g "src/CMakeLists.txt" | ||
) | ||
else() | ||
FetchContent_Declare(openfst | ||
URL ${openfst_URL} | ||
URL_HASH ${openfst_HASH} | ||
) | ||
endif() | ||
|
||
FetchContent_GetProperties(openfst) | ||
if(NOT openfst_POPULATED) | ||
message(STATUS "Downloading openfst from ${openfst_URL}") | ||
FetchContent_Populate(openfst) | ||
endif() | ||
message(STATUS "openfst is downloaded to ${openfst_SOURCE_DIR}") | ||
add_subdirectory(${openfst_SOURCE_DIR} ${openfst_BINARY_DIR} EXCLUDE_FROM_ALL) | ||
set(openfst_SOURCE_DIR ${openfst_SOURCE_DIR} PARENT_SCOPE) | ||
|
||
set_target_properties(fst PROPERTIES OUTPUT_NAME "kaldi-decoder-fst") | ||
|
||
target_include_directories(fst | ||
PUBLIC | ||
${openfst_SOURCE_DIR}/src/include | ||
) | ||
|
||
if(KALDI_DECODER_BUILD_PYTHON AND WIN32) | ||
install(TARGETS fst DESTINATION ..) | ||
else() | ||
install(TARGETS fst DESTINATION lib) | ||
endif() | ||
|
||
if(WIN32 AND BUILD_SHARED_LIBS) | ||
install(TARGETS fst DESTINATION bin) | ||
endif() | ||
endfunction() | ||
|
||
download_openfst() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters