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
2024-07-29 14:27:55 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Committed by
GitHub
2024-07-29 14:27:55 +0800
Commit
b1711ecaa1c2f3738494f23d4396fd11ef386136
b1711eca
1 parent
646f99c8
Fix ffmpeg c api example (#1185)
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
30 行增加
和
12 行删除
.github/workflows/c-api.yaml
ffmpeg-examples/Makefile
ffmpeg-examples/run.sh
ffmpeg-examples/sherpa-onnx-ffmpeg.c
.github/workflows/c-api.yaml
查看文件 @
b1711ec
...
...
@@ -13,6 +13,7 @@ on:
-
'
sherpa-onnx/csrc/*'
-
'
sherpa-onnx/c-api/*'
-
'
c-api-examples/**'
-
'
ffmpeg-examples/**'
pull_request
:
branches
:
-
master
...
...
@@ -23,6 +24,7 @@ on:
-
'
sherpa-onnx/csrc/*'
-
'
sherpa-onnx/c-api/*'
-
'
c-api-examples/**'
-
'
ffmpeg-examples/**'
workflow_dispatch
:
...
...
@@ -81,6 +83,22 @@ jobs:
otool -L ./install/lib/libsherpa-onnx-c-api.dylib
fi
-
name
:
Test ffmpeg
if
:
matrix.os == 'macos-latest'
shell
:
bash
run
:
|
brew install ffmpeg
cd ffmpeg-examples
curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2
make
ls -lh
./run.sh
rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
-
name
:
Test sense-voice
shell
:
bash
run
:
|
...
...
ffmpeg-examples/Makefile
查看文件 @
b1711ec
...
...
@@ -14,19 +14,18 @@ ifeq ($(GDB), TRUE)
OPTFLAG
+=
-g
endif
# CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 -fopenmp ${OPTFLAG}
CFLAGS
:=
$(
shell
pkg-config --cflags
$(SHARED_LIBS))
-I.. -Wall -std
=
c++11
${
OPTFLAG
}
# CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++17 -fopenmp ${OPTFLAG}
CFLAGS
:=
$(
shell
pkg-config --cflags
$(SHARED_LIBS))
-I.. -Wall -std
=
c++17
${
OPTFLAG
}
LDLIBS
:=
$(
shell
pkg-config --libs
$(SHARED_LIBS))
CUR_DIR
:=
$(
shell
pwd
)
LDLIBS
+=
-L ../build/lib
LDLIBS
+=
-L ../build/_deps/onnxruntime-src/lib
LDLIBS
+=
-lsherpa-onnx-c-api -l
sherpa-onnx-core -lonnxruntime -lkaldi-native-fbank-cor
e
LDLIBS
+=
-lsherpa-onnx-c-api -l
onnxruntim
e
LDLIBS
+=
-Wl,-rpath,
${
CUR_DIR
}
/../build/lib
LDLIBS
+=
-Wl,-rpath,
${
CUR_DIR
}
/../build/_deps/onnxruntime-src/lib
#Get libavutil version and extract major, minor and micro
LIBAVUTIL_VERSION
:=
$(
shell
pkg-config --modversion libavutil
)
LIBAVUTIL_MAJOR
:=
$(
shell
echo
"
$(LIBAVUTIL_VERSION)
"
| awk -F.
'{print $$1}'
)
...
...
ffmpeg-examples/run.sh
查看文件 @
b1711ec
...
...
@@ -45,4 +45,4 @@ echo "Decoding a URL"
./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx
\
./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx
\
./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx
\
https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/resolve/main/test_wavs/
4
.wav
https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/resolve/main/test_wavs/
3
.wav
...
...
ffmpeg-examples/sherpa-onnx-ffmpeg.c
查看文件 @
b1711ec
...
...
@@ -216,7 +216,7 @@ end:
static
void
sherpa_decode_frame
(
const
AVFrame
*
frame
,
SherpaOnnxOnlineRecognizer
*
recognizer
,
SherpaOnnxOnlineStream
*
stream
,
SherpaOnnxDisplay
*
display
,
const
SherpaOnnxDisplay
*
display
,
int32_t
*
segment_id
)
{
#define N 3200 // 100s. Sample rate is fixed to 16 kHz
static
float
samples
[
N
];
...
...
@@ -229,7 +229,7 @@ static void sherpa_decode_frame(const AVFrame *frame,
SherpaOnnxDecodeOnlineStream
(
recognizer
,
stream
);
}
SherpaOnnxOnlineRecognizerResult
*
r
=
const
SherpaOnnxOnlineRecognizerResult
*
r
=
SherpaOnnxGetOnlineStreamResult
(
recognizer
,
stream
);
if
(
strlen
(
r
->
text
))
{
SherpaOnnxPrint
(
display
,
*
segment_id
,
r
->
text
);
...
...
@@ -290,10 +290,11 @@ int main(int argc, char **argv) {
}
SherpaOnnxOnlineRecognizerConfig
config
;
memset
(
&
config
,
0
,
sizeof
(
config
));
config
.
model_config
.
tokens
=
argv
[
1
];
config
.
model_config
.
encoder
=
argv
[
2
];
config
.
model_config
.
decoder
=
argv
[
3
];
config
.
model_config
.
joiner
=
argv
[
4
];
config
.
model_config
.
transducer
.
encoder
=
argv
[
2
];
config
.
model_config
.
transducer
.
decoder
=
argv
[
3
];
config
.
model_config
.
transducer
.
joiner
=
argv
[
4
];
if
(
argc
==
7
&&
atoi
(
argv
[
6
])
>
0
)
{
num_threads
=
atoi
(
argv
[
6
]);
...
...
@@ -320,7 +321,7 @@ int main(int argc, char **argv) {
SherpaOnnxOnlineRecognizer
*
recognizer
=
SherpaOnnxCreateOnlineRecognizer
(
&
config
);
SherpaOnnxOnlineStream
*
stream
=
SherpaOnnxCreateOnlineStream
(
recognizer
);
SherpaOnnxDisplay
*
display
=
SherpaOnnxCreateDisplay
(
50
);
const
SherpaOnnxDisplay
*
display
=
SherpaOnnxCreateDisplay
(
50
);
int32_t
segment_id
=
0
;
if
((
ret
=
open_input_file
(
argv
[
5
]))
<
0
)
exit
(
1
);
...
...
@@ -383,7 +384,7 @@ int main(int argc, char **argv) {
SherpaOnnxDecodeOnlineStream
(
recognizer
,
stream
);
}
SherpaOnnxOnlineRecognizerResult
*
r
=
const
SherpaOnnxOnlineRecognizerResult
*
r
=
SherpaOnnxGetOnlineStreamResult
(
recognizer
,
stream
);
if
(
strlen
(
r
->
text
))
{
SherpaOnnxPrint
(
display
,
segment_id
,
r
->
text
);
...
...
请
注册
或
登录
后发表评论