Skip to content

Commit 30f0987

Browse files
authored
Merge pull request #1572 from zh794390558/egs
[speechx] refactor speechx egs
2 parents ef67043 + 6693321 commit 30f0987

File tree

13 files changed

+115
-35
lines changed

13 files changed

+115
-35
lines changed

speechx/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tools/valgrind*

speechx/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# SpeechX -- Speech Inference All in One
2+
3+
> Test under `Ubuntu 16.04.7 LTS`.
4+
5+
## Build
6+
7+
```
8+
./build.sh
9+
```l
10+
11+
## Valgrind
12+
13+
> If using docker please check `--privileged` is set when `docker run`.
14+
15+
1. Fatal error at startup: a function redirection which is mandatory for this platform-tool combination cannot be set up
16+
```
17+
apt-get install libc6-dbg
18+
```
19+
20+
```
21+
pushd tools
22+
./setup_valgrind.sh
23+
popd
24+
```

speechx/examples/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.ark
2+
paddle_asr_model/

speechx/examples/path.sh renamed to speechx/examples/decoder/path.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
SPEECHX_ROOT=$PWD/../..
44
SPEECHX_EXAMPLES=$SPEECHX_ROOT/build/examples
5-
SPEECHX_BIN=$SPEECHX_EXAMPLES/nnet:$SPEECHX_EXAMPLES/decoder:$SPEECHX_EXAMPLES/feat
65

76
SPEECHX_TOOLS=$SPEECHX_ROOT/tools
87
TOOLS_BIN=$SPEECHX_TOOLS/valgrind/install/bin
@@ -11,4 +10,5 @@ TOOLS_BIN=$SPEECHX_TOOLS/valgrind/install/bin
1110

1211
export LC_AL=C
1312

13+
SPEECHX_BIN=$SPEECHX_EXAMPLES/decoder
1414
export PATH=$PATH:$SPEECHX_BIN:$TOOLS_BIN

speechx/examples/decoder/run.sh

100644100755
Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
set +x
33
set -e
44

5+
. path.sh
6+
57
# 1. compile
6-
if [ ! -d ../../build/examples ]; then
7-
cd ../..
8+
if [ ! -d ${SPEECHX_EXAMPLES} ]; then
9+
pushd ${SPEECHX_ROOT}
810
bash build.sh
9-
cd -
11+
popd
1012
fi
1113

12-
. ../path.sh
1314

1415
# 2. download model
1516
if [ ! -d ../paddle_asr_model ]; then
16-
wget https://paddlespeech.bj.bcebos.com/s2t/paddle_asr_online/paddle_asr_model.tar.gz
17+
wget -c https://paddlespeech.bj.bcebos.com/s2t/paddle_asr_online/paddle_asr_model.tar.gz
1718
tar xzfv paddle_asr_model.tar.gz
1819
mv ./paddle_asr_model ../
1920
# produce wav scp
@@ -25,8 +26,15 @@ feat_wspecifier=./feats.ark
2526
cmvn=./cmvn.ark
2627

2728
# 3. run feat
28-
linear_spectrogram_main --wav_rspecifier=scp:$model_dir/wav.scp --feature_wspecifier=ark:$feat_wspecifier --cmvn_write_path=$cmvn
29+
linear_spectrogram_main \
30+
--wav_rspecifier=scp:$model_dir/wav.scp \
31+
--feature_wspecifier=ark,t:$feat_wspecifier \
32+
--cmvn_write_path=$cmvn
2933

3034
# 4. run decoder
31-
offline_decoder_main --feature_respecifier=ark:$feat_wspecifier --model_path=$model_dir/avg_1.jit.pdmodel --param_path=$model_dir/avg_1.jit.pdparams --dict_file=$model_dir/vocab.txt --lm_path=$model_dir/avg_1.jit.klm
32-
35+
offline_decoder_main \
36+
--feature_respecifier=ark:$feat_wspecifier \
37+
--model_path=$model_dir/avg_1.jit.pdmodel \
38+
--param_path=$model_dir/avg_1.jit.pdparams \
39+
--dict_file=$model_dir/vocab.txt \
40+
--lm_path=$model_dir/avg_1.jit.klm

speechx/examples/decoder/valgrind.sh

100644100755
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
set +x
66
set -e
77

8-
if [ ! -d ../../tools/valgrind/install ]; then
8+
. ./path.sh
9+
10+
if [ ! -d ${SPEECHX_TOOLS}/valgrind/install ]; then
911
echo "please install valgrind in the speechx tools dir.\n"
1012
exit 1
1113
fi
1214

13-
. ../path.sh
14-
1515
model_dir=../paddle_asr_model
1616
feat_wspecifier=./feats.ark
1717
cmvn=./cmvn.ark
1818

19-
valgrind --tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=all offline_decoder_main --feature_respecifier=ark:$feat_wspecifier --model_path=$model_dir/avg_1.jit.pdmodel --param_path=$model_dir/avg_1.jit.pdparams --dict_file=$model_dir/vocab.txt --lm_path=$model_dir/avg_1.jit.klm
19+
valgrind --tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=all \
20+
offline_decoder_main \
21+
--feature_respecifier=ark:$feat_wspecifier \
22+
--model_path=$model_dir/avg_1.jit.pdmodel \
23+
--param_path=$model_dir/avg_1.jit.pdparams \
24+
--dict_file=$model_dir/vocab.txt \
25+
--lm_path=$model_dir/avg_1.jit.klm
2026

speechx/examples/feat/path.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This contains the locations of binarys build required for running the examples.
2+
3+
SPEECHX_ROOT=$PWD/../..
4+
SPEECHX_EXAMPLES=$SPEECHX_ROOT/build/examples
5+
6+
SPEECHX_TOOLS=$SPEECHX_ROOT/tools
7+
TOOLS_BIN=$SPEECHX_TOOLS/valgrind/install/bin
8+
9+
[ -d $SPEECHX_EXAMPLES ] || { echo "Error: 'build/examples' directory not found. please ensure that the project build successfully"; }
10+
11+
export LC_AL=C
12+
13+
SPEECHX_BIN=$SPEECHX_EXAMPLES/feat
14+
export PATH=$PATH:$SPEECHX_BIN:$TOOLS_BIN

speechx/examples/feat/run.sh

100644100755
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
set +x
33
set -e
44

5+
. ./path.sh
6+
57
# 1. compile
6-
if [ ! -d ../../build/examples ]; then
7-
cd ../..
8+
if [ ! -d ${SPEECHX_EXAMPLES} ]; then
9+
pushd ${SPEECHX_ROOT}
810
bash build.sh
9-
cd -
11+
popd
1012
fi
1113

12-
. ../path.sh
13-
1414
# 2. download model
1515
if [ ! -d ../paddle_asr_model ]; then
1616
wget https://paddlespeech.bj.bcebos.com/s2t/paddle_asr_online/paddle_asr_model.tar.gz
@@ -25,4 +25,7 @@ feat_wspecifier=./feats.ark
2525
cmvn=./cmvn.ark
2626

2727
# 3. run feat
28-
linear_spectrogram_main --wav_rspecifier=scp:$model_dir/wav.scp --feature_wspecifier=ark,t:$feat_wspecifier --cmvn_write_path=$cmvn
28+
linear_spectrogram_main \
29+
--wav_rspecifier=scp:$model_dir/wav.scp \
30+
--feature_wspecifier=ark,t:$feat_wspecifier \
31+
--cmvn_write_path=$cmvn

speechx/examples/feat/valgrind.sh

100644100755
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
set +x
66
set -e
77

8-
if [ ! -d ../../tools/valgrind/install ]; then
8+
. ./path.sh
9+
10+
if [ ! -d ${SPEECHX_TOOLS}/valgrind/install ]; then
911
echo "please install valgrind in the speechx tools dir.\n"
1012
exit 1
1113
fi
1214

13-
. ../path.sh
14-
1515
model_dir=../paddle_asr_model
1616
feat_wspecifier=./feats.ark
1717
cmvn=./cmvn.ark
1818

19-
valgrind --tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=all linear_spectrogram_main --wav_rspecifier=scp:$model_dir/wav.scp --feature_wspecifier=ark,t:$feat_wspecifier --cmvn_write_path=$cmvn
19+
valgrind --tool=memcheck --track-origins=yes --leak-check=full --show-leak-kinds=all \
20+
linear_spectrogram_main \
21+
--wav_rspecifier=scp:$model_dir/wav.scp \
22+
--feature_wspecifier=ark,t:$feat_wspecifier \
23+
--cmvn_write_path=$cmvn
2024

speechx/examples/nnet/path.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# This contains the locations of binarys build required for running the examples.
2+
3+
SPEECHX_ROOT=$PWD/../..
4+
SPEECHX_EXAMPLES=$SPEECHX_ROOT/build/examples
5+
6+
SPEECHX_TOOLS=$SPEECHX_ROOT/tools
7+
TOOLS_BIN=$SPEECHX_TOOLS/valgrind/install/bin
8+
9+
[ -d $SPEECHX_EXAMPLES ] || { echo "Error: 'build/examples' directory not found. please ensure that the project build successfully"; }
10+
11+
export LC_AL=C
12+
13+
SPEECHX_BIN=$SPEECHX_EXAMPLES/nnet
14+
export PATH=$PATH:$SPEECHX_BIN:$TOOLS_BIN

0 commit comments

Comments
 (0)