diff --git a/.github/workflows/c-api.yaml b/.github/workflows/c-api.yaml index 3b1cd85a3..8c48e9256 100644 --- a/.github/workflows/c-api.yaml +++ b/.github/workflows/c-api.yaml @@ -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: | diff --git a/ffmpeg-examples/Makefile b/ffmpeg-examples/Makefile index 0213ff038..08eef258a 100644 --- a/ffmpeg-examples/Makefile +++ b/ffmpeg-examples/Makefile @@ -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 -lsherpa-onnx-core -lonnxruntime -lkaldi-native-fbank-core +LDLIBS += -lsherpa-onnx-c-api -lonnxruntime 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}') diff --git a/ffmpeg-examples/run.sh b/ffmpeg-examples/run.sh index deede7168..f6ba33b07 100755 --- a/ffmpeg-examples/run.sh +++ b/ffmpeg-examples/run.sh @@ -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 diff --git a/ffmpeg-examples/sherpa-onnx-ffmpeg.c b/ffmpeg-examples/sherpa-onnx-ffmpeg.c index 211d91d5a..f99ac0bdc 100644 --- a/ffmpeg-examples/sherpa-onnx-ffmpeg.c +++ b/ffmpeg-examples/sherpa-onnx-ffmpeg.c @@ -216,7 +216,7 @@ static int init_filters(const char *filters_descr) { 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);