Files
sherpa-onnx/java-api-examples
Fangjun Kuang f2e01fe8e3 Widen VAD sample positions to int64_t to fix long-stream SIGSEGV. (#4079)
Fixes #3635

It is for v2.0.0 and breaks the ABI.

CircularBuffer::head_ and tail_ are absolute sample counters that grow
forever. As int32_t they overflow after 2^31 samples (~37 h at 16 kHz);
tail_ % capacity then goes negative and std::copy() writes to an invalid
iterator, crashing long-running VAD streams.

Widen every absolute stream position to int64_t. Counts and capacities
(Push/Pop/Get's n, Size(), capacity) stay int32_t — they are bounded by
buffer memory, not stream duration.
2026-10-22 23:39:59 +08:00
..
2026-09-10 21:52:45 +08:00
2026-09-10 21:52:45 +08:00

Introduction

This directory contains examples for the JAVA API of sherpa-onnx.

Supported platforms

OS Architecture Status
Linux x64 ✅
Linux ARM64 ✅
macOS x64 (Intel) ✅
macOS ARM64 (Apple Silicon) ✅
Windows x64 ✅
Windows ARM64 ✅

Usage

Non-streaming speech enhancement

./run-non-streaming-speech-enhancement-gtcrn.sh
./run-non-streaming-speech-enhancement-dpdfnet.sh

Use 16 kHz DPDFNet models such as dpdfnet_baseline.onnx, dpdfnet2.onnx, dpdfnet4.onnx, or dpdfnet8.onnx for downstream ASR and dpdfnet2_48khz_hr.onnx for 48 kHz enhancement output.

Non-streaming speaker diarization

./run-offline-speaker-diarization.sh

Streaming Speech recognition

./run-streaming-asr-from-mic-transducer.sh
./run-streaming-decode-file-ctc-hlg.sh
./run-streaming-decode-file-ctc.sh
./run-streaming-decode-file-paraformer.sh
./run-streaming-decode-file-tone-ctc.sh
./run-streaming-decode-file-transducer.sh

Non-Streaming Speech recognition

./run-non-streaming-decode-file-dolphin-ctc.sh
./run-non-streaming-decode-file-fire-red-asr-ctc.sh
./run-non-streaming-decode-file-fire-red-asr.sh
./run-non-streaming-decode-file-funasr-nano.sh
./run-non-streaming-decode-file-medasr-ctc.sh
./run-non-streaming-decode-file-moonshine.sh
./run-non-streaming-decode-file-moonshine-v2.sh
./run-non-streaming-decode-file-nemo-canary.sh
./run-non-streaming-decode-file-nemo.sh
./run-non-streaming-decode-file-omnilingual-asr-ctc.sh
./run-non-streaming-decode-file-paraformer.sh
./run-non-streaming-decode-file-sense-voice-with-hr.sh
./run-non-streaming-decode-file-sense-voice.sh
./run-non-streaming-decode-file-tele-speech-ctc.sh
./run-non-streaming-decode-file-transducer-hotwords.sh
./run-non-streaming-decode-file-transducer.sh
./run-non-streaming-decode-file-wenet-ctc.sh
./run-non-streaming-decode-file-whisper-multiple.sh
./run-non-streaming-decode-file-whisper.sh
./run-non-streaming-decode-file-zipformer-ctc.sh

Non-Streaming Speech recognition with homophone replacer

./run-non-streaming-decode-file-sense-voice-with-hr.sh

Non-Streaming text-to-speech

./run-non-streaming-tts-coqui-de.sh
./run-non-streaming-tts-kitten-en-lexicon.sh
./run-non-streaming-tts-kokoro-en-lexicon.sh
./run-non-streaming-tts-kokoro-zh-en-lexicon.sh
./run-non-streaming-tts-matcha-en-lexicon.sh
./run-non-streaming-tts-matcha-zh-lexicon.sh
./run-non-streaming-tts-piper-en-with-callback-lexicon.sh
./run-non-streaming-tts-piper-en-lexicon.sh
./run-non-streaming-tts-vits-zh-lexicon.sh
./run-pocket-tts.sh
./run-zipvoice-tts-lexicon.sh

Non-Streaming text-to-speech (Playback the audio as it is being generated)

./run-non-streaming-tts-piper-en-with-callback-lexicon.sh

Spoken language identification

./run-spoken-language-identification-whisper.sh

Add punctuations to text

The punctuation model supports both English and Chinese.

./run-offline-add-punctuation-zh-en.sh
./run-online-add-punctuation-zh-en.sh

Audio tagging

./run-audio-tagging-zipformer-from-file.sh
./run-audio-tagging-ced-from-file.sh

Speaker identification

./run-speaker-identification.sh

VAD with a microphone

./run-vad-from-mic.sh

VAD with a microphone + Non-streaming SenseVoice for speech recognition

./run-vad-from-mic-non-streaming-sense-voice.sh

VAD with a microphone + Non-streaming Paraformer for speech recognition

./run-vad-from-mic-non-streaming-paraformer.sh

VAD with a microphone + Non-streaming Whisper tiny.en for speech recognition

./run-vad-from-mic-non-streaming-whisper.sh

VAD (Remove silence)

./run-vad-remove-silence.sh
./run-ten-vad-remove-silence.sh

VAD + Non-streaming Dolphin CTC for speech recognition

./run-vad-non-streaming-dolphin-ctc.sh

VAD + Non-streaming SenseVoice for speech recognition

./run-vad-non-streaming-sense-voice.sh

VAD + Non-streaming Paraformer for speech recognition

./run-vad-non-streaming-paraformer.sh

Keyword spotter

./run-kws-from-file.sh