For java ci actions (#231)
This commit is contained in:
@@ -73,10 +73,10 @@ runmic:
|
||||
java -cp ./lib/sherpaonnx.jar:build $(RUNJFLAGS) DecodeMic
|
||||
|
||||
runsrv:
|
||||
java -cp $(BUILD_DIR):lib/Java-WebSocket-1.5.3.jar:lib/slf4j-simple-1.7.25.jar:lib/slf4j-api-1.7.25.jar:../lib/sherpaonnx.jar $(RUNJFLAGS) websocketsrv.AsrWebsocketServer /sherpa-onnx/20230515/zhaoming/sherpa-onnx/build/lib/libsherpa-onnx-jni.so ./modelconfig.cfg
|
||||
java -cp $(BUILD_DIR):lib/Java-WebSocket-1.5.3.jar:lib/slf4j-simple-1.7.25.jar:lib/slf4j-api-1.7.25.jar:../lib/sherpaonnx.jar $(RUNJFLAGS) websocketsrv.AsrWebsocketServer ../build/lib/libsherpa-onnx-jni.so ./modeltest.cfg
|
||||
|
||||
runclient:
|
||||
java -cp $(BUILD_DIR):lib/Java-WebSocket-1.5.3.jar:lib/slf4j-simple-1.7.25.jar:lib/slf4j-api-1.7.25.jar:../lib/sherpaonnx.jar $(RUNJFLAGS) websocketsrv.AsrWebsocketClient /sherpa-onnx/20230515/zhaoming/sherpa-onnx/build/lib/libsherpa-onnx-jni.so 127.0.0.1 8890 ./test.wav 32
|
||||
java -cp $(BUILD_DIR):lib/Java-WebSocket-1.5.3.jar:lib/slf4j-simple-1.7.25.jar:lib/slf4j-api-1.7.25.jar:../lib/sherpaonnx.jar $(RUNJFLAGS) websocketsrv.AsrWebsocketClient ../build/lib/libsherpa-onnx-jni.so 127.0.0.1 8890 ./test.wav 32
|
||||
|
||||
buildlib: $(LIB_FILES:.java=.class)
|
||||
|
||||
|
||||
@@ -185,3 +185,9 @@ json result example: {"text":"甚至出现交易几乎停滞的情况","eof":"tr
|
||||
make runclient /**change path in Makefile according to your env**/
|
||||
```
|
||||
|
||||
7 runtest
|
||||
this script will download model, compile codes and run test
|
||||
```bash
|
||||
cd sherpa-onnx/java-api-examples
|
||||
runtest.sh
|
||||
```
|
||||
66
java-api-examples/runtest.sh
Executable file
66
java-api-examples/runtest.sh
Executable file
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# This scripts shows how to test java for sherpa-onnx
|
||||
# Note: This scripts runs only on Linux and macOS
|
||||
|
||||
set -e
|
||||
|
||||
log() {
|
||||
# This function is from espnet
|
||||
local fname=${BASH_SOURCE[1]##*/}
|
||||
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo "PATH: $PATH"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
log "------------------------------------------------------------"
|
||||
log "Run download model"
|
||||
log "------------------------------------------------------------"
|
||||
|
||||
repo_url=https://huggingface.co/csukuangfj/sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20
|
||||
log "Start testing ${repo_url}"
|
||||
repo=$(basename $repo_url)
|
||||
log "download dir is $(basename $repo_url)"
|
||||
if [ ! -d $repo ];then
|
||||
log "Download pretrained model and test-data from $repo_url"
|
||||
|
||||
GIT_LFS_SKIP_SMUDGE=1 git clone $repo_url
|
||||
pushd $repo
|
||||
git lfs pull --include "*.onnx"
|
||||
ls -lh *.onnx
|
||||
popd
|
||||
fi
|
||||
|
||||
log $(pwd)
|
||||
|
||||
sed -e 's?/sherpa/?'$(pwd)'/?g' modelconfig.cfg > modeltest.cfg
|
||||
|
||||
log "display model cfg"
|
||||
cat modeltest.cfg
|
||||
|
||||
cd ..
|
||||
|
||||
export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DSHERPA_ONNX_ENABLE_JNI=ON ..
|
||||
|
||||
make -j4
|
||||
ls -lh lib
|
||||
|
||||
export LD_LIBRARY_PATH=$PWD/build/lib:$LD_LIBRARY_PATH
|
||||
|
||||
cd ../java-api-examples
|
||||
|
||||
make all
|
||||
|
||||
make runfile
|
||||
@@ -159,7 +159,7 @@ public class DecodeFile {
|
||||
String appDir = System.getProperty("user.dir");
|
||||
System.out.println("appdir=" + appDir);
|
||||
String fileName = appDir + "/test.wav";
|
||||
String cfgPath = appDir + "/modelconfig.cfg";
|
||||
String cfgPath = appDir + "/modeltest.cfg";
|
||||
String soPath = appDir + "/../build/lib/libsherpa-onnx-jni.so";
|
||||
OnlineRecognizer.setSoPath(soPath);
|
||||
DecodeFile rcgDemo = new DecodeFile(fileName);
|
||||
|
||||
Reference in New Issue
Block a user