sherpa-onnx C API 1.0
Public C API and C++ wrapper for sherpa-onnx
Loading...
Searching...
No Matches
cxx-api.h File Reference

Public C++ wrapper for the sherpa-onnx C API. More...

#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "sherpa-onnx/c-api/c-api.h"
+ Include dependency graph for cxx-api.h:

Go to the source code of this file.

Classes

struct  sherpa_onnx::cxx::OnlineTransducerModelConfig
 Streaming transducer model files. More...
 
struct  sherpa_onnx::cxx::OnlineParaformerModelConfig
 Streaming Paraformer model files. More...
 
struct  sherpa_onnx::cxx::OnlineZipformer2CtcModelConfig
 Streaming Zipformer2 CTC model file. More...
 
struct  sherpa_onnx::cxx::OnlineNemoCtcModelConfig
 Streaming NeMo CTC model file. More...
 
struct  sherpa_onnx::cxx::OnlineToneCtcModelConfig
 Streaming T-One CTC model file. More...
 
struct  sherpa_onnx::cxx::OnlineModelConfig
 Acoustic model configuration for streaming ASR. More...
 
struct  sherpa_onnx::cxx::FeatureConfig
 Feature extraction settings shared by ASR and KWS wrappers. More...
 
struct  sherpa_onnx::cxx::OnlineCtcFstDecoderConfig
 Decoder graph configuration for online CTC + FST decoding. More...
 
struct  sherpa_onnx::cxx::HomophoneReplacerConfig
 Homophone replacement resources used by some Chinese ASR setups. More...
 
struct  sherpa_onnx::cxx::OnlineRecognizerConfig
 Configuration for streaming ASR. More...
 
struct  sherpa_onnx::cxx::OnlineRecognizerResult
 Current streaming ASR result copied into C++ containers. More...
 
struct  sherpa_onnx::cxx::Wave
 Mono PCM waveform used by the helper I/O functions. More...
 
class  sherpa_onnx::cxx::MoveOnly< Derived, T >
 Base class for move-only RAII wrappers around C handles. More...
 
class  sherpa_onnx::cxx::OnlineStream
 
class  sherpa_onnx::cxx::OnlineRecognizer
 RAII wrapper for a streaming recognizer. More...
 
struct  sherpa_onnx::cxx::OfflineTransducerModelConfig
 Offline transducer model files. More...
 
struct  sherpa_onnx::cxx::OfflineParaformerModelConfig
 Offline Paraformer model file. More...
 
struct  sherpa_onnx::cxx::OfflineNemoEncDecCtcModelConfig
 Offline NeMo EncDec CTC model file. More...
 
struct  sherpa_onnx::cxx::OfflineWhisperModelConfig
 Offline Whisper model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineCanaryModelConfig
 Offline Canary model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineCohereTranscribeModelConfig
 Offline Cohere Transcribe model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineFireRedAsrModelConfig
 Offline FireRed ASR model files. More...
 
struct  sherpa_onnx::cxx::OfflineFireRedAsrCtcModelConfig
 Offline FireRed ASR CTC model file. More...
 
struct  sherpa_onnx::cxx::OfflineTdnnModelConfig
 Offline TDNN model file. More...
 
struct  sherpa_onnx::cxx::OfflineSenseVoiceModelConfig
 Offline SenseVoice model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineDolphinModelConfig
 Offline Dolphin model file. More...
 
struct  sherpa_onnx::cxx::OfflineZipformerCtcModelConfig
 Offline Zipformer CTC model file. More...
 
struct  sherpa_onnx::cxx::OfflineWenetCtcModelConfig
 Offline WeNet CTC model file. More...
 
struct  sherpa_onnx::cxx::OfflineOmnilingualAsrCtcModelConfig
 Offline omnilingual ASR CTC model file. More...
 
struct  sherpa_onnx::cxx::OfflineMedAsrCtcModelConfig
 Offline MedASR CTC model file. More...
 
struct  sherpa_onnx::cxx::OfflineMoonshineModelConfig
 Offline Moonshine model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineFunASRNanoModelConfig
 Offline FunASR Nano model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineQwen3ASRModelConfig
 Offline Qwen3-ASR model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineModelConfig
 Acoustic model configuration for offline ASR. More...
 
struct  sherpa_onnx::cxx::OfflineLMConfig
 Optional language-model rescoring configuration for offline ASR. More...
 
struct  sherpa_onnx::cxx::OfflineRecognizerConfig
 Configuration for offline ASR. More...
 
struct  sherpa_onnx::cxx::OfflineRecognizerResult
 Offline ASR result copied into C++ containers. More...
 
class  sherpa_onnx::cxx::OfflineStream
 RAII wrapper for an offline decoding stream. More...
 
class  sherpa_onnx::cxx::OfflineRecognizer
 RAII wrapper for an offline recognizer. More...
 
struct  sherpa_onnx::cxx::OfflineTtsVitsModelConfig
 VITS model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsMatchaModelConfig
 Matcha model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsKokoroModelConfig
 Kokoro model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsKittenModelConfig
 Kitten model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsZipvoiceModelConfig
 ZipVoice model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsPocketModelConfig
 Pocket TTS model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsSupertonicModelConfig
 Supertonic model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineTtsModelConfig
 Model configuration for offline TTS. More...
 
struct  sherpa_onnx::cxx::GenerationConfig
 Generation-time options for advanced TTS synthesis. More...
 
struct  sherpa_onnx::cxx::OfflineTtsConfig
 Configuration for offline TTS. More...
 
struct  sherpa_onnx::cxx::GeneratedAudio
 Generated audio returned by the C++ TTS wrapper. More...
 
class  sherpa_onnx::cxx::OfflineTts
 RAII wrapper for offline TTS. More...
 
struct  sherpa_onnx::cxx::KeywordResult
 Current keyword spotting result copied into C++ containers. More...
 
struct  sherpa_onnx::cxx::KeywordSpotterConfig
 Configuration for the C++ keyword spotting wrapper. More...
 
class  sherpa_onnx::cxx::KeywordSpotter
 RAII wrapper for keyword spotting. More...
 
struct  sherpa_onnx::cxx::OfflineSpeechDenoiserGtcrnModelConfig
 GTCRN speech denoiser model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineSpeechDenoiserDpdfNetModelConfig
 DPDFNet speech denoiser model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineSpeechDenoiserModelConfig
 Speech denoiser model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineSpeechDenoiserConfig
 Configuration for offline speech denoising. More...
 
struct  sherpa_onnx::cxx::DenoisedAudio
 Denoised waveform returned by speech enhancement wrappers. More...
 
class  sherpa_onnx::cxx::OfflineSpeechDenoiser
 RAII wrapper for offline speech denoising. More...
 
struct  sherpa_onnx::cxx::OnlineSpeechDenoiserConfig
 Configuration for online speech denoising. More...
 
class  sherpa_onnx::cxx::OnlineSpeechDenoiser
 RAII wrapper for online speech denoising. More...
 
struct  sherpa_onnx::cxx::SileroVadModelConfig
 Silero VAD model configuration. More...
 
struct  sherpa_onnx::cxx::TenVadModelConfig
 Ten VAD model configuration. More...
 
struct  sherpa_onnx::cxx::VadModelConfig
 VAD model configuration. More...
 
struct  sherpa_onnx::cxx::SpeechSegment
 One speech segment produced by the VAD wrapper. More...
 
class  sherpa_onnx::cxx::CircularBuffer
 RAII wrapper for the circular buffer helper used by VAD. More...
 
class  sherpa_onnx::cxx::VoiceActivityDetector
 RAII wrapper for voice activity detection. More...
 
class  sherpa_onnx::cxx::LinearResampler
 RAII wrapper for linear resampling. More...
 
struct  sherpa_onnx::cxx::OfflinePunctuationModelConfig
 Offline punctuation model configuration. More...
 
struct  sherpa_onnx::cxx::OfflinePunctuationConfig
 Configuration for offline punctuation. More...
 
class  sherpa_onnx::cxx::OfflinePunctuation
 RAII wrapper for offline punctuation restoration. More...
 
struct  sherpa_onnx::cxx::OnlinePunctuationModelConfig
 Online punctuation model configuration. More...
 
struct  sherpa_onnx::cxx::OnlinePunctuationConfig
 Configuration for online punctuation. More...
 
class  sherpa_onnx::cxx::OnlinePunctuation
 RAII wrapper for online punctuation restoration. More...
 
struct  sherpa_onnx::cxx::OfflineZipformerAudioTaggingModelConfig
 Zipformer audio-tagging model configuration. More...
 
struct  sherpa_onnx::cxx::AudioTaggingModelConfig
 Audio-tagging model configuration. More...
 
struct  sherpa_onnx::cxx::AudioTaggingConfig
 Configuration for audio tagging. More...
 
struct  sherpa_onnx::cxx::AudioEvent
 One audio-tagging event returned by the C++ wrapper. More...
 
class  sherpa_onnx::cxx::AudioTagging
 RAII wrapper for audio tagging. More...
 
struct  sherpa_onnx::cxx::OfflineSourceSeparationSpleeterModelConfig
 Spleeter source-separation model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineSourceSeparationUvrModelConfig
 UVR (MDX-Net) source-separation model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineSourceSeparationModelConfig
 Source-separation model configuration. More...
 
struct  sherpa_onnx::cxx::OfflineSourceSeparationConfig
 Configuration for offline source separation. More...
 
struct  sherpa_onnx::cxx::SourceSeparationStem
 A single stem (output track) with one or more channels. More...
 
struct  sherpa_onnx::cxx::SourceSeparationOutput
 Output of a source-separation run. More...
 
class  sherpa_onnx::cxx::OfflineSourceSeparation
 RAII wrapper for offline source separation. More...
 

Namespaces

namespace  sherpa_onnx
 
namespace  sherpa_onnx::cxx
 

Typedefs

using sherpa_onnx::cxx::OfflineTtsCallback = int32_t(*)(const float *samples, int32_t num_samples, float progress, void *arg)
 TTS progress callback.
 

Functions

Wave sherpa_onnx::cxx::ReadWave (const std::string &filename)
 Read a mono WAVE file into a C++ value object.
 
bool sherpa_onnx::cxx::WriteWave (const std::string &filename, const Wave &wave)
 Write a mono WAVE file from a C++ value object.
 
std::string sherpa_onnx::cxx::GetVersionStr ()
 Return the sherpa-onnx version string as a C++ string.
 
std::string sherpa_onnx::cxx::GetGitSha1 ()
 Return the build Git SHA1 as a C++ string.
 
std::string sherpa_onnx::cxx::GetGitDate ()
 Return the build Git date as a C++ string.
 
bool sherpa_onnx::cxx::FileExists (const std::string &filename)
 Return true if a file exists.
 

Detailed Description

This header provides a lightweight C++ interface on top of c-api.h. The wrapper follows a few simple design rules:

  • Configuration objects are plain structs with std::string, std::vector, and default values
  • Runtime handles are move-only RAII classes that automatically release the underlying C handle
  • Result objects are copied into standard C++ containers so callers do not need to manage C-allocated memory manually
  • The API mirrors the C API closely, while offering a more idiomatic C++ surface

Major feature families available in this file:

  • Streaming ASR
  • Non-streaming ASR
  • Non-streaming TTS
  • Keyword spotting
  • Offline and online speech enhancement
  • VAD and circular buffering
  • Linear resampling
  • Version/file/WAVE helpers
  • Offline and online punctuation
  • Audio tagging

Typical usage pattern:

  1. Fill a config struct
  2. Create the corresponding RAII wrapper with Class::Create(...)
  3. Check wrapper.Get() for success
  4. Feed audio or text, run inference, and retrieve results as C++ objects
  5. Let destructors clean up automatically

Example programs are available in cxx-api-examples/ and show concrete model packages and end-to-end usage.

Definition in file cxx-api.h.