正在显示
4 个修改的文件
包含
30 行增加
和
12 行删除
| @@ -13,6 +13,7 @@ on: | @@ -13,6 +13,7 @@ on: | ||
| 13 | - 'sherpa-onnx/csrc/*' | 13 | - 'sherpa-onnx/csrc/*' |
| 14 | - 'sherpa-onnx/c-api/*' | 14 | - 'sherpa-onnx/c-api/*' |
| 15 | - 'c-api-examples/**' | 15 | - 'c-api-examples/**' |
| 16 | + - 'ffmpeg-examples/**' | ||
| 16 | pull_request: | 17 | pull_request: |
| 17 | branches: | 18 | branches: |
| 18 | - master | 19 | - master |
| @@ -23,6 +24,7 @@ on: | @@ -23,6 +24,7 @@ on: | ||
| 23 | - 'sherpa-onnx/csrc/*' | 24 | - 'sherpa-onnx/csrc/*' |
| 24 | - 'sherpa-onnx/c-api/*' | 25 | - 'sherpa-onnx/c-api/*' |
| 25 | - 'c-api-examples/**' | 26 | - 'c-api-examples/**' |
| 27 | + - 'ffmpeg-examples/**' | ||
| 26 | 28 | ||
| 27 | workflow_dispatch: | 29 | workflow_dispatch: |
| 28 | 30 | ||
| @@ -81,6 +83,22 @@ jobs: | @@ -81,6 +83,22 @@ jobs: | ||
| 81 | otool -L ./install/lib/libsherpa-onnx-c-api.dylib | 83 | otool -L ./install/lib/libsherpa-onnx-c-api.dylib |
| 82 | fi | 84 | fi |
| 83 | 85 | ||
| 86 | + - name: Test ffmpeg | ||
| 87 | + if: matrix.os == 'macos-latest' | ||
| 88 | + shell: bash | ||
| 89 | + run: | | ||
| 90 | + brew install ffmpeg | ||
| 91 | + | ||
| 92 | + cd ffmpeg-examples | ||
| 93 | + 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 | ||
| 94 | + tar xvf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 | ||
| 95 | + rm sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20.tar.bz2 | ||
| 96 | + | ||
| 97 | + make | ||
| 98 | + ls -lh | ||
| 99 | + ./run.sh | ||
| 100 | + rm -rf sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20 | ||
| 101 | + | ||
| 84 | - name: Test sense-voice | 102 | - name: Test sense-voice |
| 85 | shell: bash | 103 | shell: bash |
| 86 | run: | | 104 | run: | |
| @@ -14,19 +14,18 @@ ifeq ($(GDB), TRUE) | @@ -14,19 +14,18 @@ ifeq ($(GDB), TRUE) | ||
| 14 | OPTFLAG += -g | 14 | OPTFLAG += -g |
| 15 | endif | 15 | endif |
| 16 | 16 | ||
| 17 | -# CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 -fopenmp ${OPTFLAG} | ||
| 18 | -CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++11 ${OPTFLAG} | 17 | +# CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++17 -fopenmp ${OPTFLAG} |
| 18 | +CFLAGS := $(shell pkg-config --cflags $(SHARED_LIBS)) -I.. -Wall -std=c++17 ${OPTFLAG} | ||
| 19 | LDLIBS := $(shell pkg-config --libs $(SHARED_LIBS)) | 19 | LDLIBS := $(shell pkg-config --libs $(SHARED_LIBS)) |
| 20 | 20 | ||
| 21 | CUR_DIR :=$(shell pwd) | 21 | CUR_DIR :=$(shell pwd) |
| 22 | 22 | ||
| 23 | LDLIBS += -L ../build/lib | 23 | LDLIBS += -L ../build/lib |
| 24 | LDLIBS += -L ../build/_deps/onnxruntime-src/lib | 24 | LDLIBS += -L ../build/_deps/onnxruntime-src/lib |
| 25 | -LDLIBS += -lsherpa-onnx-c-api -lsherpa-onnx-core -lonnxruntime -lkaldi-native-fbank-core | 25 | +LDLIBS += -lsherpa-onnx-c-api -lonnxruntime |
| 26 | LDLIBS += -Wl,-rpath,${CUR_DIR}/../build/lib | 26 | LDLIBS += -Wl,-rpath,${CUR_DIR}/../build/lib |
| 27 | LDLIBS += -Wl,-rpath,${CUR_DIR}/../build/_deps/onnxruntime-src/lib | 27 | LDLIBS += -Wl,-rpath,${CUR_DIR}/../build/_deps/onnxruntime-src/lib |
| 28 | 28 | ||
| 29 | - | ||
| 30 | #Get libavutil version and extract major, minor and micro | 29 | #Get libavutil version and extract major, minor and micro |
| 31 | LIBAVUTIL_VERSION := $(shell pkg-config --modversion libavutil) | 30 | LIBAVUTIL_VERSION := $(shell pkg-config --modversion libavutil) |
| 32 | LIBAVUTIL_MAJOR := $(shell echo "$(LIBAVUTIL_VERSION)" | awk -F. '{print $$1}') | 31 | LIBAVUTIL_MAJOR := $(shell echo "$(LIBAVUTIL_VERSION)" | awk -F. '{print $$1}') |
| @@ -45,4 +45,4 @@ echo "Decoding a URL" | @@ -45,4 +45,4 @@ echo "Decoding a URL" | ||
| 45 | ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx \ | 45 | ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/encoder-epoch-99-avg-1.onnx \ |
| 46 | ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx \ | 46 | ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/decoder-epoch-99-avg-1.onnx \ |
| 47 | ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx \ | 47 | ./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/joiner-epoch-99-avg-1.onnx \ |
| 48 | - https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/resolve/main/test_wavs/4.wav | 48 | + https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/resolve/main/test_wavs/3.wav |
| @@ -216,7 +216,7 @@ end: | @@ -216,7 +216,7 @@ end: | ||
| 216 | static void sherpa_decode_frame(const AVFrame *frame, | 216 | static void sherpa_decode_frame(const AVFrame *frame, |
| 217 | SherpaOnnxOnlineRecognizer *recognizer, | 217 | SherpaOnnxOnlineRecognizer *recognizer, |
| 218 | SherpaOnnxOnlineStream *stream, | 218 | SherpaOnnxOnlineStream *stream, |
| 219 | - SherpaOnnxDisplay *display, | 219 | + const SherpaOnnxDisplay *display, |
| 220 | int32_t *segment_id) { | 220 | int32_t *segment_id) { |
| 221 | #define N 3200 // 100s. Sample rate is fixed to 16 kHz | 221 | #define N 3200 // 100s. Sample rate is fixed to 16 kHz |
| 222 | static float samples[N]; | 222 | static float samples[N]; |
| @@ -229,7 +229,7 @@ static void sherpa_decode_frame(const AVFrame *frame, | @@ -229,7 +229,7 @@ static void sherpa_decode_frame(const AVFrame *frame, | ||
| 229 | SherpaOnnxDecodeOnlineStream(recognizer, stream); | 229 | SherpaOnnxDecodeOnlineStream(recognizer, stream); |
| 230 | } | 230 | } |
| 231 | 231 | ||
| 232 | - SherpaOnnxOnlineRecognizerResult *r = | 232 | + const SherpaOnnxOnlineRecognizerResult *r = |
| 233 | SherpaOnnxGetOnlineStreamResult(recognizer, stream); | 233 | SherpaOnnxGetOnlineStreamResult(recognizer, stream); |
| 234 | if (strlen(r->text)) { | 234 | if (strlen(r->text)) { |
| 235 | SherpaOnnxPrint(display, *segment_id, r->text); | 235 | SherpaOnnxPrint(display, *segment_id, r->text); |
| @@ -290,10 +290,11 @@ int main(int argc, char **argv) { | @@ -290,10 +290,11 @@ int main(int argc, char **argv) { | ||
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | SherpaOnnxOnlineRecognizerConfig config; | 292 | SherpaOnnxOnlineRecognizerConfig config; |
| 293 | + memset(&config, 0, sizeof(config)); | ||
| 293 | config.model_config.tokens = argv[1]; | 294 | config.model_config.tokens = argv[1]; |
| 294 | - config.model_config.encoder = argv[2]; | ||
| 295 | - config.model_config.decoder = argv[3]; | ||
| 296 | - config.model_config.joiner = argv[4]; | 295 | + config.model_config.transducer.encoder = argv[2]; |
| 296 | + config.model_config.transducer.decoder = argv[3]; | ||
| 297 | + config.model_config.transducer.joiner = argv[4]; | ||
| 297 | 298 | ||
| 298 | if (argc == 7 && atoi(argv[6]) > 0) { | 299 | if (argc == 7 && atoi(argv[6]) > 0) { |
| 299 | num_threads = atoi(argv[6]); | 300 | num_threads = atoi(argv[6]); |
| @@ -320,7 +321,7 @@ int main(int argc, char **argv) { | @@ -320,7 +321,7 @@ int main(int argc, char **argv) { | ||
| 320 | SherpaOnnxOnlineRecognizer *recognizer = | 321 | SherpaOnnxOnlineRecognizer *recognizer = |
| 321 | SherpaOnnxCreateOnlineRecognizer(&config); | 322 | SherpaOnnxCreateOnlineRecognizer(&config); |
| 322 | SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer); | 323 | SherpaOnnxOnlineStream *stream = SherpaOnnxCreateOnlineStream(recognizer); |
| 323 | - SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50); | 324 | + const SherpaOnnxDisplay *display = SherpaOnnxCreateDisplay(50); |
| 324 | int32_t segment_id = 0; | 325 | int32_t segment_id = 0; |
| 325 | 326 | ||
| 326 | if ((ret = open_input_file(argv[5])) < 0) exit(1); | 327 | if ((ret = open_input_file(argv[5])) < 0) exit(1); |
| @@ -383,7 +384,7 @@ int main(int argc, char **argv) { | @@ -383,7 +384,7 @@ int main(int argc, char **argv) { | ||
| 383 | SherpaOnnxDecodeOnlineStream(recognizer, stream); | 384 | SherpaOnnxDecodeOnlineStream(recognizer, stream); |
| 384 | } | 385 | } |
| 385 | 386 | ||
| 386 | - SherpaOnnxOnlineRecognizerResult *r = | 387 | + const SherpaOnnxOnlineRecognizerResult *r = |
| 387 | SherpaOnnxGetOnlineStreamResult(recognizer, stream); | 388 | SherpaOnnxGetOnlineStreamResult(recognizer, stream); |
| 388 | if (strlen(r->text)) { | 389 | if (strlen(r->text)) { |
| 389 | SherpaOnnxPrint(display, segment_id, r->text); | 390 | SherpaOnnxPrint(display, segment_id, r->text); |
-
请 注册 或 登录 后发表评论