Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/scripts/test-c-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ log() {
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
}

log "test version"
./build/bin/version-c-api

echo "SLID_EXE is $SLID_EXE"
echo "SID_EXE is $SID_EXE"
echo "AT_EXE is $AT_EXE"
Expand Down
5 changes: 5 additions & 0 deletions .github/scripts/test-dart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ set -ex

cd dart-api-examples

echo '----------Version----------'
pushd version
./run.sh
popd

pushd non-streaming-asr

echo '----------Cohere Transcribe----------'
Expand Down
3 changes: 3 additions & 0 deletions .github/scripts/test-python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ log() {
echo -e "$(date '+%Y-%m-%d %H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
}

log "test version"
python3 ./python-api-examples/version-test.py

log "test Cohere Transcribe"

curl -SL -O https://github.com/k2-fsa/sherpa-onnx/releases/download/asr-models/sherpa-onnx-cohere-transcribe-14-lang-int8-2026-04-01.tar.bz2
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/c-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ jobs:
echo "LD_LIBRARY_PATH=$PWD/build/install/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=$PWD/build/install/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Test version
shell: bash
run: |
name=version-c-api
gcc -o $name ./c-api-examples/$name.c \
-I ./build/install/include \
-L ./build/install/lib/ \
-l sherpa-onnx-c-api \
-l onnxruntime

ls -lh $name
./$name

- name: Test Cohere Transcribe
shell: bash
run: |
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/cxx-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ jobs:
echo "LD_LIBRARY_PATH=$PWD/build/install/lib:$LD_LIBRARY_PATH" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=$PWD/build/install/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV

- name: Test version
shell: bash
run: |
name=version-cxx-api
g++ -std=c++17 -o $name ./cxx-api-examples/$name.cc \
-I ./build/install/include \
-L ./build/install/lib/ \
-l sherpa-onnx-cxx-api \
-l sherpa-onnx-c-api \
-l onnxruntime

ls -lh $name
./$name

- name: Test Cohere Transcribe
shell: bash
run: |
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/pascal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jobs:
cp -v install/lib/*.dll ../pascal-api-examples/tts
cp -v install/lib/*.dll ../pascal-api-examples/vad
cp -v install/lib/*.dll ../pascal-api-examples/vad-with-non-streaming-asr
cp -v install/lib/*.dll ../pascal-api-examples/version

cp -v ../sherpa-onnx/pascal-api/*.pas ../pascal-api-examples/non-streaming-asr
cp -v ../sherpa-onnx/pascal-api/*.pas ../pascal-api-examples/read-wav
Expand All @@ -130,8 +131,18 @@ jobs:
cp -v ../sherpa-onnx/pascal-api/*.pas ../pascal-api-examples/tts
cp -v ../sherpa-onnx/pascal-api/*.pas ../pascal-api-examples/vad
cp -v ../sherpa-onnx/pascal-api/*.pas ../pascal-api-examples/vad-with-non-streaming-asr
cp -v ../sherpa-onnx/pascal-api/*.pas ../pascal-api-examples/version
fi

- name: Run Pascal version test
shell: bash
run: |
cd ./pascal-api-examples

pushd version
./run.sh
popd

Comment thread
coderabbitai[bot] marked this conversation as resolved.
- name: Run Pascal test (Cohere Transcribe)
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test-dart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ jobs:
cp scripts/dart/streaming-speech-enhancement-gtcrn-pubspec.yaml dart-api-examples/streaming-speech-enhancement-gtcrn/pubspec.yaml
cp scripts/dart/streaming-speech-enhancement-dpdfnet-pubspec.yaml dart-api-examples/streaming-speech-enhancement-dpdfnet/pubspec.yaml
cp scripts/dart/slid-pubspec.yaml dart-api-examples/spoken-language-identification/pubspec.yaml
cp scripts/dart/version-pubspec.yaml dart-api-examples/version/pubspec.yaml

cp scripts/dart/sherpa-onnx-pubspec.yaml flutter/sherpa_onnx/pubspec.yaml

Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/test-go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ jobs:
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/zero-shot-pocket-tts
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/source-separation
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/supertonic-tts
cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll ../scripts/go/_internal/version

cp -v ../scripts/go/_internal/lib/x86_64-pc-windows-gnu/*.dll $upload_dir
else
Expand Down Expand Up @@ -155,6 +156,18 @@ jobs:
name: ${{ matrix.os }}-libs
path: to-upload/

- name: Test version
shell: bash
run: |
cd scripts/go/_internal/version
ls -lh
go mod tidy
cat go.mod
go build
ls -lh

./run.sh
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Comment on lines +164 to +169

- name: Test source separation (Spleeter & UVR)
shell: bash
run: |
Expand Down
3 changes: 3 additions & 0 deletions c-api-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
include(cargs)

include_directories(${PROJECT_SOURCE_DIR})
add_executable(version-c-api version-c-api.c)
target_link_libraries(version-c-api sherpa-onnx-c-api)

add_executable(decode-file-c-api decode-file-c-api.c)
target_link_libraries(decode-file-c-api sherpa-onnx-c-api cargs)

Expand Down
16 changes: 16 additions & 0 deletions c-api-examples/version-c-api.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// c-api-examples/version-c-api.c
//
// Copyright (c) 2026 Xiaomi Corporation

#include <stdio.h>

#include "sherpa-onnx/c-api/c-api.h"

int32_t main() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== file context =="
sed -n '1,40p' c-api-examples/version-c-api.c

echo
echo "== all version-c-api files =="
git ls-files | grep -E '(^|/)version-c-api\.c$' || true

echo
echo "== compiler availability and C semantics probe for int32_t main()/int main(void) =="
if command -v gcc >/dev/null 2>&1; then
  tmp="$(mktemp --suffix=.c)"
  cat > "$tmp" <<'EOF'
`#include` <stdint.h>
`#include` <stdio.h>

int32_t main() {
  printf("int32_t main()\n");
  return 0;
  // unreachable: int32_t has no default argument expressions, so
  // unspecified args would not make parameter count 0 for int.
}
EOF
  gcc -std=c11 -pedantic -Wall -Wextra -Werror "$tmp" 2>&1 || true
  rm -f "$tmp" a.out
fi

if command -v clang >/dev/null 2>&1; then
  tmp="$(mktemp --suffix=.c)"
  cat > "$tmp" <<'EOF'
`#include` <stdint.h>
`#include` <stdio.h>

int32_t main() {
  printf("int32_t main()\n");
  return 0;
}
EOF
  clang -std=c11 -pedantic -Wall -Wextra "$tmp" 2>&1 || true
  rm -f "$tmp" a.out
fi

echo
echo "== search for int32_t main declarations in repo =="
rg -n 'int32_t\s+main\s*\(' -g '*.c' -g '*.h' . || true

Repository: k2-fsa/sherpa-onnx

Length of output: 4774


Use a conforming C entry-point signature.

A hosted C program’s main should return int, and () declares unspecified arguments rather than no arguments. Use int main(void) so this entry point is portable and warning-clean with pedantic C compilers.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@c-api-examples/version-c-api.c` at line 9, Update the version-c-api.c entry
point from int32_t main() to int main(void), using the conforming return type
and explicit no-argument declaration.

printf("sherpa-onnx version : %s\n", SherpaOnnxGetVersionStr());
printf("sherpa-onnx Git SHA1: %s\n", SherpaOnnxGetGitSha1());
printf("sherpa-onnx Git date: %s\n", SherpaOnnxGetGitDate());
printf("onnxruntime version : %s\n", SherpaOnnxGetOnnxruntimeVersionStr());

return 0;
}
3 changes: 3 additions & 0 deletions cxx-api-examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
include_directories(${PROJECT_SOURCE_DIR})

add_executable(version-cxx-api ./version-cxx-api.cc)
target_link_libraries(version-cxx-api sherpa-onnx-cxx-api)

add_executable(streaming-zipformer-cxx-api ./streaming-zipformer-cxx-api.cc)
target_link_libraries(streaming-zipformer-cxx-api sherpa-onnx-cxx-api)

Expand Down
18 changes: 18 additions & 0 deletions cxx-api-examples/version-cxx-api.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// cxx-api-examples/version-cxx-api.cc
//
// Copyright (c) 2026 Xiaomi Corporation

#include <iostream>

#include "sherpa-onnx/c-api/cxx-api.h"

auto main() -> int {
std::cout << "sherpa-onnx version : " << sherpa_onnx::GetVersionStr()
<< "\n";
std::cout << "sherpa-onnx Git SHA1: " << sherpa_onnx::GetGitSha1() << "\n";
std::cout << "sherpa-onnx Git date: " << sherpa_onnx::GetGitDate() << "\n";
std::cout << "onnxruntime version : " << sherpa_onnx::GetOnnxruntimeVersionStr()
<< "\n";

return 0;
}
10 changes: 10 additions & 0 deletions dart-api-examples/version/bin/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2026 Xiaomi Corporation

import 'package:sherpa_onnx/src/version.dart' as sherpa_onnx;

void main() {
print('sherpa-onnx version: ${sherpa_onnx.getVersion()}');
print('sherpa-onnx git sha1: ${sherpa_onnx.getGitSha1()}');
print('sherpa-onnx git date: ${sherpa_onnx.getGitDate()}');
print('onnxruntime version: ${sherpa_onnx.getOnnxruntimeVersion()}');
}
14 changes: 14 additions & 0 deletions dart-api-examples/version/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: version
description: >
Print sherpa-onnx version info.

version: 1.0.0

environment:
sdk: ">=3.0.0 <4.0.0"

dependencies:
sherpa_onnx: ^1.13.4

dev_dependencies:
lints: ^3.0.0
7 changes: 7 additions & 0 deletions dart-api-examples/version/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

set -ex

dart pub get

dart run ./bin/main.dart
2 changes: 2 additions & 0 deletions dotnet-examples/version-test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ static void Main(string[] args)
var version = VersionInfo.Version;
var gitSha1 = VersionInfo.GitSha1;
var gitDate = VersionInfo.GitDate;
var onnxruntimeVersion = VersionInfo.OnnxruntimeVersion;

Console.WriteLine("sherpa-onnx version: {0}", version);
Console.WriteLine("sherpa-onnx gitSha1: {0}", gitSha1);
Console.WriteLine("sherpa-onnx gitDate: {0}", gitDate);
Console.WriteLine("onnxruntime version: {0}", onnxruntimeVersion);
}
}
10 changes: 10 additions & 0 deletions flutter/sherpa_onnx/lib/src/sherpa_onnx_bindings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,9 @@ typedef SherpaOnnxGetGitSha1 = SherpaOnnxGetGitSha1Native;
typedef SherpaOnnxGetGitDateNative = Pointer<Utf8> Function();
typedef SherpaOnnxGetGitDate = SherpaOnnxGetGitDateNative;

typedef SherpaOnnxGetOnnxruntimeVersionStrNative = Pointer<Utf8> Function();
typedef SherpaOnnxGetOnnxruntimeVersionStr = SherpaOnnxGetOnnxruntimeVersionStrNative;

class SherpaOnnxBindings {
static SherpaOnnxCreateOfflineSpeechDenoiser?
sherpaOnnxCreateOfflineSpeechDenoiser;
Expand Down Expand Up @@ -2102,6 +2105,7 @@ class SherpaOnnxBindings {
static SherpaOnnxGetVersionStr? getVersionStr;
static SherpaOnnxGetGitSha1? getGitSha1;
static SherpaOnnxGetGitDate? getGitDate;
static SherpaOnnxGetOnnxruntimeVersionStr? getOnnxruntimeVersionStr;

static void init(DynamicLibrary dynamicLibrary) {
sherpaOnnxCreateOfflineSpeechDenoiser ??= dynamicLibrary
Expand Down Expand Up @@ -2882,5 +2886,11 @@ class SherpaOnnxBindings {
'SherpaOnnxGetGitDate',
)
.asFunction();

getOnnxruntimeVersionStr ??= dynamicLibrary
.lookup<NativeFunction<SherpaOnnxGetOnnxruntimeVersionStrNative>>(
'SherpaOnnxGetOnnxruntimeVersionStr',
)
.asFunction();
}
}
11 changes: 11 additions & 0 deletions flutter/sherpa_onnx/lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,14 @@ String getGitDate() {

return gitDate.toDartString();
}

/// Return the onnxruntime version string used by the native library.
String getOnnxruntimeVersion() {
Pointer<Utf8> version =
SherpaOnnxBindings.getOnnxruntimeVersionStr?.call() ?? nullptr;
if (version == nullptr) {
return '';
}

return version.toDartString();
}
1 change: 1 addition & 0 deletions go-api-examples/streaming-decode-files/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ func main() {
log.Printf("sherpa-onnx version: %v\n", sherpa.GetVersion())
log.Printf("sherpa-onnx gitSha1: %v\n", sherpa.GetGitSha1())
log.Printf("sherpa-onnx gitDate: %v\n", sherpa.GetGitDate())
log.Printf("onnxruntime version: %v\n", sherpa.GetOnnxruntimeVersion())

log.SetFlags(log.LstdFlags | log.Lmicroseconds)

Expand Down
3 changes: 3 additions & 0 deletions harmony-os/SherpaOnnxHar/sherpa_onnx/src/main/cpp/version.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ void InitVersion(Napi::Env env, Napi::Object exports) {
Napi::String version = Napi::String::New(env, SherpaOnnxGetVersionStr());
Napi::String git_sha1 = Napi::String::New(env, SherpaOnnxGetGitSha1());
Napi::String git_date = Napi::String::New(env, SherpaOnnxGetGitDate());
Napi::String onnxruntime_version =
Napi::String::New(env, SherpaOnnxGetOnnxruntimeVersionStr());

exports.Set(Napi::String::New(env, "version"), version);
exports.Set(Napi::String::New(env, "gitSha1"), git_sha1);
exports.Set(Napi::String::New(env, "gitDate"), git_date);
exports.Set(Napi::String::New(env, "onnxruntimeVersion"), onnxruntime_version);
}
1 change: 1 addition & 0 deletions java-api-examples/VersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ public static void main(String[] args) {
System.out.printf("sherpa-onnx version: %s\n", VersionInfo.getVersion());
System.out.printf("sherpa-onnx gitSha1: %s\n", VersionInfo.getGitSha1());
System.out.printf("sherpa-onnx gitDate: %s\n", VersionInfo.getGitDate());
System.out.printf("onnxruntime version: %s\n", VersionInfo.getOnnxruntimeVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public static void main(String[] args) {
System.out.printf("sherpa-onnx version: %s\n", VersionInfo.getVersion());
System.out.printf("sherpa-onnx gitSha1: %s\n", VersionInfo.getGitSha1());
System.out.printf("sherpa-onnx gitDate: %s\n", VersionInfo.getGitDate());
System.out.printf("onnxruntime version: %s\n", VersionInfo.getOnnxruntimeVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public static void main(String[] args) {
System.out.printf("sherpa-onnx version: %s\n", VersionInfo.getVersion());
System.out.printf("sherpa-onnx gitSha1: %s\n", VersionInfo.getGitSha1());
System.out.printf("sherpa-onnx gitDate: %s\n", VersionInfo.getGitDate());
System.out.printf("onnxruntime version: %s\n", VersionInfo.getOnnxruntimeVersion());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public static void main(String[] args) {
System.out.printf("sherpa-onnx version: %s\n", VersionInfo.getVersion());
System.out.printf("sherpa-onnx gitSha1: %s\n", VersionInfo.getGitSha1());
System.out.printf("sherpa-onnx gitDate: %s\n", VersionInfo.getGitDate());
System.out.printf("onnxruntime version: %s\n", VersionInfo.getOnnxruntimeVersion());
}
}
1 change: 1 addition & 0 deletions kotlin-api-examples/test_version.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ fun main() {
println("sherpa-onnx version: ${VersionInfo.version}");
println("sherpa-onnx gitSha1: ${VersionInfo.gitSha1}");
println("sherpa-onnx gitDate: ${VersionInfo.gitDate}");
println("onnxruntime version: ${VersionInfo.onnxruntimeVersion}");
}

35 changes: 35 additions & 0 deletions pascal-api-examples/version/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env bash

set -ex

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Quote path variables before passing them to cd and fpc.

Unquoted expansions can break when the repository path contains spaces or glob characters.

Proposed fix
-SHERPA_ONNX_DIR=$(cd $SCRIPT_DIR/../.. && pwd)
+SHERPA_ONNX_DIR=$(cd "$SCRIPT_DIR/../.." && pwd)

-  -Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \
-  -Fl$SHERPA_ONNX_DIR/build/install/lib \
+  -Fu"$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api" \
+  -Fl"$SHERPA_ONNX_DIR/build/install/lib" \

Also applies to: 28-29

🧰 Tools
🪛 Shellcheck (0.11.0)

[info] 6-6: Double quote to prevent globbing and word splitting.

(SC2086)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pascal-api-examples/version/run.sh` at line 6, Quote the path variable
expansions used by cd and fpc in run.sh, including the SHERPA_ONNX_DIR
assignment and the additionally affected commands, so repository paths
containing spaces or glob characters are passed as single arguments.

Source: Linters/SAST tools


echo "SHERPA_ONNX_DIR: $SHERPA_ONNX_DIR"

if [[ ! -f ../../build/install/lib/libsherpa-onnx-c-api.dylib && ! -f ../../build/install/lib/libsherpa-onnx-c-api.so && ! -f ../../build/install/lib/sherpa-onnx-c-api.dll ]]; then
mkdir -p ../../build
pushd ../../build
cmake \
-DCMAKE_INSTALL_PREFIX=./install \
-DSHERPA_ONNX_ENABLE_PYTHON=OFF \
-DSHERPA_ONNX_ENABLE_TESTS=OFF \
-DSHERPA_ONNX_ENABLE_CHECK=OFF \
-DBUILD_SHARED_LIBS=ON \
-DSHERPA_ONNX_ENABLE_PORTAUDIO=OFF \
..

cmake --build . --target install --config Release
popd
fi

fpc \
-dSHERPA_ONNX_USE_SHARED_LIBS \
-Fu$SHERPA_ONNX_DIR/sherpa-onnx/pascal-api \
-Fl$SHERPA_ONNX_DIR/build/install/lib \
./version.pas

export LD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$SHERPA_ONNX_DIR/build/install/lib:$DYLD_LIBRARY_PATH

./version
15 changes: 15 additions & 0 deletions pascal-api-examples/version/version.pas
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// pascal-api-examples/version/version.pas
//
// Copyright (c) 2026 Xiaomi Corporation

program version;

uses
sherpa_onnx;

begin
WriteLn('sherpa-onnx version : ', SherpaOnnxGetVersionStr());
WriteLn('sherpa-onnx Git SHA1: ', SherpaOnnxGetGitSha1());
WriteLn('sherpa-onnx Git date: ', SherpaOnnxGetGitDate());
WriteLn('onnxruntime version : ', SherpaOnnxGetOnnxruntimeVersionStr());
end.
Loading
Loading