Fix ffmpeg c api example (#1185)
This commit is contained in:
18
.github/workflows/c-api.yaml
vendored
18
.github/workflows/c-api.yaml
vendored
@@ -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: |
|
||||
|
||||
@@ -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}')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user