Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
88275af
add linear spectrogram feature extractor, test=doc
SmileGoat Jan 27, 2022
a01fa86
add normalizer
SmileGoat Jan 28, 2022
f03d48f
test linear spectrogram feature
SmileGoat Feb 10, 2022
c602775
add frontend cmakelist
SmileGoat Feb 13, 2022
42c8d0d
fix typo & make build success
SmileGoat Feb 13, 2022
e57efcb
add nnet module
SmileGoat Feb 15, 2022
d14ee80
add decodable & ctc_beam_search_deocder
SmileGoat Feb 17, 2022
e904382
add offline_deocder_main
SmileGoat Feb 18, 2022
d2d53cc
add cmakelist of decoder, nnet
SmileGoat Feb 22, 2022
b584b96
Merge pull request #1400 from SmileGoat/feature_dev
zh794390558 Feb 25, 2022
406b4fc
align linear_feature & nnet
SmileGoat Mar 2, 2022
9b6f946
fix bug
SmileGoat Mar 2, 2022
ca5ed02
Merge pull request #1521 from SmileGoat/speechx_goat
zh794390558 Mar 2, 2022
cd3c57d
add build.sh & openblas
SmileGoat Mar 3, 2022
a89032d
add comment
SmileGoat Mar 4, 2022
584f659
Merge pull request #1531 from SmileGoat/speechx_dev
zh794390558 Mar 4, 2022
d7341cf
gitignore
zh794390558 Mar 4, 2022
af09260
refactor cmake
zh794390558 Mar 4, 2022
d7f55e5
reorder gflags, gtest, glog
zh794390558 Mar 4, 2022
eb4826f
Merge pull request #1535 from zh794390558/cmake
SmileGoat Mar 4, 2022
6c0af89
libsndfile
zh794390558 Mar 4, 2022
4cc3e43
Merge pull request #1536 from zh794390558/cmake
SmileGoat Mar 4, 2022
77e60de
add cmvn
SmileGoat Mar 4, 2022
c4a5be3
add comment
SmileGoat Mar 7, 2022
6a32a0b
Merge pull request #1537 from SmileGoat/add_cmvn
zh794390558 Mar 7, 2022
04eb8a2
openblas cmake
zh794390558 Mar 7, 2022
36d16ff
libsndfile from repo; rm useless openblas
zh794390558 Mar 7, 2022
3887a9b
openfst.cmake
zh794390558 Mar 7, 2022
1a1ba2b
Merge pull request #1538 from zh794390558/cmake
SmileGoat Mar 7, 2022
11dc485
move egs from codelab to examples
zh794390558 Mar 7, 2022
41feecb
format
zh794390558 Mar 7, 2022
ebc2aca
Merge pull request #1541 from zh794390558/egs
SmileGoat Mar 7, 2022
c82cf0d
add raw_audio & feature_cache
SmileGoat Mar 7, 2022
8ec6a8c
add streaming_feat_main
SmileGoat Mar 7, 2022
ac0e417
make streaming pipeline work
SmileGoat Mar 8, 2022
c769d90
make feature cache& raw audio work
SmileGoat Mar 9, 2022
7c1b432
format
SmileGoat Mar 10, 2022
22fe1c9
rename interface & add comment to Dim()
SmileGoat Mar 10, 2022
027feae
rename arg of Accept & Read
SmileGoat Mar 10, 2022
bedd2de
Merge pull request #1542 from SmileGoat/stream_feature
zh794390558 Mar 10, 2022
1f6ae1b
align nnet decoder & refactor
SmileGoat Mar 13, 2022
5a0e0b0
add help info
Mar 14, 2022
bb07144
Merge pull request #1559 from SmileGoat/align_nnet_decoder
SmileGoat Mar 14, 2022
5383dff
Revert "align nnet decoder & refactor"
SmileGoat Mar 14, 2022
32afe21
Merge pull request #1562 from PaddlePaddle/revert-1559-align_nnet_dec…
zh794390558 Mar 14, 2022
82b23eb
streaming nnet align & decoder align
SmileGoat Mar 14, 2022
f279606
Merge pull request #1563 from SmileGoat/rename_author
zh794390558 Mar 14, 2022
8a7bdf3
add run.sh for example
SmileGoat Mar 14, 2022
c6db0e8
split run.sh
SmileGoat Mar 14, 2022
b69e222
Merge pull request #1566 from SmileGoat/add_run
zh794390558 Mar 14, 2022
92c618d
add reset of decoder&frontend
SmileGoat Mar 15, 2022
6b654b5
add path.sh
SmileGoat Mar 16, 2022
300caf1
add valgrind
SmileGoat Mar 16, 2022
a8ac0c6
format
SmileGoat Mar 16, 2022
ef67043
Merge pull request #1570 from SmileGoat/refactor_reset
zh794390558 Mar 16, 2022
6693321
fix speech egs
zh794390558 Mar 16, 2022
30f0987
Merge pull request #1572 from zh794390558/egs
SmileGoat Mar 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.pyc
.vscode
*log
*.wav
*.pdmodel
*.pdiparams*
*.zip
Expand All @@ -13,6 +14,7 @@
*.whl
*.egg-info
build
*output/

docs/build/
docs/topic/ctc/warp-ctc/
Expand All @@ -30,5 +32,6 @@ tools/OpenBLAS/
tools/Miniconda3-latest-Linux-x86_64.sh
tools/activate_python.sh
tools/miniconda.sh
tools/CRF++-0.58/

*output/
speechx/fc_patch/
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ repos:
entry: bash .pre-commit-hooks/clang-format.hook -i
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$
exclude: (?=speechx/speechx/kaldi).*(\.cpp|\.cc|\.h|\.py)$
exclude: (?=speechx/speechx/kaldi|speechx/patch).*(\.cpp|\.cc|\.h|\.py)$
- id: copyright_checker
name: copyright_checker
entry: python .pre-commit-hooks/copyright-check.hook
language: system
files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|proto|py)$
exclude: (?=third_party|pypinyin|speechx/speechx/kaldi).*(\.cpp|\.cc|\.h|\.py)$
exclude: (?=third_party|pypinyin|speechx/speechx/kaldi|speechx/patch).*(\.cpp|\.cc|\.h|\.py)$
- repo: https://github.com/asottile/reorder_python_imports
rev: v2.4.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions demos/speech_server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.wav
4 changes: 4 additions & 0 deletions docs/source/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@ We borrowed a lot of code from these repos to build `model` and `engine`, thanks
* [librosa](https://github.com/librosa/librosa/blob/main/LICENSE.md)
- ISC License
- Audio feature

* [ThreadPool](https://github.com/progschj/ThreadPool/blob/master/COPYING)
- zlib License
- ThreadPool
2 changes: 1 addition & 1 deletion paddlespeech/s2t/io/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _batch_shuffle(indices, batch_size, epoch, clipped=False):
"""
rng = np.random.RandomState(epoch)
shift_len = rng.randint(0, batch_size - 1)
batch_indices = list(zip(*[iter(indices[shift_len:])] * batch_size))
batch_indices = list(zip(* [iter(indices[shift_len:])] * batch_size))
rng.shuffle(batch_indices)
batch_indices = [item for batch in batch_indices for item in batch]
assert clipped is False
Expand Down
2 changes: 1 addition & 1 deletion paddlespeech/t2s/modules/transformer/repeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ def repeat(N, fn):
Returns:
MultiSequential: Repeated model instance.
"""
return MultiSequential(*[fn(n) for n in range(N)])
return MultiSequential(* [fn(n) for n in range(N)])
1 change: 1 addition & 0 deletions speechx/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tools/valgrind*
166 changes: 93 additions & 73 deletions speechx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,32 @@ cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

project(paddlespeech VERSION 0.1)

set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_SOURCE_DIR}/cmake/EnableCMP0048.cmake")

set(CMAKE_VERBOSE_MAKEFILE on)

# set std-14
set(CMAKE_CXX_STANDARD 14)

# include file
# cmake dir
set(speechx_cmake_dir ${PROJECT_SOURCE_DIR}/cmake)

# Modules
list(APPEND CMAKE_MODULE_PATH ${speechx_cmake_dir}/external)
list(APPEND CMAKE_MODULE_PATH ${speechx_cmake_dir})
include(FetchContent)
include(ExternalProject)

# fc_patch dir
set(FETCHCONTENT_QUIET off)
get_filename_component(fc_patch "fc_patch" REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
set(FETCHCONTENT_BASE_DIR ${fc_patch})

# compiler option
# Keep the same with openfst, -fPIC or -fpic
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++14 -pthread -fPIC -O0 -Wall -g")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} --std=c++14 -pthread -fPIC -O0 -Wall -g -ggdb")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} --std=c++14 -pthread -fPIC -O3 -Wall")

###############################################################################
# Option Configurations
Expand All @@ -25,91 +39,92 @@ option(TEST_DEBUG "option for debug" OFF)
###############################################################################
# Include third party
###############################################################################
# #example for include third party
# FetchContent_Declare()
# # FetchContent_MakeAvailable was not added until CMake 3.14
# example for include third party
# FetchContent_MakeAvailable was not added until CMake 3.14
# FetchContent_MakeAvailable()
# include_directories()

# gflags
include(gflags)

# glog
include(glog)

# gtest
include(gtest)

# ABSEIL-CPP
include(FetchContent)
FetchContent_Declare(
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
GIT_TAG "20210324.1"
)
FetchContent_MakeAvailable(absl)
include(absl)

# libsndfile
include(FetchContent)
FetchContent_Declare(
libsndfile
GIT_REPOSITORY "https://github.com/libsndfile/libsndfile.git"
GIT_TAG "1.0.31"
)
FetchContent_MakeAvailable(libsndfile)
include(libsndfile)

# gflags
FetchContent_Declare(
gflags
URL https://github.com/gflags/gflags/archive/v2.2.1.zip
URL_HASH SHA256=4e44b69e709c826734dbbbd5208f61888a2faf63f239d73d8ba0011b2dccc97a
)
FetchContent_MakeAvailable(gflags)
include_directories(${gflags_BINARY_DIR}/include)
# boost
# include(boost) # not work
set(boost_SOURCE_DIR ${fc_patch}/boost-src)
set(BOOST_ROOT ${boost_SOURCE_DIR})
# #find_package(boost REQUIRED PATHS ${BOOST_ROOT})

# glog
FetchContent_Declare(
glog
URL https://github.com/google/glog/archive/v0.4.0.zip
URL_HASH SHA256=9e1b54eb2782f53cd8af107ecf08d2ab64b8d0dc2b7f5594472f3bd63ca85cdc
)
FetchContent_MakeAvailable(glog)
include_directories(${glog_BINARY_DIR})
# Eigen
include(eigen)
find_package(Eigen3 REQUIRED)

# gtest
FetchContent_Declare(googletest
URL https://github.com/google/googletest/archive/release-1.10.0.zip
URL_HASH SHA256=94c634d499558a76fa649edb13721dce6e98fb1e7018dfaeba3cd7a083945e91
)
FetchContent_MakeAvailable(googletest)
# Kenlm
include(kenlm)
add_dependencies(kenlm eigen boost)

#openblas
include(openblas)

# openfst
set(openfst_SOURCE_DIR ${fc_patch}/openfst-src)
set(openfst_BINARY_DIR ${fc_patch}/openfst-build)
set(openfst_PREFIX_DIR ${fc_patch}/openfst-subbuild/openfst-populate-prefix)
ExternalProject_Add(openfst
URL https://github.com/mjansche/openfst/archive/refs/tags/1.7.2.zip
URL_HASH SHA256=ffc56931025579a8af3515741c0f3b0fc3a854c023421472c07ca0c6389c75e6
SOURCE_DIR ${openfst_SOURCE_DIR}
BINARY_DIR ${openfst_BINARY_DIR}
CONFIGURE_COMMAND ${openfst_SOURCE_DIR}/configure --prefix=${openfst_PREFIX_DIR}
"CPPFLAGS=-I${gflags_BINARY_DIR}/include -I${glog_SOURCE_DIR}/src -I${glog_BINARY_DIR}"
"LDFLAGS=-L${gflags_BINARY_DIR} -L${glog_BINARY_DIR}"
"LIBS=-lgflags_nothreads -lglog -lpthread"
BUILD_COMMAND make -j 4
)
include(openfst)
add_dependencies(openfst gflags glog)
link_directories(${openfst_PREFIX_DIR}/lib)
include_directories(${openfst_PREFIX_DIR}/include)

add_subdirectory(speechx)

#openblas
#set(OpenBLAS_INSTALL_PREFIX ${fc_patch}/OpenBLAS)
#set(OpenBLAS_SOURCE_DIR ${fc_patch}/OpenBLAS-src)
#ExternalProject_Add(
# OpenBLAS
# GIT_REPOSITORY https://github.com/xianyi/OpenBLAS
# GIT_TAG v0.3.13
# GIT_SHALLOW TRUE
# GIT_PROGRESS TRUE
# CONFIGURE_COMMAND ""
# BUILD_IN_SOURCE TRUE
# BUILD_COMMAND make USE_LOCKING=1 USE_THREAD=0
# INSTALL_COMMAND make PREFIX=${OpenBLAS_INSTALL_PREFIX} install
# UPDATE_DISCONNECTED TRUE
#)
# paddle lib
set(paddle_SOURCE_DIR ${fc_patch}/paddle-lib)
set(paddle_PREFIX_DIR ${fc_patch}/paddle-lib-prefix)
ExternalProject_Add(paddle
URL https://paddle-inference-lib.bj.bcebos.com/2.2.2/cxx_c/Linux/CPU/gcc8.2_avx_mkl/paddle_inference.tgz
URL_HASH SHA256=7c6399e778c6554a929b5a39ba2175e702e115145e8fa690d2af974101d98873
PREFIX ${paddle_PREFIX_DIR}
SOURCE_DIR ${paddle_SOURCE_DIR}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
)

set(PADDLE_LIB ${fc_patch}/paddle-lib)
include_directories("${PADDLE_LIB}/paddle/include")
set(PADDLE_LIB_THIRD_PARTY_PATH "${PADDLE_LIB}/third_party/install/")
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}protobuf/include")
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}xxhash/include")
include_directories("${PADDLE_LIB_THIRD_PARTY_PATH}cryptopp/include")

link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}protobuf/lib")
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}xxhash/lib")
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}cryptopp/lib")
link_directories("${PADDLE_LIB}/paddle/lib")
link_directories("${PADDLE_LIB_THIRD_PARTY_PATH}mklml/lib")

##paddle with mkl
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(MATH_LIB_PATH "${PADDLE_LIB_THIRD_PARTY_PATH}mklml")
include_directories("${MATH_LIB_PATH}/include")
set(MATH_LIB ${MATH_LIB_PATH}/lib/libmklml_intel${CMAKE_SHARED_LIBRARY_SUFFIX}
${MATH_LIB_PATH}/lib/libiomp5${CMAKE_SHARED_LIBRARY_SUFFIX})
set(MKLDNN_PATH "${PADDLE_LIB_THIRD_PARTY_PATH}mkldnn")
include_directories("${MKLDNN_PATH}/include")
set(MKLDNN_LIB ${MKLDNN_PATH}/lib/libmkldnn.so.0)
set(EXTERNAL_LIB "-lrt -ldl -lpthread")

set(DEPS ${PADDLE_LIB}/paddle/lib/libpaddle_inference${CMAKE_SHARED_LIBRARY_SUFFIX})
set(DEPS ${DEPS}
${MATH_LIB} ${MKLDNN_LIB}
glog gflags protobuf xxhash cryptopp
${EXTERNAL_LIB})



###############################################################################
# Add local library
Expand All @@ -121,4 +136,9 @@ add_subdirectory(speechx)
# if dir do not have CmakeLists.txt
#add_library(lib_name STATIC file.cc)
#target_link_libraries(lib_name item0 item1)
#add_dependencies(lib_name depend-target)
#add_dependencies(lib_name depend-target)

set(SPEECHX_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/speechx)

add_subdirectory(speechx)
add_subdirectory(examples)
24 changes: 24 additions & 0 deletions speechx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SpeechX -- Speech Inference All in One

> Test under `Ubuntu 16.04.7 LTS`.

## Build

```
./build.sh
```l

## Valgrind

> If using docker please check `--privileged` is set when `docker run`.

1. Fatal error at startup: a function redirection which is mandatory for this platform-tool combination cannot be set up
```
apt-get install libc6-dbg
```

```
pushd tools
./setup_valgrind.sh
popd
```
3 changes: 3 additions & 0 deletions speechx/TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# TODO

* DecibelNormalizer: there is a little bit difference between offline and online db norm. The computation of online db norm read feature chunk by chunk, which causes the feature size is different with offline db norm. In normalizer.cc:73, the samples.size() is different, which causes the difference of result.
28 changes: 28 additions & 0 deletions speechx/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

# the build script had verified in the paddlepaddle docker image.
# please follow the instruction below to install PaddlePaddle image.
# https://www.paddlepaddle.org.cn/documentation/docs/zh/install/docker/linux-docker.html

boost_SOURCE_DIR=$PWD/fc_patch/boost-src
if [ ! -d ${boost_SOURCE_DIR} ]; then wget -c https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz
tar xzfv boost_1_75_0.tar.gz
mkdir -p $PWD/fc_patch
mv boost_1_75_0 ${boost_SOURCE_DIR}
cd ${boost_SOURCE_DIR}
bash ./bootstrap.sh
./b2
cd -
echo -e "\n"
fi

#rm -rf build
mkdir -p build
cd build

cmake .. -DBOOST_ROOT:STRING=${boost_SOURCE_DIR}
#cmake ..

make -j1

cd -
1 change: 1 addition & 0 deletions speechx/cmake/EnableCMP0048.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake_policy(SET CMP0048 NEW)
16 changes: 16 additions & 0 deletions speechx/cmake/external/absl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include(FetchContent)


set(BUILD_SHARED_LIBS OFF) # up to you
set(BUILD_TESTING OFF) # to disable abseil test, or gtest will fail.
set(ABSL_ENABLE_INSTALL ON) # now you can enable install rules even in subproject...

FetchContent_Declare(
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
GIT_TAG "20210324.1"
)
FetchContent_MakeAvailable(absl)

set(EIGEN3_INCLUDE_DIR ${Eigen3_SOURCE_DIR})
include_directories(${absl_SOURCE_DIR})
27 changes: 27 additions & 0 deletions speechx/cmake/external/boost.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
include(FetchContent)
set(Boost_DEBUG ON)

set(Boost_PREFIX_DIR ${fc_patch}/boost)
set(Boost_SOURCE_DIR ${fc_patch}/boost-src)

FetchContent_Declare(
Boost
URL https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz
URL_HASH SHA256=aeb26f80e80945e82ee93e5939baebdca47b9dee80a07d3144be1e1a6a66dd6a
PREFIX ${Boost_PREFIX_DIR}
SOURCE_DIR ${Boost_SOURCE_DIR}
)

execute_process(COMMAND bootstrap.sh WORKING_DIRECTORY ${Boost_SOURCE_DIR})
execute_process(COMMAND b2 WORKING_DIRECTORY ${Boost_SOURCE_DIR})

FetchContent_MakeAvailable(Boost)

message(STATUS "boost src dir: ${Boost_SOURCE_DIR}")
message(STATUS "boost inc dir: ${Boost_INCLUDE_DIR}")
message(STATUS "boost bin dir: ${Boost_BINARY_DIR}")

set(BOOST_ROOT ${Boost_SOURCE_DIR})
message(STATUS "boost root dir: ${BOOST_ROOT}")

include_directories(${Boost_SOURCE_DIR})
Loading