Files
sherpa-onnx/c-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
..

Introduction

This folder contains C API examples for sherpa-onnx.

Please refer to the documentation https://k2-fsa.github.io/sherpa/onnx/c-api/index.html for details.

File descriptions

  • decode-file-c-api.c This file shows how to use the C API for speech recognition with a streaming model.

  • offline-tts-c-api.c This file shows how to use the C API to convert text to speech with a non-streaming model.

  • speech-enhancement-gtcrn-c-api.c This file shows how to use the C API for speech enhancement with GTCRN models.

  • speech-enhancement-dpdfnet-c-api.c This file shows how to use the C API for speech enhancement with DPDFNet models. 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.

  • online-speech-enhancement-gtcrn-c-api.c This file shows how to use the C API for online speech enhancement with GTCRN models.

  • online-speech-enhancement-dpdfnet-c-api.c This file shows how to use the C API for online speech enhancement with DPDFNet models. Use dpdfnet_baseline.onnx, dpdfnet2.onnx, dpdfnet4.onnx, or dpdfnet8.onnx for 16 kHz output.