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

Public C API for sherpa-onnx. More...

#include <stdint.h>
+ Include dependency graph for c-api.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  SherpaOnnxOnlineTransducerModelConfig
 Configuration for a streaming transducer model. More...
 
struct  SherpaOnnxOnlineParaformerModelConfig
 Configuration for a streaming Paraformer model. More...
 
struct  SherpaOnnxOnlineZipformer2CtcModelConfig
 Configuration for a streaming Zipformer2 CTC model. More...
 
struct  SherpaOnnxOnlineNemoCtcModelConfig
 Configuration for a streaming NeMo CTC model. More...
 
struct  SherpaOnnxOnlineToneCtcModelConfig
 Configuration for a streaming T-One CTC model. More...
 
struct  SherpaOnnxOnlineModelConfig
 Model configuration shared by streaming ASR recognizers. More...
 
struct  SherpaOnnxFeatureConfig
 Feature extraction settings for ASR. More...
 
struct  SherpaOnnxOnlineCtcFstDecoderConfig
 Configuration for HLG/FST-based online CTC decoding. More...
 
struct  SherpaOnnxHomophoneReplacerConfig
 Configuration for homophone replacement. More...
 
struct  SherpaOnnxOnlineRecognizerConfig
 Configuration for a streaming ASR recognizer. More...
 
struct  SherpaOnnxOnlineRecognizerResult
 Incremental recognition result for a streaming ASR stream. More...
 
struct  SherpaOnnxOfflineTransducerModelConfig
 Configuration for a non-streaming transducer model. More...
 
struct  SherpaOnnxOfflineParaformerModelConfig
 Configuration for a non-streaming Paraformer model. More...
 
struct  SherpaOnnxOfflineNemoEncDecCtcModelConfig
 Configuration for a non-streaming NeMo CTC model. More...
 
struct  SherpaOnnxOfflineWhisperModelConfig
 Configuration for a non-streaming Whisper model. More...
 
struct  SherpaOnnxOfflineCanaryModelConfig
 Configuration for a Canary model. More...
 
struct  SherpaOnnxOfflineCohereTranscribeModelConfig
 Configuration for a Cohere Transcribe model. More...
 
struct  SherpaOnnxOfflineFireRedAsrModelConfig
 Configuration for a FireRedAsr encoder/decoder model. More...
 
struct  SherpaOnnxOfflineFireRedAsrCtcModelConfig
 Configuration for a FireRedAsr CTC model. More...
 
struct  SherpaOnnxOfflineMoonshineModelConfig
 Configuration for a Moonshine model. More...
 
struct  SherpaOnnxOfflineTdnnModelConfig
 Configuration for a TDNN model. More...
 
struct  SherpaOnnxOfflineLMConfig
 Configuration for an offline language model. More...
 
struct  SherpaOnnxOfflineSenseVoiceModelConfig
 Configuration for a SenseVoice model. More...
 
struct  SherpaOnnxOfflineDolphinModelConfig
 Configuration for a Dolphin model. More...
 
struct  SherpaOnnxOfflineZipformerCtcModelConfig
 Configuration for an offline Zipformer CTC model. More...
 
struct  SherpaOnnxOfflineWenetCtcModelConfig
 Configuration for an offline WeNet CTC model. More...
 
struct  SherpaOnnxOfflineOmnilingualAsrCtcModelConfig
 Configuration for an omnilingual offline CTC model. More...
 
struct  SherpaOnnxOfflineFunASRNanoModelConfig
 Configuration for an offline FunASR Nano model. More...
 
struct  SherpaOnnxOfflineQwen3ASRModelConfig
 Configuration for an offline Qwen3-ASR model. More...
 
struct  SherpaOnnxOfflineMedAsrCtcModelConfig
 Configuration for a MedASR CTC model. More...
 
struct  SherpaOnnxOfflineModelConfig
 Model configuration shared by offline ASR recognizers. More...
 
struct  SherpaOnnxOfflineRecognizerConfig
 Configuration for a non-streaming ASR recognizer. More...
 
struct  SherpaOnnxOfflineRecognizerResult
 Recognition result for a non-streaming ASR stream. More...
 
struct  SherpaOnnxKeywordResult
 Snapshot of the current keyword spotting result. More...
 
struct  SherpaOnnxKeywordSpotterConfig
 Configuration for keyword spotting. More...
 
struct  SherpaOnnxSileroVadModelConfig
 Configuration for a Silero VAD model. More...
 
struct  SherpaOnnxTenVadModelConfig
 Configuration for a Ten VAD model. More...
 
struct  SherpaOnnxVadModelConfig
 Configuration shared by voice activity detectors. More...
 
struct  SherpaOnnxSpeechSegment
 One detected speech segment returned by the VAD. More...
 
struct  SherpaOnnxOfflineTtsVitsModelConfig
 Configuration for a VITS TTS model. More...
 
struct  SherpaOnnxOfflineTtsMatchaModelConfig
 Configuration for a Matcha TTS model. More...
 
struct  SherpaOnnxOfflineTtsKokoroModelConfig
 Configuration for a Kokoro TTS model. More...
 
struct  SherpaOnnxOfflineTtsKittenModelConfig
 Configuration for a Kitten TTS model. More...
 
struct  SherpaOnnxOfflineTtsZipvoiceModelConfig
 Configuration for a ZipVoice TTS model. More...
 
struct  SherpaOnnxOfflineTtsPocketModelConfig
 Configuration for a Pocket TTS model. More...
 
struct  SherpaOnnxOfflineTtsSupertonicModelConfig
 Configuration for a Supertonic TTS model. More...
 
struct  SherpaOnnxOfflineTtsModelConfig
 Configuration shared by offline TTS models. More...
 
struct  SherpaOnnxOfflineTtsConfig
 Configuration for offline text-to-speech. More...
 
struct  SherpaOnnxGeneratedAudio
 Generated waveform returned by TTS APIs. More...
 
struct  SherpaOnnxGenerationConfig
 Generation-time parameters shared by advanced TTS APIs. More...
 
struct  SherpaOnnxWave
 Decoded mono WAVE file content. More...
 
struct  SherpaOnnxMultiChannelWave
 Decoded multi-channel WAVE file content. More...
 
struct  SherpaOnnxSpokenLanguageIdentificationWhisperConfig
 Whisper-based model files for spoken language identification. More...
 
struct  SherpaOnnxSpokenLanguageIdentificationConfig
 Configuration for spoken language identification. More...
 
struct  SherpaOnnxSpokenLanguageIdentificationResult
 Result of spoken-language identification. More...
 
struct  SherpaOnnxSpeakerEmbeddingExtractorConfig
 Configuration for speaker embedding extraction. More...
 
struct  SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch
 One speaker match returned by the best-matches API. More...
 
struct  SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult
 Collection of best speaker matches. More...
 
struct  SherpaOnnxOfflineZipformerAudioTaggingModelConfig
 Zipformer audio-tagging model configuration. More...
 
struct  SherpaOnnxAudioTaggingModelConfig
 Audio-tagging model configuration. More...
 
struct  SherpaOnnxAudioTaggingConfig
 Configuration for audio tagging. More...
 
struct  SherpaOnnxAudioEvent
 One audio-tagging prediction. More...
 
struct  SherpaOnnxOfflinePunctuationModelConfig
 Offline punctuation model configuration. More...
 
struct  SherpaOnnxOfflinePunctuationConfig
 Configuration for offline punctuation. More...
 
struct  SherpaOnnxOnlinePunctuationModelConfig
 Online punctuation model configuration. More...
 
struct  SherpaOnnxOnlinePunctuationConfig
 Configuration for online punctuation. More...
 
struct  SherpaOnnxResampleOut
 Output chunk returned by SherpaOnnxLinearResamplerResample(). More...
 
struct  SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig
 Pyannote speaker-segmentation model configuration. More...
 
struct  SherpaOnnxOfflineSpeakerSegmentationModelConfig
 Segmentation model configuration for offline speaker diarization. More...
 
struct  SherpaOnnxFastClusteringConfig
 Fast clustering configuration. More...
 
struct  SherpaOnnxOfflineSpeakerDiarizationConfig
 Configuration for offline speaker diarization. More...
 
struct  SherpaOnnxOfflineSpeakerDiarizationSegment
 One diarization segment. More...
 
struct  SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig
 GTCRN offline denoiser model configuration. More...
 
struct  SherpaOnnxOfflineSpeechDenoiserDpdfNetModelConfig
 DPDFNet offline denoiser model configuration. More...
 
struct  SherpaOnnxOfflineSpeechDenoiserModelConfig
 Speech denoiser model configuration shared by offline and online APIs. More...
 
struct  SherpaOnnxOfflineSpeechDenoiserConfig
 Configuration for offline speech denoising. More...
 
struct  SherpaOnnxDenoisedAudio
 Denoised audio returned by offline or online speech enhancement APIs. More...
 
struct  SherpaOnnxOnlineSpeechDenoiserConfig
 Configuration for streaming speech denoising. More...
 
struct  SherpaOnnxOfflineSourceSeparationSpleeterModelConfig
 Spleeter source-separation model configuration. More...
 
struct  SherpaOnnxOfflineSourceSeparationUvrModelConfig
 UVR (MDX-Net) source-separation model configuration. More...
 
struct  SherpaOnnxOfflineSourceSeparationModelConfig
 Source-separation model configuration. More...
 
struct  SherpaOnnxOfflineSourceSeparationConfig
 Top-level source-separation configuration. More...
 
struct  SherpaOnnxSourceSeparationStem
 A single stem (one output track) with one or more channels. More...
 
struct  SherpaOnnxSourceSeparationOutput
 Output of a source-separation run. More...
 

Macros

#define SHERPA_ONNX_EXPORT   __attribute__((visibility("default")))
 
#define SHERPA_ONNX_IMPORT   SHERPA_ONNX_EXPORT
 
#define SHERPA_ONNX_API   SHERPA_ONNX_IMPORT
 

Typedefs

typedef struct SherpaOnnxOnlineTransducerModelConfig SherpaOnnxOnlineTransducerModelConfig
 Configuration for a streaming transducer model.
 
typedef struct SherpaOnnxOnlineParaformerModelConfig SherpaOnnxOnlineParaformerModelConfig
 Configuration for a streaming Paraformer model.
 
typedef struct SherpaOnnxOnlineZipformer2CtcModelConfig SherpaOnnxOnlineZipformer2CtcModelConfig
 Configuration for a streaming Zipformer2 CTC model.
 
typedef struct SherpaOnnxOnlineNemoCtcModelConfig SherpaOnnxOnlineNemoCtcModelConfig
 Configuration for a streaming NeMo CTC model.
 
typedef struct SherpaOnnxOnlineToneCtcModelConfig SherpaOnnxOnlineToneCtcModelConfig
 Configuration for a streaming T-One CTC model.
 
typedef struct SherpaOnnxOnlineModelConfig SherpaOnnxOnlineModelConfig
 Model configuration shared by streaming ASR recognizers.
 
typedef struct SherpaOnnxFeatureConfig SherpaOnnxFeatureConfig
 Feature extraction settings for ASR.
 
typedef struct SherpaOnnxOnlineCtcFstDecoderConfig SherpaOnnxOnlineCtcFstDecoderConfig
 Configuration for HLG/FST-based online CTC decoding.
 
typedef struct SherpaOnnxHomophoneReplacerConfig SherpaOnnxHomophoneReplacerConfig
 Configuration for homophone replacement.
 
typedef struct SherpaOnnxOnlineRecognizerConfig SherpaOnnxOnlineRecognizerConfig
 Configuration for a streaming ASR recognizer.
 
typedef struct SherpaOnnxOnlineRecognizerResult SherpaOnnxOnlineRecognizerResult
 Incremental recognition result for a streaming ASR stream.
 
typedef struct SherpaOnnxOnlineRecognizer SherpaOnnxOnlineRecognizer
 Streaming recognizer handle.
 
typedef struct SherpaOnnxOnlineStream SherpaOnnxOnlineStream
 Streaming decoding state for one utterance or stream.
 
typedef struct SherpaOnnxDisplay SherpaOnnxDisplay
 Helper for pretty-printing incremental recognition results.
 
typedef struct SherpaOnnxOfflineTransducerModelConfig SherpaOnnxOfflineTransducerModelConfig
 Configuration for a non-streaming transducer model.
 
typedef struct SherpaOnnxOfflineParaformerModelConfig SherpaOnnxOfflineParaformerModelConfig
 Configuration for a non-streaming Paraformer model.
 
typedef struct SherpaOnnxOfflineNemoEncDecCtcModelConfig SherpaOnnxOfflineNemoEncDecCtcModelConfig
 Configuration for a non-streaming NeMo CTC model.
 
typedef struct SherpaOnnxOfflineWhisperModelConfig SherpaOnnxOfflineWhisperModelConfig
 Configuration for a non-streaming Whisper model.
 
typedef struct SherpaOnnxOfflineCanaryModelConfig SherpaOnnxOfflineCanaryModelConfig
 Configuration for a Canary model.
 
typedef struct SherpaOnnxOfflineCohereTranscribeModelConfig SherpaOnnxOfflineCohereTranscribeModelConfig
 Configuration for a Cohere Transcribe model.
 
typedef struct SherpaOnnxOfflineFireRedAsrModelConfig SherpaOnnxOfflineFireRedAsrModelConfig
 Configuration for a FireRedAsr encoder/decoder model.
 
typedef struct SherpaOnnxOfflineFireRedAsrCtcModelConfig SherpaOnnxOfflineFireRedAsrCtcModelConfig
 Configuration for a FireRedAsr CTC model.
 
typedef struct SherpaOnnxOfflineMoonshineModelConfig SherpaOnnxOfflineMoonshineModelConfig
 Configuration for a Moonshine model.
 
typedef struct SherpaOnnxOfflineTdnnModelConfig SherpaOnnxOfflineTdnnModelConfig
 Configuration for a TDNN model.
 
typedef struct SherpaOnnxOfflineLMConfig SherpaOnnxOfflineLMConfig
 Configuration for an offline language model.
 
typedef struct SherpaOnnxOfflineSenseVoiceModelConfig SherpaOnnxOfflineSenseVoiceModelConfig
 Configuration for a SenseVoice model.
 
typedef struct SherpaOnnxOfflineDolphinModelConfig SherpaOnnxOfflineDolphinModelConfig
 Configuration for a Dolphin model.
 
typedef struct SherpaOnnxOfflineZipformerCtcModelConfig SherpaOnnxOfflineZipformerCtcModelConfig
 Configuration for an offline Zipformer CTC model.
 
typedef struct SherpaOnnxOfflineWenetCtcModelConfig SherpaOnnxOfflineWenetCtcModelConfig
 Configuration for an offline WeNet CTC model.
 
typedef struct SherpaOnnxOfflineOmnilingualAsrCtcModelConfig SherpaOnnxOfflineOmnilingualAsrCtcModelConfig
 Configuration for an omnilingual offline CTC model.
 
typedef struct SherpaOnnxOfflineFunASRNanoModelConfig SherpaOnnxOfflineFunASRNanoModelConfig
 Configuration for an offline FunASR Nano model.
 
typedef struct SherpaOnnxOfflineQwen3ASRModelConfig SherpaOnnxOfflineQwen3ASRModelConfig
 Configuration for an offline Qwen3-ASR model.
 
typedef struct SherpaOnnxOfflineMedAsrCtcModelConfig SherpaOnnxOfflineMedAsrCtcModelConfig
 Configuration for a MedASR CTC model.
 
typedef struct SherpaOnnxOfflineModelConfig SherpaOnnxOfflineModelConfig
 Model configuration shared by offline ASR recognizers.
 
typedef struct SherpaOnnxOfflineRecognizerConfig SherpaOnnxOfflineRecognizerConfig
 Configuration for a non-streaming ASR recognizer.
 
typedef struct SherpaOnnxOfflineRecognizer SherpaOnnxOfflineRecognizer
 Non-streaming recognizer handle.
 
typedef struct SherpaOnnxOfflineStream SherpaOnnxOfflineStream
 Non-streaming decoding state for one utterance.
 
typedef struct SherpaOnnxOfflineRecognizerResult SherpaOnnxOfflineRecognizerResult
 Recognition result for a non-streaming ASR stream.
 
typedef struct SherpaOnnxKeywordResult SherpaOnnxKeywordResult
 Snapshot of the current keyword spotting result.
 
typedef struct SherpaOnnxKeywordSpotterConfig SherpaOnnxKeywordSpotterConfig
 Configuration for keyword spotting.
 
typedef struct SherpaOnnxKeywordSpotter SherpaOnnxKeywordSpotter
 Opaque keyword spotter handle.
 
typedef struct SherpaOnnxSileroVadModelConfig SherpaOnnxSileroVadModelConfig
 Configuration for a Silero VAD model.
 
typedef struct SherpaOnnxTenVadModelConfig SherpaOnnxTenVadModelConfig
 Configuration for a Ten VAD model.
 
typedef struct SherpaOnnxVadModelConfig SherpaOnnxVadModelConfig
 Configuration shared by voice activity detectors.
 
typedef struct SherpaOnnxCircularBuffer SherpaOnnxCircularBuffer
 Opaque circular-buffer handle used by helper APIs.
 
typedef struct SherpaOnnxSpeechSegment SherpaOnnxSpeechSegment
 One detected speech segment returned by the VAD.
 
typedef struct SherpaOnnxVoiceActivityDetector SherpaOnnxVoiceActivityDetector
 Opaque voice activity detector handle.
 
typedef struct SherpaOnnxOfflineTtsVitsModelConfig SherpaOnnxOfflineTtsVitsModelConfig
 Configuration for a VITS TTS model.
 
typedef struct SherpaOnnxOfflineTtsMatchaModelConfig SherpaOnnxOfflineTtsMatchaModelConfig
 Configuration for a Matcha TTS model.
 
typedef struct SherpaOnnxOfflineTtsKokoroModelConfig SherpaOnnxOfflineTtsKokoroModelConfig
 Configuration for a Kokoro TTS model.
 
typedef struct SherpaOnnxOfflineTtsKittenModelConfig SherpaOnnxOfflineTtsKittenModelConfig
 Configuration for a Kitten TTS model.
 
typedef struct SherpaOnnxOfflineTtsZipvoiceModelConfig SherpaOnnxOfflineTtsZipvoiceModelConfig
 Configuration for a ZipVoice TTS model.
 
typedef struct SherpaOnnxOfflineTtsPocketModelConfig SherpaOnnxOfflineTtsPocketModelConfig
 Configuration for a Pocket TTS model.
 
typedef struct SherpaOnnxOfflineTtsSupertonicModelConfig SherpaOnnxOfflineTtsSupertonicModelConfig
 Configuration for a Supertonic TTS model.
 
typedef struct SherpaOnnxOfflineTtsModelConfig SherpaOnnxOfflineTtsModelConfig
 Configuration shared by offline TTS models.
 
typedef struct SherpaOnnxOfflineTtsConfig SherpaOnnxOfflineTtsConfig
 Configuration for offline text-to-speech.
 
typedef struct SherpaOnnxGeneratedAudio SherpaOnnxGeneratedAudio
 Generated waveform returned by TTS APIs.
 
typedef int32_t(* SherpaOnnxGeneratedAudioCallback) (const float *samples, int32_t n)
 Callback invoked during incremental generation.
 
typedef int32_t(* SherpaOnnxGeneratedAudioCallbackWithArg) (const float *samples, int32_t n, void *arg)
 Same as SherpaOnnxGeneratedAudioCallback but with an extra user pointer.
 
typedef int32_t(* SherpaOnnxGeneratedAudioProgressCallback) (const float *samples, int32_t n, float p)
 Progress callback invoked during incremental generation.
 
typedef int32_t(* SherpaOnnxGeneratedAudioProgressCallbackWithArg) (const float *samples, int32_t n, float p, void *arg)
 Same as SherpaOnnxGeneratedAudioProgressCallback but with an extra user pointer.
 
typedef struct SherpaOnnxOfflineTts SherpaOnnxOfflineTts
 Opaque offline TTS handle.
 
typedef struct SherpaOnnxGenerationConfig SherpaOnnxGenerationConfig
 Generation-time parameters shared by advanced TTS APIs.
 
typedef struct SherpaOnnxWave SherpaOnnxWave
 Decoded mono WAVE file content.
 
typedef struct SherpaOnnxMultiChannelWave SherpaOnnxMultiChannelWave
 Decoded multi-channel WAVE file content.
 
typedef struct SherpaOnnxSpokenLanguageIdentificationWhisperConfig SherpaOnnxSpokenLanguageIdentificationWhisperConfig
 Whisper-based model files for spoken language identification.
 
typedef struct SherpaOnnxSpokenLanguageIdentificationConfig SherpaOnnxSpokenLanguageIdentificationConfig
 Configuration for spoken language identification.
 
typedef struct SherpaOnnxSpokenLanguageIdentification SherpaOnnxSpokenLanguageIdentification
 Opaque spoken-language identification handle.
 
typedef struct SherpaOnnxSpokenLanguageIdentificationResult SherpaOnnxSpokenLanguageIdentificationResult
 Result of spoken-language identification.
 
typedef struct SherpaOnnxSpeakerEmbeddingExtractorConfig SherpaOnnxSpeakerEmbeddingExtractorConfig
 Configuration for speaker embedding extraction.
 
typedef struct SherpaOnnxSpeakerEmbeddingExtractor SherpaOnnxSpeakerEmbeddingExtractor
 Opaque speaker embedding extractor handle.
 
typedef struct SherpaOnnxSpeakerEmbeddingManager SherpaOnnxSpeakerEmbeddingManager
 Opaque speaker embedding manager handle.
 
typedef struct SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch
 One speaker match returned by the best-matches API.
 
typedef struct SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult
 Collection of best speaker matches.
 
typedef struct SherpaOnnxOfflineZipformerAudioTaggingModelConfig SherpaOnnxOfflineZipformerAudioTaggingModelConfig
 Zipformer audio-tagging model configuration.
 
typedef struct SherpaOnnxAudioTaggingModelConfig SherpaOnnxAudioTaggingModelConfig
 Audio-tagging model configuration.
 
typedef struct SherpaOnnxAudioTaggingConfig SherpaOnnxAudioTaggingConfig
 Configuration for audio tagging.
 
typedef struct SherpaOnnxAudioEvent SherpaOnnxAudioEvent
 One audio-tagging prediction.
 
typedef struct SherpaOnnxAudioTagging SherpaOnnxAudioTagging
 Opaque audio tagger handle.
 
typedef struct SherpaOnnxOfflinePunctuationModelConfig SherpaOnnxOfflinePunctuationModelConfig
 Offline punctuation model configuration.
 
typedef struct SherpaOnnxOfflinePunctuationConfig SherpaOnnxOfflinePunctuationConfig
 Configuration for offline punctuation.
 
typedef struct SherpaOnnxOfflinePunctuation SherpaOnnxOfflinePunctuation
 Opaque offline punctuation handle.
 
typedef struct SherpaOnnxOnlinePunctuationModelConfig SherpaOnnxOnlinePunctuationModelConfig
 Online punctuation model configuration.
 
typedef struct SherpaOnnxOnlinePunctuationConfig SherpaOnnxOnlinePunctuationConfig
 Configuration for online punctuation.
 
typedef struct SherpaOnnxOnlinePunctuation SherpaOnnxOnlinePunctuation
 Opaque online punctuation handle.
 
typedef struct SherpaOnnxLinearResampler SherpaOnnxLinearResampler
 Opaque linear resampler handle.
 
typedef struct SherpaOnnxResampleOut SherpaOnnxResampleOut
 Output chunk returned by SherpaOnnxLinearResamplerResample().
 
typedef struct SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig
 Pyannote speaker-segmentation model configuration.
 
typedef struct SherpaOnnxOfflineSpeakerSegmentationModelConfig SherpaOnnxOfflineSpeakerSegmentationModelConfig
 Segmentation model configuration for offline speaker diarization.
 
typedef struct SherpaOnnxFastClusteringConfig SherpaOnnxFastClusteringConfig
 Fast clustering configuration.
 
typedef struct SherpaOnnxOfflineSpeakerDiarizationConfig SherpaOnnxOfflineSpeakerDiarizationConfig
 Configuration for offline speaker diarization.
 
typedef struct SherpaOnnxOfflineSpeakerDiarization SherpaOnnxOfflineSpeakerDiarization
 Opaque offline speaker diarization handle.
 
typedef struct SherpaOnnxOfflineSpeakerDiarizationResult SherpaOnnxOfflineSpeakerDiarizationResult
 Opaque offline speaker diarization result.
 
typedef struct SherpaOnnxOfflineSpeakerDiarizationSegment SherpaOnnxOfflineSpeakerDiarizationSegment
 One diarization segment.
 
typedef int32_t(* SherpaOnnxOfflineSpeakerDiarizationProgressCallback) (int32_t num_processed_chunks, int32_t num_total_chunks, void *arg)
 Progress callback for offline speaker diarization.
 
typedef int32_t(* SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg) (int32_t num_processed_chunks, int32_t num_total_chunks)
 Same as SherpaOnnxOfflineSpeakerDiarizationProgressCallback but without a user pointer.
 
typedef struct SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig
 GTCRN offline denoiser model configuration.
 
typedef struct SherpaOnnxOfflineSpeechDenoiserDpdfNetModelConfig SherpaOnnxOfflineSpeechDenoiserDpdfNetModelConfig
 DPDFNet offline denoiser model configuration.
 
typedef struct SherpaOnnxOfflineSpeechDenoiserModelConfig SherpaOnnxOfflineSpeechDenoiserModelConfig
 Speech denoiser model configuration shared by offline and online APIs.
 
typedef struct SherpaOnnxOfflineSpeechDenoiserConfig SherpaOnnxOfflineSpeechDenoiserConfig
 Configuration for offline speech denoising.
 
typedef struct SherpaOnnxOfflineSpeechDenoiser SherpaOnnxOfflineSpeechDenoiser
 Opaque offline speech denoiser handle.
 
typedef struct SherpaOnnxDenoisedAudio SherpaOnnxDenoisedAudio
 Denoised audio returned by offline or online speech enhancement APIs.
 
typedef struct SherpaOnnxOnlineSpeechDenoiserConfig SherpaOnnxOnlineSpeechDenoiserConfig
 Configuration for streaming speech denoising.
 
typedef struct SherpaOnnxOnlineSpeechDenoiser SherpaOnnxOnlineSpeechDenoiser
 Opaque online speech denoiser handle.
 
typedef struct SherpaOnnxOfflineSourceSeparationSpleeterModelConfig SherpaOnnxOfflineSourceSeparationSpleeterModelConfig
 Spleeter source-separation model configuration.
 
typedef struct SherpaOnnxOfflineSourceSeparationUvrModelConfig SherpaOnnxOfflineSourceSeparationUvrModelConfig
 UVR (MDX-Net) source-separation model configuration.
 
typedef struct SherpaOnnxOfflineSourceSeparationModelConfig SherpaOnnxOfflineSourceSeparationModelConfig
 Source-separation model configuration.
 
typedef struct SherpaOnnxOfflineSourceSeparationConfig SherpaOnnxOfflineSourceSeparationConfig
 Top-level source-separation configuration.
 
typedef struct SherpaOnnxOfflineSourceSeparation SherpaOnnxOfflineSourceSeparation
 Opaque source-separation engine handle.
 
typedef struct SherpaOnnxSourceSeparationStem SherpaOnnxSourceSeparationStem
 A single stem (one output track) with one or more channels.
 
typedef struct SherpaOnnxSourceSeparationOutput SherpaOnnxSourceSeparationOutput
 Output of a source-separation run.
 

Functions

const char * SherpaOnnxGetVersionStr ()
 Return the sherpa-onnx version string.
 
const char * SherpaOnnxGetGitSha1 ()
 Return the Git SHA1 used to build the library.
 
const char * SherpaOnnxGetGitDate ()
 Return the Git build date used to build the library.
 
int32_t SherpaOnnxFileExists (const char *filename)
 Check whether a file exists.
 
const SherpaOnnxOnlineRecognizerSherpaOnnxCreateOnlineRecognizer (const SherpaOnnxOnlineRecognizerConfig *config)
 Create a streaming ASR recognizer.
 
void SherpaOnnxDestroyOnlineRecognizer (const SherpaOnnxOnlineRecognizer *recognizer)
 Destroy a streaming recognizer.
 
const SherpaOnnxOnlineStreamSherpaOnnxCreateOnlineStream (const SherpaOnnxOnlineRecognizer *recognizer)
 Create a streaming ASR state object.
 
const SherpaOnnxOnlineStreamSherpaOnnxCreateOnlineStreamWithHotwords (const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords)
 Create a streaming ASR state object with per-stream hotwords.
 
void SherpaOnnxDestroyOnlineStream (const SherpaOnnxOnlineStream *stream)
 Destroy a streaming ASR state object.
 
void SherpaOnnxOnlineStreamAcceptWaveform (const SherpaOnnxOnlineStream *stream, int32_t sample_rate, const float *samples, int32_t n)
 Append audio samples to a streaming ASR stream.
 
int32_t SherpaOnnxIsOnlineStreamReady (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
 Check whether a streaming ASR stream is ready to decode.
 
void SherpaOnnxDecodeOnlineStream (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
 Decode one step of a streaming ASR stream.
 
void SherpaOnnxDecodeMultipleOnlineStreams (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream **streams, int32_t n)
 Decode multiple streaming ASR streams in parallel.
 
const SherpaOnnxOnlineRecognizerResultSherpaOnnxGetOnlineStreamResult (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
 Get the current streaming ASR result for a stream.
 
void SherpaOnnxDestroyOnlineRecognizerResult (const SherpaOnnxOnlineRecognizerResult *r)
 Destroy a result returned by SherpaOnnxGetOnlineStreamResult().
 
const char * SherpaOnnxGetOnlineStreamResultAsJson (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
 Get the current streaming ASR result as JSON.
 
void SherpaOnnxDestroyOnlineStreamResultJson (const char *s)
 Free a JSON string returned by SherpaOnnxGetOnlineStreamResultAsJson().
 
void SherpaOnnxOnlineStreamReset (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
 Reset a streaming ASR stream after an endpoint or utterance boundary.
 
void SherpaOnnxOnlineStreamInputFinished (const SherpaOnnxOnlineStream *stream)
 Signal end-of-input for a streaming ASR stream.
 
void SherpaOnnxOnlineStreamSetOption (const SherpaOnnxOnlineStream *stream, const char *key, const char *value)
 Set a per-stream runtime option.
 
const char * SherpaOnnxOnlineStreamGetOption (const SherpaOnnxOnlineStream *stream, const char *key)
 Get a per-stream runtime option.
 
int32_t SherpaOnnxOnlineStreamHasOption (const SherpaOnnxOnlineStream *stream, const char *key)
 Check whether a per-stream runtime option exists.
 
int32_t SherpaOnnxOnlineStreamIsEndpoint (const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
 Check whether endpoint detection has triggered for a stream.
 
const SherpaOnnxDisplaySherpaOnnxCreateDisplay (int32_t max_word_per_line)
 Create a display helper.
 
void SherpaOnnxDestroyDisplay (const SherpaOnnxDisplay *display)
 Destroy a display helper.
 
void SherpaOnnxPrint (const SherpaOnnxDisplay *display, int32_t idx, const char *s)
 Print one line of text using the display helper.
 
const SherpaOnnxOfflineRecognizerSherpaOnnxCreateOfflineRecognizer (const SherpaOnnxOfflineRecognizerConfig *config)
 Create a non-streaming ASR recognizer.
 
void SherpaOnnxOfflineRecognizerSetConfig (const SherpaOnnxOfflineRecognizer *recognizer, const SherpaOnnxOfflineRecognizerConfig *config)
 Update the configuration of an existing offline recognizer.
 
void SherpaOnnxDestroyOfflineRecognizer (const SherpaOnnxOfflineRecognizer *recognizer)
 Destroy a non-streaming recognizer.
 
const SherpaOnnxOfflineStreamSherpaOnnxCreateOfflineStream (const SherpaOnnxOfflineRecognizer *recognizer)
 Create a non-streaming ASR input stream.
 
const SherpaOnnxOfflineStreamSherpaOnnxCreateOfflineStreamWithHotwords (const SherpaOnnxOfflineRecognizer *recognizer, const char *hotwords)
 Create a non-streaming ASR input stream with per-stream hotwords.
 
void SherpaOnnxDestroyOfflineStream (const SherpaOnnxOfflineStream *stream)
 Destroy a non-streaming ASR stream.
 
void SherpaOnnxAcceptWaveformOffline (const SherpaOnnxOfflineStream *stream, int32_t sample_rate, const float *samples, int32_t n)
 Provide the full utterance to an offline ASR stream.
 
void SherpaOnnxOfflineStreamSetOption (const SherpaOnnxOfflineStream *stream, const char *key, const char *value)
 Set a per-stream runtime option for offline ASR.
 
const char * SherpaOnnxOfflineStreamGetOption (const SherpaOnnxOfflineStream *stream, const char *key)
 Get a per-stream runtime option for offline ASR.
 
int32_t SherpaOnnxOfflineStreamHasOption (const SherpaOnnxOfflineStream *stream, const char *key)
 Check whether a per-stream runtime option exists.
 
void SherpaOnnxDecodeOfflineStream (const SherpaOnnxOfflineRecognizer *recognizer, const SherpaOnnxOfflineStream *stream)
 Run offline ASR on one stream.
 
void SherpaOnnxDecodeMultipleOfflineStreams (const SherpaOnnxOfflineRecognizer *recognizer, const SherpaOnnxOfflineStream **streams, int32_t n)
 Run offline ASR on multiple streams in parallel.
 
const SherpaOnnxOfflineRecognizerResultSherpaOnnxGetOfflineStreamResult (const SherpaOnnxOfflineStream *stream)
 Get the recognition result for an offline ASR stream.
 
void SherpaOnnxDestroyOfflineRecognizerResult (const SherpaOnnxOfflineRecognizerResult *r)
 Destroy a result returned by SherpaOnnxGetOfflineStreamResult().
 
const char * SherpaOnnxGetOfflineStreamResultAsJson (const SherpaOnnxOfflineStream *stream)
 Get the offline ASR result as JSON.
 
void SherpaOnnxDestroyOfflineStreamResultJson (const char *s)
 Free a JSON string returned by SherpaOnnxGetOfflineStreamResultAsJson().
 
const SherpaOnnxKeywordSpotterSherpaOnnxCreateKeywordSpotter (const SherpaOnnxKeywordSpotterConfig *config)
 Create a keyword spotter.
 
void SherpaOnnxDestroyKeywordSpotter (const SherpaOnnxKeywordSpotter *spotter)
 Destroy a keyword spotter.
 
const SherpaOnnxOnlineStreamSherpaOnnxCreateKeywordStream (const SherpaOnnxKeywordSpotter *spotter)
 Create a keyword spotting stream using the spotter's built-in keyword list.
 
const SherpaOnnxOnlineStreamSherpaOnnxCreateKeywordStreamWithKeywords (const SherpaOnnxKeywordSpotter *spotter, const char *keywords)
 Create a keyword spotting stream with extra or replacement keywords.
 
int32_t SherpaOnnxIsKeywordStreamReady (const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
 Check whether a keyword stream has enough audio for decoding.
 
void SherpaOnnxDecodeKeywordStream (const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
 Decode one ready keyword stream.
 
void SherpaOnnxResetKeywordStream (const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
 Reset a keyword stream after a keyword is detected.
 
void SherpaOnnxDecodeMultipleKeywordStreams (const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream **streams, int32_t n)
 Decode multiple ready keyword streams in parallel.
 
const SherpaOnnxKeywordResultSherpaOnnxGetKeywordResult (const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
 Get the current keyword spotting result for a stream.
 
void SherpaOnnxDestroyKeywordResult (const SherpaOnnxKeywordResult *r)
 Destroy a keyword result snapshot.
 
const char * SherpaOnnxGetKeywordResultAsJson (const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
 Get the current keyword spotting result as JSON.
 
void SherpaOnnxFreeKeywordResultJson (const char *s)
 Free a JSON string returned by SherpaOnnxGetKeywordResultAsJson().
 
const SherpaOnnxCircularBufferSherpaOnnxCreateCircularBuffer (int32_t capacity)
 Create a floating-point circular buffer.
 
void SherpaOnnxDestroyCircularBuffer (const SherpaOnnxCircularBuffer *buffer)
 Destroy a circular buffer.
 
void SherpaOnnxCircularBufferPush (const SherpaOnnxCircularBuffer *buffer, const float *p, int32_t n)
 Append samples to a circular buffer.
 
const float * SherpaOnnxCircularBufferGet (const SherpaOnnxCircularBuffer *buffer, int32_t start_index, int32_t n)
 Copy out a slice of samples from a circular buffer.
 
void SherpaOnnxCircularBufferFree (const float *p)
 Free an array returned by SherpaOnnxCircularBufferGet().
 
void SherpaOnnxCircularBufferPop (const SherpaOnnxCircularBuffer *buffer, int32_t n)
 Drop samples from the front of a circular buffer.
 
int32_t SherpaOnnxCircularBufferSize (const SherpaOnnxCircularBuffer *buffer)
 Return the number of currently stored samples.
 
int32_t SherpaOnnxCircularBufferHead (const SherpaOnnxCircularBuffer *buffer)
 Return the current head index of the buffer timeline.
 
void SherpaOnnxCircularBufferReset (const SherpaOnnxCircularBuffer *buffer)
 Clear a circular buffer and reset its head index.
 
const SherpaOnnxVoiceActivityDetectorSherpaOnnxCreateVoiceActivityDetector (const SherpaOnnxVadModelConfig *config, float buffer_size_in_seconds)
 Create a voice activity detector.
 
void SherpaOnnxDestroyVoiceActivityDetector (const SherpaOnnxVoiceActivityDetector *p)
 Destroy a voice activity detector.
 
void SherpaOnnxVoiceActivityDetectorAcceptWaveform (const SherpaOnnxVoiceActivityDetector *p, const float *samples, int32_t n)
 Feed audio samples to the VAD.
 
int32_t SherpaOnnxVoiceActivityDetectorEmpty (const SherpaOnnxVoiceActivityDetector *p)
 Check whether the detector currently has any completed speech segment.
 
int32_t SherpaOnnxVoiceActivityDetectorDetected (const SherpaOnnxVoiceActivityDetector *p)
 Check whether the detector is currently inside speech.
 
void SherpaOnnxVoiceActivityDetectorPop (const SherpaOnnxVoiceActivityDetector *p)
 Remove the front speech segment from the detector queue.
 
void SherpaOnnxVoiceActivityDetectorClear (const SherpaOnnxVoiceActivityDetector *p)
 Remove all queued speech segments.
 
const SherpaOnnxSpeechSegmentSherpaOnnxVoiceActivityDetectorFront (const SherpaOnnxVoiceActivityDetector *p)
 Get the first queued speech segment.
 
void SherpaOnnxDestroySpeechSegment (const SherpaOnnxSpeechSegment *p)
 Destroy a speech segment returned by SherpaOnnxVoiceActivityDetectorFront().
 
void SherpaOnnxVoiceActivityDetectorReset (const SherpaOnnxVoiceActivityDetector *p)
 Reset a voice activity detector so it can process a new stream.
 
void SherpaOnnxVoiceActivityDetectorFlush (const SherpaOnnxVoiceActivityDetector *p)
 Flush buffered tail samples and force final segmentation.
 
const SherpaOnnxOfflineTtsSherpaOnnxCreateOfflineTts (const SherpaOnnxOfflineTtsConfig *config)
 Create an offline TTS engine.
 
void SherpaOnnxDestroyOfflineTts (const SherpaOnnxOfflineTts *tts)
 Destroy an offline TTS engine.
 
int32_t SherpaOnnxOfflineTtsSampleRate (const SherpaOnnxOfflineTts *tts)
 Return the output sample rate of a TTS engine.
 
int32_t SherpaOnnxOfflineTtsNumSpeakers (const SherpaOnnxOfflineTts *tts)
 Return the number of available speaker IDs.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerate (const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed)
 Generate speech from text using the simple sid/speed interface.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerateWithCallback (const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed, SherpaOnnxGeneratedAudioCallback callback)
 Generate speech and receive incremental audio chunks through a callback.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerateWithProgressCallback (const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed, SherpaOnnxGeneratedAudioProgressCallback callback)
 Generate speech with a progress callback.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerateWithProgressCallbackWithArg (const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed, SherpaOnnxGeneratedAudioProgressCallbackWithArg callback, void *arg)
 Generate speech with a progress callback that receives a user pointer.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerateWithCallbackWithArg (const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed, SherpaOnnxGeneratedAudioCallbackWithArg callback, void *arg)
 Same as SherpaOnnxOfflineTtsGenerateWithCallback() but with a user pointer.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerateWithZipvoice (const SherpaOnnxOfflineTts *tts, const char *text, const char *prompt_text, const float *prompt_samples, int32_t n_prompt, int32_t prompt_sr, float speed, int32_t num_steps)
 Deprecated ZipVoice-specific generation API.
 
const SherpaOnnxGeneratedAudioSherpaOnnxOfflineTtsGenerateWithConfig (const SherpaOnnxOfflineTts *tts, const char *text, const SherpaOnnxGenerationConfig *config, SherpaOnnxGeneratedAudioProgressCallbackWithArg callback, void *arg)
 Generate speech using the advanced configuration interface.
 
void SherpaOnnxDestroyOfflineTtsGeneratedAudio (const SherpaOnnxGeneratedAudio *p)
 Destroy audio returned by a TTS generation API.
 
int32_t SherpaOnnxWriteWave (const float *samples, int32_t n, int32_t sample_rate, const char *filename)
 Write floating-point PCM to a mono 16-bit WAVE file.
 
int64_t SherpaOnnxWaveFileSize (int32_t n_samples)
 Return the number of bytes needed for a mono 16-bit WAVE file.
 
void SherpaOnnxWriteWaveToBuffer (const float *samples, int32_t n, int32_t sample_rate, char *buffer)
 Write a mono 16-bit WAVE file to a caller-provided buffer.
 
int32_t SherpaOnnxWriteWaveMultiChannel (const float *const *samples, int32_t n, int32_t sample_rate, int32_t num_channels, const char *filename)
 Write multi-channel audio to a WAVE file (16-bit PCM).
 
const SherpaOnnxWaveSherpaOnnxReadWave (const char *filename)
 Read a mono 16-bit PCM WAVE file.
 
const SherpaOnnxWaveSherpaOnnxReadWaveFromBinaryData (const char *data, int32_t n)
 Read a mono 16-bit PCM WAVE file from binary memory.
 
void SherpaOnnxFreeWave (const SherpaOnnxWave *wave)
 Destroy a wave object returned by SherpaOnnxReadWave() or SherpaOnnxReadWaveFromBinaryData().
 
const SherpaOnnxMultiChannelWaveSherpaOnnxReadWaveMultiChannel (const char *filename)
 Read a multi-channel 16-bit PCM WAVE file.
 
void SherpaOnnxFreeMultiChannelWave (const SherpaOnnxMultiChannelWave *wave)
 Destroy a multi-channel wave object.
 
const SherpaOnnxSpokenLanguageIdentificationSherpaOnnxCreateSpokenLanguageIdentification (const SherpaOnnxSpokenLanguageIdentificationConfig *config)
 Create a spoken-language identifier.
 
void SherpaOnnxDestroySpokenLanguageIdentification (const SherpaOnnxSpokenLanguageIdentification *slid)
 Destroy a spoken-language identifier.
 
SherpaOnnxOfflineStreamSherpaOnnxSpokenLanguageIdentificationCreateOfflineStream (const SherpaOnnxSpokenLanguageIdentification *slid)
 Create an offline stream for spoken-language identification.
 
const SherpaOnnxSpokenLanguageIdentificationResultSherpaOnnxSpokenLanguageIdentificationCompute (const SherpaOnnxSpokenLanguageIdentification *slid, const SherpaOnnxOfflineStream *s)
 Run spoken-language identification on an offline stream.
 
void SherpaOnnxDestroySpokenLanguageIdentificationResult (const SherpaOnnxSpokenLanguageIdentificationResult *r)
 Destroy a spoken-language identification result.
 
const SherpaOnnxSpeakerEmbeddingExtractorSherpaOnnxCreateSpeakerEmbeddingExtractor (const SherpaOnnxSpeakerEmbeddingExtractorConfig *config)
 Create a speaker embedding extractor.
 
void SherpaOnnxDestroySpeakerEmbeddingExtractor (const SherpaOnnxSpeakerEmbeddingExtractor *p)
 Destroy a speaker embedding extractor.
 
int32_t SherpaOnnxSpeakerEmbeddingExtractorDim (const SherpaOnnxSpeakerEmbeddingExtractor *p)
 Return the embedding dimension produced by the extractor.
 
const SherpaOnnxOnlineStreamSherpaOnnxSpeakerEmbeddingExtractorCreateStream (const SherpaOnnxSpeakerEmbeddingExtractor *p)
 Create a streaming feature buffer for embedding extraction.
 
int32_t SherpaOnnxSpeakerEmbeddingExtractorIsReady (const SherpaOnnxSpeakerEmbeddingExtractor *p, const SherpaOnnxOnlineStream *s)
 Check whether enough audio has been provided to compute an embedding.
 
const float * SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding (const SherpaOnnxSpeakerEmbeddingExtractor *p, const SherpaOnnxOnlineStream *s)
 Compute the embedding for a stream.
 
void SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding (const float *v)
 Destroy an embedding vector returned by SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding().
 
const SherpaOnnxSpeakerEmbeddingManagerSherpaOnnxCreateSpeakerEmbeddingManager (int32_t dim)
 Create a speaker embedding manager.
 
void SherpaOnnxDestroySpeakerEmbeddingManager (const SherpaOnnxSpeakerEmbeddingManager *p)
 Destroy a speaker embedding manager.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerAdd (const SherpaOnnxSpeakerEmbeddingManager *p, const char *name, const float *v)
 Add one enrollment embedding for a speaker.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerAddList (const SherpaOnnxSpeakerEmbeddingManager *p, const char *name, const float **v)
 Add multiple enrollment embeddings for one speaker.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerAddListFlattened (const SherpaOnnxSpeakerEmbeddingManager *p, const char *name, const float *v, int32_t n)
 Add multiple enrollment embeddings packed in one flat array.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerRemove (const SherpaOnnxSpeakerEmbeddingManager *p, const char *name)
 Remove a speaker from the manager.
 
const char * SherpaOnnxSpeakerEmbeddingManagerSearch (const SherpaOnnxSpeakerEmbeddingManager *p, const float *v, float threshold)
 Search for the best matching enrolled speaker.
 
void SherpaOnnxSpeakerEmbeddingManagerFreeSearch (const char *name)
 Free a string returned by SherpaOnnxSpeakerEmbeddingManagerSearch().
 
const SherpaOnnxSpeakerEmbeddingManagerBestMatchesResultSherpaOnnxSpeakerEmbeddingManagerGetBestMatches (const SherpaOnnxSpeakerEmbeddingManager *p, const float *v, float threshold, int32_t n)
 Return up to n best matches above a similarity threshold.
 
void SherpaOnnxSpeakerEmbeddingManagerFreeBestMatches (const SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult *r)
 Destroy a best-matches result.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerVerify (const SherpaOnnxSpeakerEmbeddingManager *p, const char *name, const float *v, float threshold)
 Verify whether a query embedding matches a named speaker.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerContains (const SherpaOnnxSpeakerEmbeddingManager *p, const char *name)
 Check whether a speaker is enrolled.
 
int32_t SherpaOnnxSpeakerEmbeddingManagerNumSpeakers (const SherpaOnnxSpeakerEmbeddingManager *p)
 Return the number of enrolled speakers.
 
const char *const * SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers (const SherpaOnnxSpeakerEmbeddingManager *p)
 Return all enrolled speaker names.
 
void SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers (const char *const *names)
 Free an array returned by SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers().
 
const SherpaOnnxAudioTaggingSherpaOnnxCreateAudioTagging (const SherpaOnnxAudioTaggingConfig *config)
 Create an audio tagger.
 
void SherpaOnnxDestroyAudioTagging (const SherpaOnnxAudioTagging *tagger)
 Destroy an audio tagger.
 
const SherpaOnnxOfflineStreamSherpaOnnxAudioTaggingCreateOfflineStream (const SherpaOnnxAudioTagging *tagger)
 Create an offline stream for audio tagging.
 
const SherpaOnnxAudioEvent *const * SherpaOnnxAudioTaggingCompute (const SherpaOnnxAudioTagging *tagger, const SherpaOnnxOfflineStream *s, int32_t top_k)
 Run audio tagging on an offline stream.
 
void SherpaOnnxAudioTaggingFreeResults (const SherpaOnnxAudioEvent *const *p)
 Destroy results returned by SherpaOnnxAudioTaggingCompute().
 
const SherpaOnnxOfflinePunctuationSherpaOnnxCreateOfflinePunctuation (const SherpaOnnxOfflinePunctuationConfig *config)
 Create an offline punctuation processor.
 
void SherpaOnnxDestroyOfflinePunctuation (const SherpaOnnxOfflinePunctuation *punct)
 Destroy an offline punctuation processor.
 
const char * SherpaOfflinePunctuationAddPunct (const SherpaOnnxOfflinePunctuation *punct, const char *text)
 Add punctuation to a complete input text.
 
void SherpaOfflinePunctuationFreeText (const char *text)
 Free a string returned by SherpaOfflinePunctuationAddPunct().
 
const SherpaOnnxOnlinePunctuationSherpaOnnxCreateOnlinePunctuation (const SherpaOnnxOnlinePunctuationConfig *config)
 Create an online punctuation processor.
 
void SherpaOnnxDestroyOnlinePunctuation (const SherpaOnnxOnlinePunctuation *punctuation)
 Destroy an online punctuation processor.
 
const char * SherpaOnnxOnlinePunctuationAddPunct (const SherpaOnnxOnlinePunctuation *punctuation, const char *text)
 Add punctuation to one text chunk using the online punctuation model.
 
void SherpaOnnxOnlinePunctuationFreeText (const char *text)
 Free a string returned by SherpaOnnxOnlinePunctuationAddPunct().
 
const SherpaOnnxLinearResamplerSherpaOnnxCreateLinearResampler (int32_t samp_rate_in_hz, int32_t samp_rate_out_hz, float filter_cutoff_hz, int32_t num_zeros)
 Create a linear resampler.
 
void SherpaOnnxDestroyLinearResampler (const SherpaOnnxLinearResampler *p)
 Destroy a linear resampler.
 
void SherpaOnnxLinearResamplerReset (const SherpaOnnxLinearResampler *p)
 Reset a linear resampler to its initial state.
 
const SherpaOnnxResampleOutSherpaOnnxLinearResamplerResample (const SherpaOnnxLinearResampler *p, const float *input, int32_t input_dim, int32_t flush)
 Resample one chunk of input audio.
 
void SherpaOnnxLinearResamplerResampleFree (const SherpaOnnxResampleOut *p)
 Destroy a resampler output chunk.
 
int32_t SherpaOnnxLinearResamplerResampleGetInputSampleRate (const SherpaOnnxLinearResampler *p)
 Return the resampler input sample rate.
 
int32_t SherpaOnnxLinearResamplerResampleGetOutputSampleRate (const SherpaOnnxLinearResampler *p)
 Return the resampler output sample rate.
 
const SherpaOnnxOfflineSpeakerDiarizationSherpaOnnxCreateOfflineSpeakerDiarization (const SherpaOnnxOfflineSpeakerDiarizationConfig *config)
 Create an offline speaker diarization pipeline.
 
void SherpaOnnxDestroyOfflineSpeakerDiarization (const SherpaOnnxOfflineSpeakerDiarization *sd)
 Destroy an offline speaker diarizer.
 
int32_t SherpaOnnxOfflineSpeakerDiarizationGetSampleRate (const SherpaOnnxOfflineSpeakerDiarization *sd)
 Return the expected input sample rate.
 
void SherpaOnnxOfflineSpeakerDiarizationSetConfig (const SherpaOnnxOfflineSpeakerDiarization *sd, const SherpaOnnxOfflineSpeakerDiarizationConfig *config)
 Update clustering-related settings of an existing diarizer.
 
int32_t SherpaOnnxOfflineSpeakerDiarizationResultGetNumSpeakers (const SherpaOnnxOfflineSpeakerDiarizationResult *r)
 Return the number of speakers in a diarization result.
 
int32_t SherpaOnnxOfflineSpeakerDiarizationResultGetNumSegments (const SherpaOnnxOfflineSpeakerDiarizationResult *r)
 Return the number of diarization segments.
 
const SherpaOnnxOfflineSpeakerDiarizationSegmentSherpaOnnxOfflineSpeakerDiarizationResultSortByStartTime (const SherpaOnnxOfflineSpeakerDiarizationResult *r)
 Return segments sorted by start time.
 
void SherpaOnnxOfflineSpeakerDiarizationDestroySegment (const SherpaOnnxOfflineSpeakerDiarizationSegment *s)
 Destroy a segment array returned by SherpaOnnxOfflineSpeakerDiarizationResultSortByStartTime().
 
const SherpaOnnxOfflineSpeakerDiarizationResultSherpaOnnxOfflineSpeakerDiarizationProcess (const SherpaOnnxOfflineSpeakerDiarization *sd, const float *samples, int32_t n)
 Run offline speaker diarization.
 
const SherpaOnnxOfflineSpeakerDiarizationResultSherpaOnnxOfflineSpeakerDiarizationProcessWithCallback (const SherpaOnnxOfflineSpeakerDiarization *sd, const float *samples, int32_t n, SherpaOnnxOfflineSpeakerDiarizationProgressCallback callback, void *arg)
 Run offline speaker diarization with a progress callback.
 
const SherpaOnnxOfflineSpeakerDiarizationResultSherpaOnnxOfflineSpeakerDiarizationProcessWithCallbackNoArg (const SherpaOnnxOfflineSpeakerDiarization *sd, const float *samples, int32_t n, SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg callback)
 Run offline speaker diarization with a progress callback that has no user pointer.
 
void SherpaOnnxOfflineSpeakerDiarizationDestroyResult (const SherpaOnnxOfflineSpeakerDiarizationResult *r)
 Destroy a diarization result.
 
const SherpaOnnxOfflineSpeechDenoiserSherpaOnnxCreateOfflineSpeechDenoiser (const SherpaOnnxOfflineSpeechDenoiserConfig *config)
 Create an offline speech denoiser.
 
void SherpaOnnxDestroyOfflineSpeechDenoiser (const SherpaOnnxOfflineSpeechDenoiser *sd)
 Destroy an offline speech denoiser.
 
int32_t SherpaOnnxOfflineSpeechDenoiserGetSampleRate (const SherpaOnnxOfflineSpeechDenoiser *sd)
 Return the expected sample rate for the denoiser.
 
const SherpaOnnxDenoisedAudioSherpaOnnxOfflineSpeechDenoiserRun (const SherpaOnnxOfflineSpeechDenoiser *sd, const float *samples, int32_t n, int32_t sample_rate)
 Run offline speech denoising on a complete waveform.
 
void SherpaOnnxDestroyDenoisedAudio (const SherpaOnnxDenoisedAudio *p)
 Destroy denoised audio returned by a speech enhancement API.
 
const SherpaOnnxOnlineSpeechDenoiserSherpaOnnxCreateOnlineSpeechDenoiser (const SherpaOnnxOnlineSpeechDenoiserConfig *config)
 Create an online speech denoiser.
 
void SherpaOnnxDestroyOnlineSpeechDenoiser (const SherpaOnnxOnlineSpeechDenoiser *sd)
 Destroy an online speech denoiser.
 
int32_t SherpaOnnxOnlineSpeechDenoiserGetSampleRate (const SherpaOnnxOnlineSpeechDenoiser *sd)
 Return the expected input sample rate for the online denoiser.
 
int32_t SherpaOnnxOnlineSpeechDenoiserGetFrameShiftInSamples (const SherpaOnnxOnlineSpeechDenoiser *sd)
 Return the recommended chunk size in samples for streaming input.
 
const SherpaOnnxDenoisedAudioSherpaOnnxOnlineSpeechDenoiserRun (const SherpaOnnxOnlineSpeechDenoiser *sd, const float *samples, int32_t n, int32_t sample_rate)
 Process one chunk of streaming audio.
 
const SherpaOnnxDenoisedAudioSherpaOnnxOnlineSpeechDenoiserFlush (const SherpaOnnxOnlineSpeechDenoiser *sd)
 Flush buffered samples and reset the online denoiser.
 
void SherpaOnnxOnlineSpeechDenoiserReset (const SherpaOnnxOnlineSpeechDenoiser *sd)
 Reset an online denoiser so it can process a new stream.
 
const SherpaOnnxOfflineSourceSeparationSherpaOnnxCreateOfflineSourceSeparation (const SherpaOnnxOfflineSourceSeparationConfig *config)
 Create a source-separation engine.
 
void SherpaOnnxDestroyOfflineSourceSeparation (const SherpaOnnxOfflineSourceSeparation *ss)
 Destroy a source-separation engine.
 
int32_t SherpaOnnxOfflineSourceSeparationGetOutputSampleRate (const SherpaOnnxOfflineSourceSeparation *ss)
 Return the output sample rate of the source-separation engine.
 
int32_t SherpaOnnxOfflineSourceSeparationGetNumberOfStems (const SherpaOnnxOfflineSourceSeparation *ss)
 Return the number of stems produced by the engine.
 
const SherpaOnnxSourceSeparationOutputSherpaOnnxOfflineSourceSeparationProcess (const SherpaOnnxOfflineSourceSeparation *ss, const float *const *samples, int32_t num_channels, int32_t num_samples, int32_t sample_rate)
 Run source separation on multi-channel audio.
 
void SherpaOnnxDestroySourceSeparationOutput (const SherpaOnnxSourceSeparationOutput *p)
 Destroy the output of a source-separation run.
 

Detailed Description

This header exposes the main sherpa-onnx inference features through a stable C interface. It is intended for native C/C++ applications and for language bindings that need a C ABI.

The file is organized by feature family. The major API groups are:

  • Utility helpers: version/build information, file checks, WAVE I/O, and a display helper for incremental text output
  • Streaming ASR: online recognizers, online streams, endpointing, and per-stream runtime options
  • Non-streaming ASR: offline recognizers, offline streams, batch decode, and result retrieval
  • Keyword spotting: streaming keyword detection, custom keyword streams, and keyword result snapshots
  • Voice activity detection: Silero/Ten VAD models, speech segment buffers, and detector state management
  • Text-to-speech: offline TTS model families, generation configuration, and generated audio helpers
  • Spoken language identification
  • Speaker embedding extraction and speaker enrollment/search/verification
  • Audio tagging
  • Offline and online punctuation restoration
  • Linear resampling
  • Offline speaker diarization
  • Offline and online speech enhancement / denoising
  • HarmonyOS-specific constructor variants

Common ownership rules:

  • Opaque handles created by SherpaOnnxCreate*() functions are generally destroyed with a matching SherpaOnnxDestroy*() function
  • Snapshot/result objects returned by query functions usually need explicit destruction as documented on each API
  • Strings or arrays returned by helper/query functions are either:
    • statically owned by the library and must not be freed, or
    • heap-allocated for the caller and must be released with the matching Free/Destroy API

General usage pattern:

  1. Zero-initialize a config struct with memset(&config, 0, sizeof(config))
  2. Fill in the required model paths and runtime options
  3. Create the corresponding engine with SherpaOnnxCreate*()
  4. Create a stream if the feature uses one
  5. Feed audio or text, run the compute/decode API, and retrieve results
  6. Release every returned object with the documented matching API

The examples in c-api-examples/ show complete end-to-end usage. Useful starting points include:

  • decode-file-c-api.c for ASR
  • kws-c-api.c for keyword spotting
  • vad-whisper-c-api.c for VAD
  • offline-tts-c-api.c and kokoro-tts-en-c-api.c for TTS
  • speaker-identification-c-api.c for speaker embedding and verification
  • audio-tagging-c-api.c for audio tagging
  • add-punctuation-c-api.c and add-punctuation-online-c-api.c for punctuation
  • offline-sepaker-diarization-c-api.c for diarization
  • speech-enhancement-gtcrn-c-api.c and online-speech-enhancement-gtcrn-c-api.c for speech enhancement

Definition in file c-api.h.

Macro Definition Documentation

◆ SHERPA_ONNX_API

#define SHERPA_ONNX_API   SHERPA_ONNX_IMPORT

Definition at line 106 of file c-api.h.

◆ SHERPA_ONNX_EXPORT

#define SHERPA_ONNX_EXPORT   __attribute__((visibility("default")))

Definition at line 98 of file c-api.h.

◆ SHERPA_ONNX_IMPORT

#define SHERPA_ONNX_IMPORT   SHERPA_ONNX_EXPORT

Definition at line 100 of file c-api.h.

Typedef Documentation

◆ SherpaOnnxAudioEvent

◆ SherpaOnnxAudioTagging

Definition at line 3438 of file c-api.h.

◆ SherpaOnnxAudioTaggingConfig

memset(&config, 0, sizeof(config));
"./sherpa-onnx-zipformer-audio-tagging-2024-04-09/model.int8.onnx";
config.model.num_threads = 1;
config.model.provider = "cpu";
config.labels =
"./sherpa-onnx-zipformer-audio-tagging-2024-04-09/class_labels_indices.csv";
config.top_k = 5;
Configuration for audio tagging.
Definition c-api.h:3415
SherpaOnnxAudioTaggingModelConfig model
Definition c-api.h:3417
SherpaOnnxOfflineZipformerAudioTaggingModelConfig zipformer
Definition c-api.h:3389

◆ SherpaOnnxAudioTaggingModelConfig

Configure exactly one model family. If multiple model families are provided, one of them will be used and the choice is implementation-defined.

Example using sherpa-onnx-zipformer-audio-tagging-2024-04-09:

memset(&model, 0, sizeof(model));
"./sherpa-onnx-zipformer-audio-tagging-2024-04-09/model.int8.onnx";
model.num_threads = 1;
model.provider = "cpu";
Audio-tagging model configuration.
Definition c-api.h:3387

◆ SherpaOnnxCircularBuffer

Definition at line 1936 of file c-api.h.

◆ SherpaOnnxDenoisedAudio

◆ SherpaOnnxDisplay

This utility is mainly used by example programs on Linux and macOS.

Definition at line 778 of file c-api.h.

◆ SherpaOnnxFastClusteringConfig

If num_clusters is greater than 0, threshold is ignored. When the number of speakers is known in advance, setting num_clusters is strongly recommended.

◆ SherpaOnnxFeatureConfig

The bundled ASR models typically expect 16 kHz mono audio and 80-bin features.

◆ SherpaOnnxGeneratedAudio

The returned structure owns samples. Free the whole object with SherpaOnnxDestroyOfflineTtsGeneratedAudio().

◆ SherpaOnnxGeneratedAudioCallback

typedef int32_t(* SherpaOnnxGeneratedAudioCallback) (const float *samples, int32_t n)

Return 1 to continue generation. Return 0 to stop early.

The samples pointer is only valid during the callback. Copy the samples if you need to keep them after the callback returns.

Definition at line 2443 of file c-api.h.

◆ SherpaOnnxGeneratedAudioCallbackWithArg

typedef int32_t(* SherpaOnnxGeneratedAudioCallbackWithArg) (const float *samples, int32_t n, void *arg)

Definition at line 2450 of file c-api.h.

◆ SherpaOnnxGeneratedAudioProgressCallback

typedef int32_t(* SherpaOnnxGeneratedAudioProgressCallback) (const float *samples, int32_t n, float p)
Parameters
samplesNewly generated samples valid only during the callback.
nNumber of samples in samples.
pProgress in the range [0, 1].
Returns
Return 1 to continue generation. Return 0 to stop early.

Definition at line 2462 of file c-api.h.

◆ SherpaOnnxGeneratedAudioProgressCallbackWithArg

typedef int32_t(* SherpaOnnxGeneratedAudioProgressCallbackWithArg) (const float *samples, int32_t n, float p, void *arg)

Definition at line 2469 of file c-api.h.

◆ SherpaOnnxGenerationConfig

This struct supports both simple multi-speaker synthesis and more advanced zero-shot or reference-conditioned models.

Example for Pocket TTS:

memset(&cfg, 0, sizeof(cfg));
cfg.speed = 1.0f;
cfg.reference_audio = wave->samples;
cfg.reference_audio_len = wave->num_samples;
cfg.reference_sample_rate = wave->sample_rate;
cfg.extra = "{\"max_reference_audio_len\": 10.0, \"seed\": 42}";
Generation-time parameters shared by advanced TTS APIs.
Definition c-api.h:2679
const float * reference_audio
Definition c-api.h:2687

◆ SherpaOnnxHomophoneReplacerConfig

◆ SherpaOnnxKeywordResult

◆ SherpaOnnxKeywordSpotter

Definition at line 1685 of file c-api.h.

◆ SherpaOnnxKeywordSpotterConfig

The acoustic model is configured through model_config. In practice this is usually a streaming transducer model.

Keyword definitions can be provided either through keywords_file or through keywords_buf/keywords_buf_size. If both are set, the buffer is used.

Example using sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile:

memset(&config, 0, sizeof(config));
"./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile/"
"encoder-epoch-12-avg-2-chunk-16-left-64.int8.onnx";
"./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile/"
"decoder-epoch-12-avg-2-chunk-16-left-64.onnx";
"./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile/"
"joiner-epoch-12-avg-2-chunk-16-left-64.int8.onnx";
"./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile/"
"tokens.txt";
config.model_config.provider = "cpu";
config.keywords_file =
"./sherpa-onnx-kws-zipformer-wenetspeech-3.3M-2024-01-01-mobile/"
"test_wavs/test_keywords.txt";
config.max_active_paths = 4;
config.keywords_score = 3.0f;
config.keywords_threshold = 0.1f;
Configuration for keyword spotting.
Definition c-api.h:1662
SherpaOnnxOnlineModelConfig model_config
Definition c-api.h:1666
const char * provider
Definition c-api.h:244
SherpaOnnxOnlineTransducerModelConfig transducer
Definition c-api.h:234

◆ SherpaOnnxLinearResampler

Definition at line 3662 of file c-api.h.

◆ SherpaOnnxMultiChannelWave

◆ SherpaOnnxOfflineCanaryModelConfig

◆ SherpaOnnxOfflineCohereTranscribeModelConfig

◆ SherpaOnnxOfflineDolphinModelConfig

◆ SherpaOnnxOfflineFireRedAsrCtcModelConfig

◆ SherpaOnnxOfflineFireRedAsrModelConfig

◆ SherpaOnnxOfflineFunASRNanoModelConfig

◆ SherpaOnnxOfflineLMConfig

◆ SherpaOnnxOfflineMedAsrCtcModelConfig

◆ SherpaOnnxOfflineModelConfig

Zero-initialize this struct before use, then fill in exactly the sub-config needed by the model family you want to run.

Exactly one model family should be configured for each recognizer. For example, set only one of transducer, paraformer, nemo_ctc, whisper, tdnn, sense_voice, moonshine, fire_red_asr, dolphin, zipformer_ctc, canary, cohere_transcribe, wenet_ctc, omnilingual, medasr, funasr_nano, fire_red_asr_ctc, or qwen3_asr.

If multiple model families are configured at the same time, the implementation will choose one of them, and which one is used is implementation-defined. Do not rely on any precedence rule.

◆ SherpaOnnxOfflineMoonshineModelConfig

◆ SherpaOnnxOfflineNemoEncDecCtcModelConfig

◆ SherpaOnnxOfflineOmnilingualAsrCtcModelConfig

◆ SherpaOnnxOfflineParaformerModelConfig

◆ SherpaOnnxOfflinePunctuation

Definition at line 3540 of file c-api.h.

◆ SherpaOnnxOfflinePunctuationConfig

◆ SherpaOnnxOfflinePunctuationModelConfig

Example:

memset(&model, 0, sizeof(model));
"./sherpa-onnx-punct-ct-transformer-zh-en-vocab272727-2024-04-12/model.onnx";
model.num_threads = 1;
model.provider = "cpu";
Offline punctuation model configuration.
Definition c-api.h:3522

◆ SherpaOnnxOfflineQwen3ASRModelConfig

◆ SherpaOnnxOfflineRecognizer

Definition at line 1185 of file c-api.h.

◆ SherpaOnnxOfflineRecognizerConfig

Zero-initialize this struct before use.

Example using Whisper:

memset(&config, 0, sizeof(config));
config.feat_config.sample_rate = 16000;
"./sherpa-onnx-whisper-tiny/tiny-encoder.onnx";
"./sherpa-onnx-whisper-tiny/tiny-decoder.onnx";
config.model_config.whisper.task = "transcribe";
"./sherpa-onnx-whisper-tiny/tiny-tokens.txt";
config.model_config.provider = "cpu";
config.decoding_method = "greedy_search";
SherpaOnnxOfflineWhisperModelConfig whisper
Definition c-api.h:1054
Configuration for a non-streaming ASR recognizer.
Definition c-api.h:1155
SherpaOnnxOfflineModelConfig model_config
Definition c-api.h:1159
SherpaOnnxFeatureConfig feat_config
Definition c-api.h:1157

Example using SenseVoice:

"./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17-int8/model.int8.onnx";
"./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17-int8/tokens.txt";
SherpaOnnxOfflineSenseVoiceModelConfig sense_voice
Definition c-api.h:1075

Example using Parakeet TDT:

"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/encoder.int8.onnx";
"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/decoder.int8.onnx";
"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/joiner.int8.onnx";
"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/tokens.txt";
config.model_config.model_type = "nemo_transducer";
SherpaOnnxOfflineTransducerModelConfig transducer
Definition c-api.h:1048

◆ SherpaOnnxOfflineRecognizerResult

All pointers in this struct are owned by the result object returned from SherpaOnnxGetOfflineStreamResult() and become invalid after SherpaOnnxDestroyOfflineRecognizerResult() is called.

◆ SherpaOnnxOfflineSenseVoiceModelConfig

◆ SherpaOnnxOfflineSourceSeparation

◆ SherpaOnnxOfflineSourceSeparationConfig

◆ SherpaOnnxOfflineSourceSeparationModelConfig

◆ SherpaOnnxOfflineSourceSeparationSpleeterModelConfig

◆ SherpaOnnxOfflineSourceSeparationUvrModelConfig

◆ SherpaOnnxOfflineSpeakerDiarization

◆ SherpaOnnxOfflineSpeakerDiarizationConfig

Example based on offline-sepaker-diarization-c-api.c:

memset(&config, 0, sizeof(config));
"./sherpa-onnx-pyannote-segmentation-3-0/model.onnx";
config.embedding.model =
"./3dspeaker_speech_eres2net_base_sv_zh-cn_3dspeaker_16k.onnx";
Configuration for offline speaker diarization.
Definition c-api.h:3814
SherpaOnnxFastClusteringConfig clustering
Definition c-api.h:3820
SherpaOnnxSpeakerEmbeddingExtractorConfig embedding
Definition c-api.h:3818
SherpaOnnxOfflineSpeakerSegmentationModelConfig segmentation
Definition c-api.h:3816
SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig pyannote
Definition c-api.h:3775

◆ SherpaOnnxOfflineSpeakerDiarizationProgressCallback

typedef int32_t(* SherpaOnnxOfflineSpeakerDiarizationProgressCallback) (int32_t num_processed_chunks, int32_t num_total_chunks, void *arg)

The current implementation reports progress but ignores the callback's return value.

Definition at line 3938 of file c-api.h.

◆ SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg

typedef int32_t(* SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg) (int32_t num_processed_chunks, int32_t num_total_chunks)

Definition at line 3945 of file c-api.h.

◆ SherpaOnnxOfflineSpeakerDiarizationResult

◆ SherpaOnnxOfflineSpeakerDiarizationSegment

◆ SherpaOnnxOfflineSpeakerSegmentationModelConfig

Configure exactly one model family. If multiple model families are provided, one is chosen and the choice is implementation-defined.

◆ SherpaOnnxOfflineSpeakerSegmentationPyannoteModelConfig

◆ SherpaOnnxOfflineSpeechDenoiser

◆ SherpaOnnxOfflineSpeechDenoiserConfig

◆ SherpaOnnxOfflineSpeechDenoiserDpdfNetModelConfig

◆ SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig

◆ SherpaOnnxOfflineSpeechDenoiserModelConfig

Configure exactly one model family. If multiple model families are provided, one is chosen and the choice is implementation-defined.

◆ SherpaOnnxOfflineStream

Definition at line 1188 of file c-api.h.

◆ SherpaOnnxOfflineTdnnModelConfig

◆ SherpaOnnxOfflineTransducerModelConfig

◆ SherpaOnnxOfflineTts

Definition at line 2473 of file c-api.h.

◆ SherpaOnnxOfflineTtsConfig

memset(&config, 0, sizeof(config));
config.model.kokoro.model = "./kokoro-en-v0_19/model.onnx";
config.model.kokoro.voices = "./kokoro-en-v0_19/voices.bin";
config.model.kokoro.tokens = "./kokoro-en-v0_19/tokens.txt";
config.model.kokoro.data_dir = "./kokoro-en-v0_19/espeak-ng-data";
config.model.num_threads = 2;
config.model.provider = "cpu";
config.model.debug = 0;
config.max_num_sentences = 2;
Configuration for offline text-to-speech.
Definition c-api.h:2407
SherpaOnnxOfflineTtsModelConfig model
Definition c-api.h:2409
SherpaOnnxOfflineTtsKokoroModelConfig kokoro
Definition c-api.h:2379

◆ SherpaOnnxOfflineTtsKittenModelConfig

◆ SherpaOnnxOfflineTtsKokoroModelConfig

◆ SherpaOnnxOfflineTtsMatchaModelConfig

◆ SherpaOnnxOfflineTtsModelConfig

Exactly one TTS model family should be configured. For example, set only one of vits, matcha, kokoro, kitten, zipvoice, pocket, or supertonic.

If multiple model families are configured at the same time, the implementation will choose one of them, and which one is used is implementation-defined. Do not rely on any precedence rule.

Concrete example model packages in this repository include:

  • kokoro-en-v0_19
  • sherpa-onnx-pocket-tts-int8-2026-01-26
  • matcha-icefall-en_US-ljspeech
  • sherpa-onnx-zipvoice-distill-int8-zh-en-emilia

◆ SherpaOnnxOfflineTtsPocketModelConfig

◆ SherpaOnnxOfflineTtsSupertonicModelConfig

◆ SherpaOnnxOfflineTtsVitsModelConfig

◆ SherpaOnnxOfflineTtsZipvoiceModelConfig

◆ SherpaOnnxOfflineWenetCtcModelConfig

◆ SherpaOnnxOfflineWhisperModelConfig

◆ SherpaOnnxOfflineZipformerAudioTaggingModelConfig

◆ SherpaOnnxOfflineZipformerCtcModelConfig

◆ SherpaOnnxOnlineCtcFstDecoderConfig

◆ SherpaOnnxOnlineModelConfig

Zero-initialize this struct before use, then fill in the sub-config for the model family you want to use together with the shared fields such as tokens, provider, and num_threads.

Exactly one model family should be configured for each recognizer. For example, set only one of transducer, paraformer, zipformer2_ctc, nemo_ctc, or t_one_ctc.

If multiple model families are configured at the same time, the implementation will choose one of them, and which one is used is implementation-defined. Do not rely on any precedence rule.

◆ SherpaOnnxOnlineNemoCtcModelConfig

◆ SherpaOnnxOnlineParaformerModelConfig

◆ SherpaOnnxOnlinePunctuation

Definition at line 3613 of file c-api.h.

◆ SherpaOnnxOnlinePunctuationConfig

◆ SherpaOnnxOnlinePunctuationModelConfig

Example using sherpa-onnx-online-punct-en-2024-08-06:

memset(&model, 0, sizeof(model));
model.cnn_bilstm =
"./sherpa-onnx-online-punct-en-2024-08-06/model.int8.onnx"; model.bpe_vocab =
"./sherpa-onnx-online-punct-en-2024-08-06/bpe.vocab"; model.num_threads = 1;
model.provider = "cpu";
Online punctuation model configuration.
Definition c-api.h:3593

◆ SherpaOnnxOnlineRecognizer

Definition at line 422 of file c-api.h.

◆ SherpaOnnxOnlineRecognizerConfig

Zero-initialize this struct before use. Then fill in feat_config, model_config, and any optional decoding, endpoint, or hotword settings.

Example model package: sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20

memset(&config, 0, sizeof(config));
config.feat_config.sample_rate = 16000;
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"encoder-epoch-99-avg-1.int8.onnx";
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"decoder-epoch-99-avg-1.onnx";
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"joiner-epoch-99-avg-1.int8.onnx";
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"tokens.txt";
config.model_config.provider = "cpu";
config.decoding_method = "greedy_search";
Configuration for a streaming ASR recognizer.
Definition c-api.h:337
SherpaOnnxOnlineModelConfig model_config
Definition c-api.h:341
SherpaOnnxFeatureConfig feat_config
Definition c-api.h:339

◆ SherpaOnnxOnlineRecognizerResult

All pointers in this struct are owned by the result object returned from SherpaOnnxGetOnlineStreamResult() and become invalid after SherpaOnnxDestroyOnlineRecognizerResult() is called.

◆ SherpaOnnxOnlineSpeechDenoiser

Definition at line 4149 of file c-api.h.

◆ SherpaOnnxOnlineSpeechDenoiserConfig

◆ SherpaOnnxOnlineStream

Definition at line 424 of file c-api.h.

◆ SherpaOnnxOnlineToneCtcModelConfig

◆ SherpaOnnxOnlineTransducerModelConfig

◆ SherpaOnnxOnlineZipformer2CtcModelConfig

◆ SherpaOnnxResampleOut

◆ SherpaOnnxSileroVadModelConfig

◆ SherpaOnnxSourceSeparationOutput

◆ SherpaOnnxSourceSeparationStem

◆ SherpaOnnxSpeakerEmbeddingExtractor

◆ SherpaOnnxSpeakerEmbeddingExtractorConfig

Example using 3dspeaker_speech_campplus_sv_zh-cn_16k-common.onnx:

memset(&config, 0, sizeof(config));
config.model = "./3dspeaker_speech_campplus_sv_zh-cn_16k-common.onnx";
config.num_threads = 1;
config.provider = "cpu";
Configuration for speaker embedding extraction.
Definition c-api.h:3041

◆ SherpaOnnxSpeakerEmbeddingManager

◆ SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult

◆ SherpaOnnxSpeakerEmbeddingManagerSpeakerMatch

◆ SherpaOnnxSpeechSegment

The segment owns samples. Free the whole object with SherpaOnnxDestroySpeechSegment().

◆ SherpaOnnxSpokenLanguageIdentification

◆ SherpaOnnxSpokenLanguageIdentificationConfig

The current implementation uses Whisper-based models.

Example using sherpa-onnx-whisper-tiny:

memset(&config, 0, sizeof(config));
config.whisper.encoder = "./sherpa-onnx-whisper-tiny/tiny-encoder.int8.onnx";
config.whisper.decoder = "./sherpa-onnx-whisper-tiny/tiny-decoder.int8.onnx";
config.num_threads = 1;
config.provider = "cpu";
Configuration for spoken language identification.
Definition c-api.h:2924
SherpaOnnxSpokenLanguageIdentificationWhisperConfig whisper
Definition c-api.h:2926

◆ SherpaOnnxSpokenLanguageIdentificationResult

◆ SherpaOnnxSpokenLanguageIdentificationWhisperConfig

Example:

memset(&whisper, 0, sizeof(whisper));
whisper.encoder = "./sherpa-onnx-whisper-tiny/tiny-encoder.int8.onnx";
whisper.decoder = "./sherpa-onnx-whisper-tiny/tiny-decoder.int8.onnx";
Whisper-based model files for spoken language identification.
Definition c-api.h:2899

◆ SherpaOnnxTenVadModelConfig

◆ SherpaOnnxVadModelConfig

Exactly one VAD model family should be configured. Set either silero_vad.model or ten_vad.model.

If both are configured, the implementation will choose one of them, and which one is used is implementation-defined. Do not rely on any precedence rule.

Example model files:

  • ./silero_vad.onnx
  • ./ten-vad.onnx
memset(&config, 0, sizeof(config));
config.silero_vad.model = "./silero_vad.onnx";
config.silero_vad.threshold = 0.25f;
config.silero_vad.window_size = 512;
config.sample_rate = 16000;
config.num_threads = 1;
config.provider = "cpu";
config.debug = 0;
Configuration shared by voice activity detectors.
Definition c-api.h:1920
SherpaOnnxSileroVadModelConfig silero_vad
Definition c-api.h:1922
const char * provider
Definition c-api.h:1928

◆ SherpaOnnxVoiceActivityDetector

◆ SherpaOnnxWave

Free this object with SherpaOnnxFreeWave().

Function Documentation

◆ SherpaOfflinePunctuationAddPunct()

const char * SherpaOfflinePunctuationAddPunct ( const SherpaOnnxOfflinePunctuation punct,
const char *  text 
)
Parameters
punctA pointer returned by SherpaOnnxCreateOfflinePunctuation().
textInput text without punctuation.
Returns
A newly allocated punctuated string. Free it with SherpaOfflinePunctuationFreeText().

◆ SherpaOfflinePunctuationFreeText()

void SherpaOfflinePunctuationFreeText ( const char *  text)
Parameters
textA pointer returned by SherpaOfflinePunctuationAddPunct().

◆ SherpaOnnxAcceptWaveformOffline()

void SherpaOnnxAcceptWaveformOffline ( const SherpaOnnxOfflineStream stream,
int32_t  sample_rate,
const float *  samples,
int32_t  n 
)

The input is mono floating-point PCM normalized to the range [-1, 1]. If sample_rate differs from the recognizer feature sample rate, sherpa-onnx resamples internally.

Warning
Call this function at most once for each offline stream. Offline recognition expects the entire utterance in a single call.
Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream().
sample_rateSample rate of samples.
samplesPointer to n samples in the range [-1, 1].
nNumber of samples.
const SherpaOnnxWave *wave =
SherpaOnnxReadWave("./sherpa-onnx-whisper-tiny.en/test_wavs/0.wav");
const SherpaOnnxOfflineStream *stream =
wave->samples, wave->num_samples);
SherpaOnnxDecodeOfflineStream(recognizer, stream);
const SherpaOnnxWave * SherpaOnnxReadWave(const char *filename)
Read a mono 16-bit PCM WAVE file.
void SherpaOnnxDecodeOfflineStream(const SherpaOnnxOfflineRecognizer *recognizer, const SherpaOnnxOfflineStream *stream)
Run offline ASR on one stream.
struct SherpaOnnxOfflineStream SherpaOnnxOfflineStream
Non-streaming decoding state for one utterance.
Definition c-api.h:1188
void SherpaOnnxAcceptWaveformOffline(const SherpaOnnxOfflineStream *stream, int32_t sample_rate, const float *samples, int32_t n)
Provide the full utterance to an offline ASR stream.
const SherpaOnnxOfflineStream * SherpaOnnxCreateOfflineStream(const SherpaOnnxOfflineRecognizer *recognizer)
Create a non-streaming ASR input stream.
Decoded mono WAVE file content.
Definition c-api.h:2802
int32_t num_samples
Definition c-api.h:2808
const float * samples
Definition c-api.h:2804
int32_t sample_rate
Definition c-api.h:2806

◆ SherpaOnnxAudioTaggingCompute()

const SherpaOnnxAudioEvent *const * SherpaOnnxAudioTaggingCompute ( const SherpaOnnxAudioTagging tagger,
const SherpaOnnxOfflineStream s,
int32_t  top_k 
)

The returned array is NULL-terminated. If top_k is -1, the value stored in config.top_k is used instead.

Parameters
taggerA pointer returned by SherpaOnnxCreateAudioTagging().
sA pointer returned by SherpaOnnxAudioTaggingCreateOfflineStream().
top_kNumber of top results to return, or -1 to use the configured default.
Returns
A newly allocated NULL-terminated array of result pointers ordered by descending probability. Free it with SherpaOnnxAudioTaggingFreeResults().
const SherpaOnnxAudioEvent *const *results =
SherpaOnnxAudioTaggingCompute(tagger, stream, 5);
for (int32_t i = 0; results[i] != NULL; ++i) {
printf("%d %.3f %s\n", results[i]->index, results[i]->prob,
results[i]->name);
}
void SherpaOnnxAudioTaggingFreeResults(const SherpaOnnxAudioEvent *const *p)
Destroy results returned by SherpaOnnxAudioTaggingCompute().
const SherpaOnnxAudioEvent *const * SherpaOnnxAudioTaggingCompute(const SherpaOnnxAudioTagging *tagger, const SherpaOnnxOfflineStream *s, int32_t top_k)
Run audio tagging on an offline stream.
One audio-tagging prediction.
Definition c-api.h:3428

◆ SherpaOnnxAudioTaggingCreateOfflineStream()

const SherpaOnnxOfflineStream * SherpaOnnxAudioTaggingCreateOfflineStream ( const SherpaOnnxAudioTagging tagger)
Parameters
taggerA pointer returned by SherpaOnnxCreateAudioTagging().
Returns
A newly allocated offline stream. Free it with SherpaOnnxDestroyOfflineStream().

◆ SherpaOnnxAudioTaggingFreeResults()

void SherpaOnnxAudioTaggingFreeResults ( const SherpaOnnxAudioEvent *const *  p)
Parameters
pA pointer returned by SherpaOnnxAudioTaggingCompute().

◆ SherpaOnnxCircularBufferFree()

void SherpaOnnxCircularBufferFree ( const float *  p)

◆ SherpaOnnxCircularBufferGet()

const float * SherpaOnnxCircularBufferGet ( const SherpaOnnxCircularBuffer buffer,
int32_t  start_index,
int32_t  n 
)
Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().
start_indexAbsolute start index in the buffer timeline.
nNumber of samples to copy.
Returns
A newly allocated array containing n samples. Free it with SherpaOnnxCircularBufferFree().
const float *samples = SherpaOnnxCircularBufferGet(buffer, start, 3200);
const float * SherpaOnnxCircularBufferGet(const SherpaOnnxCircularBuffer *buffer, int32_t start_index, int32_t n)
Copy out a slice of samples from a circular buffer.
void SherpaOnnxCircularBufferFree(const float *p)
Free an array returned by SherpaOnnxCircularBufferGet().

◆ SherpaOnnxCircularBufferHead()

int32_t SherpaOnnxCircularBufferHead ( const SherpaOnnxCircularBuffer buffer)

The value is monotonically non-decreasing until SherpaOnnxCircularBufferReset() is called.

Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().
Returns
The current head index.

◆ SherpaOnnxCircularBufferPop()

void SherpaOnnxCircularBufferPop ( const SherpaOnnxCircularBuffer buffer,
int32_t  n 
)
Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().
nNumber of samples to remove.

◆ SherpaOnnxCircularBufferPush()

void SherpaOnnxCircularBufferPush ( const SherpaOnnxCircularBuffer buffer,
const float *  p,
int32_t  n 
)
Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().
pPointer to n samples.
nNumber of samples.
SherpaOnnxCircularBufferPush(buffer, wave->samples, wave->num_samples);
void SherpaOnnxCircularBufferPush(const SherpaOnnxCircularBuffer *buffer, const float *p, int32_t n)
Append samples to a circular buffer.

◆ SherpaOnnxCircularBufferReset()

void SherpaOnnxCircularBufferReset ( const SherpaOnnxCircularBuffer buffer)
Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().

◆ SherpaOnnxCircularBufferSize()

int32_t SherpaOnnxCircularBufferSize ( const SherpaOnnxCircularBuffer buffer)
Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().
Returns
Number of samples currently in the buffer.

◆ SherpaOnnxCreateAudioTagging()

const SherpaOnnxAudioTagging * SherpaOnnxCreateAudioTagging ( const SherpaOnnxAudioTaggingConfig config)
Parameters
configAudio-tagging configuration.
Returns
A newly allocated audio tagger on success, or NULL on error. Free it with SherpaOnnxDestroyAudioTagging().

◆ SherpaOnnxCreateCircularBuffer()

const SherpaOnnxCircularBuffer * SherpaOnnxCreateCircularBuffer ( int32_t  capacity)
Parameters
capacityMaximum number of samples the buffer can keep.
Returns
A newly allocated buffer. Free it with SherpaOnnxDestroyCircularBuffer().
const SherpaOnnxCircularBuffer *buffer =
struct SherpaOnnxCircularBuffer SherpaOnnxCircularBuffer
Opaque circular-buffer handle used by helper APIs.
Definition c-api.h:1936
const SherpaOnnxCircularBuffer * SherpaOnnxCreateCircularBuffer(int32_t capacity)
Create a floating-point circular buffer.

◆ SherpaOnnxCreateDisplay()

const SherpaOnnxDisplay * SherpaOnnxCreateDisplay ( int32_t  max_word_per_line)
Parameters
max_word_per_lineMaximum number of words to show per line.
Returns
A newly allocated display helper. Free it with SherpaOnnxDestroyDisplay().
const SherpaOnnxDisplay * SherpaOnnxCreateDisplay(int32_t max_word_per_line)
Create a display helper.
struct SherpaOnnxDisplay SherpaOnnxDisplay
Helper for pretty-printing incremental recognition results.
Definition c-api.h:778

◆ SherpaOnnxCreateKeywordSpotter()

const SherpaOnnxKeywordSpotter * SherpaOnnxCreateKeywordSpotter ( const SherpaOnnxKeywordSpotterConfig config)
Parameters
configKeyword spotter configuration.
Returns
A newly allocated keyword spotter on success, or NULL on error. Free it with SherpaOnnxDestroyKeywordSpotter().

◆ SherpaOnnxCreateKeywordStream()

const SherpaOnnxOnlineStream * SherpaOnnxCreateKeywordStream ( const SherpaOnnxKeywordSpotter spotter)
Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
Returns
A newly allocated stream. Free it with SherpaOnnxDestroyOnlineStream().

◆ SherpaOnnxCreateKeywordStreamWithKeywords()

const SherpaOnnxOnlineStream * SherpaOnnxCreateKeywordStreamWithKeywords ( const SherpaOnnxKeywordSpotter spotter,
const char *  keywords 
)

The keywords string uses the same textual format as the keyword files used by the examples. For instance:

const SherpaOnnxOnlineStream *stream =
kws, "y ǎn y uán @演员/zh ī m íng @知名");
struct SherpaOnnxOnlineStream SherpaOnnxOnlineStream
Streaming decoding state for one utterance or stream.
Definition c-api.h:424
const SherpaOnnxOnlineStream * SherpaOnnxCreateKeywordStreamWithKeywords(const SherpaOnnxKeywordSpotter *spotter, const char *keywords)
Create a keyword spotting stream with extra or replacement keywords.
Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
keywordsInline keyword definition string.
Returns
A newly allocated stream. Free it with SherpaOnnxDestroyOnlineStream().

◆ SherpaOnnxCreateLinearResampler()

const SherpaOnnxLinearResampler * SherpaOnnxCreateLinearResampler ( int32_t  samp_rate_in_hz,
int32_t  samp_rate_out_hz,
float  filter_cutoff_hz,
int32_t  num_zeros 
)

A common choice is:

float min_freq = samp_rate_in_hz < samp_rate_out_hz ? samp_rate_in_hz
: samp_rate_out_hz;
float filter_cutoff_hz = 0.99f * 0.5f * min_freq;
int32_t num_zeros = 6;
Parameters
samp_rate_in_hzInput sample rate in Hz.
samp_rate_out_hzOutput sample rate in Hz.
filter_cutoff_hzLow-pass cutoff frequency in Hz.
num_zerosLow-pass filter width control parameter.
Returns
A newly allocated resampler. Free it with SherpaOnnxDestroyLinearResampler().

◆ SherpaOnnxCreateOfflinePunctuation()

const SherpaOnnxOfflinePunctuation * SherpaOnnxCreateOfflinePunctuation ( const SherpaOnnxOfflinePunctuationConfig config)
Parameters
configOffline punctuation configuration.
Returns
A newly allocated punctuation processor on success, or NULL on error. Free it with SherpaOnnxDestroyOfflinePunctuation().

◆ SherpaOnnxCreateOfflineRecognizer()

const SherpaOnnxOfflineRecognizer * SherpaOnnxCreateOfflineRecognizer ( const SherpaOnnxOfflineRecognizerConfig config)
Parameters
configRecognizer configuration.
Returns
A recognizer handle on success, or NULL if the configuration is invalid. The caller owns the returned object and must free it with SherpaOnnxDestroyOfflineRecognizer().

Whisper example:

memset(&config, 0, sizeof(config));
config.feat_config.sample_rate = 16000;
"./sherpa-onnx-whisper-tiny/tiny-encoder.onnx";
"./sherpa-onnx-whisper-tiny/tiny-decoder.onnx";
config.model_config.whisper.task = "transcribe";
"./sherpa-onnx-whisper-tiny/tiny-tokens.txt";
config.model_config.provider = "cpu";
config.decoding_method = "greedy_search";
const SherpaOnnxOfflineRecognizer *recognizer =
const SherpaOnnxOfflineRecognizer * SherpaOnnxCreateOfflineRecognizer(const SherpaOnnxOfflineRecognizerConfig *config)
Create a non-streaming ASR recognizer.
struct SherpaOnnxOfflineRecognizer SherpaOnnxOfflineRecognizer
Non-streaming recognizer handle.
Definition c-api.h:1185

SenseVoice example:

"./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17-int8/model.int8.onnx";
"./sherpa-onnx-sense-voice-zh-en-ja-ko-yue-2024-07-17-int8/tokens.txt";

Parakeet TDT example:

"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/encoder.int8.onnx";
"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/decoder.int8.onnx";
"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/joiner.int8.onnx";
"./sherpa-onnx-nemo-parakeet-tdt-0.6b-v3-int8/tokens.txt";
config.model_config.model_type = "nemo_transducer";

◆ SherpaOnnxCreateOfflineSourceSeparation()

const SherpaOnnxOfflineSourceSeparation * SherpaOnnxCreateOfflineSourceSeparation ( const SherpaOnnxOfflineSourceSeparationConfig config)
Parameters
configSource-separation configuration.
Returns
A newly allocated engine on success, or NULL on error. Free it with SherpaOnnxDestroyOfflineSourceSeparation().

◆ SherpaOnnxCreateOfflineSpeakerDiarization()

const SherpaOnnxOfflineSpeakerDiarization * SherpaOnnxCreateOfflineSpeakerDiarization ( const SherpaOnnxOfflineSpeakerDiarizationConfig config)
Parameters
configOffline speaker diarization configuration.
Returns
A newly allocated diarizer on success, or NULL on error. Free it with SherpaOnnxDestroyOfflineSpeakerDiarization().

◆ SherpaOnnxCreateOfflineSpeechDenoiser()

const SherpaOnnxOfflineSpeechDenoiser * SherpaOnnxCreateOfflineSpeechDenoiser ( const SherpaOnnxOfflineSpeechDenoiserConfig config)

Example using gtcrn_simple.onnx:

memset(&config, 0, sizeof(config));
config.model.gtcrn.model = "./gtcrn_simple.onnx";
Configuration for offline speech denoising.
Definition c-api.h:4047
SherpaOnnxOfflineSpeechDenoiserModelConfig model
Definition c-api.h:4049
SherpaOnnxOfflineSpeechDenoiserGtcrnModelConfig gtcrn
Definition c-api.h:4035
Parameters
configOffline denoiser configuration.
Returns
A newly allocated denoiser on success, or NULL on error. Free it with SherpaOnnxDestroyOfflineSpeechDenoiser().

◆ SherpaOnnxCreateOfflineStream()

const SherpaOnnxOfflineStream * SherpaOnnxCreateOfflineStream ( const SherpaOnnxOfflineRecognizer recognizer)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOfflineRecognizer().
Returns
A newly created stream. The caller owns the returned object and must free it with SherpaOnnxDestroyOfflineStream().
const SherpaOnnxWave *wave =
SherpaOnnxReadWave("./sherpa-onnx-whisper-tiny.en/test_wavs/0.wav");
const SherpaOnnxOfflineStream *stream =

◆ SherpaOnnxCreateOfflineStreamWithHotwords()

const SherpaOnnxOfflineStream * SherpaOnnxCreateOfflineStreamWithHotwords ( const SherpaOnnxOfflineRecognizer recognizer,
const char *  hotwords 
)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOfflineRecognizer().
hotwordsHotwords text to associate with the stream.
Returns
A newly created stream. The caller owns the returned object and must free it with SherpaOnnxDestroyOfflineStream().
const SherpaOnnxOfflineStream *stream =
"▁HELLO ▁WORLD");
const SherpaOnnxOfflineStream * SherpaOnnxCreateOfflineStreamWithHotwords(const SherpaOnnxOfflineRecognizer *recognizer, const char *hotwords)
Create a non-streaming ASR input stream with per-stream hotwords.

◆ SherpaOnnxCreateOfflineTts()

const SherpaOnnxOfflineTts * SherpaOnnxCreateOfflineTts ( const SherpaOnnxOfflineTtsConfig config)
Parameters
configTTS configuration.
Returns
A newly allocated TTS engine on success, or NULL on configuration error. Free it with SherpaOnnxDestroyOfflineTts().
memset(&config, 0, sizeof(config));
config.model.kokoro.model = "./kokoro-en-v0_19/model.onnx";
config.model.kokoro.voices = "./kokoro-en-v0_19/voices.bin";
config.model.kokoro.tokens = "./kokoro-en-v0_19/tokens.txt";
config.model.kokoro.data_dir = "./kokoro-en-v0_19/espeak-ng-data";
config.model.num_threads = 2;
const SherpaOnnxOfflineTts * SherpaOnnxCreateOfflineTts(const SherpaOnnxOfflineTtsConfig *config)
Create an offline TTS engine.
struct SherpaOnnxOfflineTts SherpaOnnxOfflineTts
Opaque offline TTS handle.
Definition c-api.h:2473

◆ SherpaOnnxCreateOnlinePunctuation()

const SherpaOnnxOnlinePunctuation * SherpaOnnxCreateOnlinePunctuation ( const SherpaOnnxOnlinePunctuationConfig config)
Parameters
configOnline punctuation configuration.
Returns
A newly allocated punctuation processor on success, or NULL on error. Free it with SherpaOnnxDestroyOnlinePunctuation().

◆ SherpaOnnxCreateOnlineRecognizer()

const SherpaOnnxOnlineRecognizer * SherpaOnnxCreateOnlineRecognizer ( const SherpaOnnxOnlineRecognizerConfig config)

The returned recognizer runs locally and does not require Internet access.

Parameters
configRecognizer configuration.
Returns
A recognizer handle on success, or NULL if the configuration is invalid. The caller owns the returned object and must free it with SherpaOnnxDestroyOnlineRecognizer().
memset(&config, 0, sizeof(config));
config.feat_config.sample_rate = 16000;
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"encoder-epoch-99-avg-1.int8.onnx";
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"decoder-epoch-99-avg-1.onnx";
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"joiner-epoch-99-avg-1.int8.onnx";
"./sherpa-onnx-streaming-zipformer-bilingual-zh-en-2023-02-20/"
"tokens.txt";
config.model_config.provider = "cpu";
config.decoding_method = "greedy_search";
const SherpaOnnxOnlineRecognizer *recognizer =
struct SherpaOnnxOnlineRecognizer SherpaOnnxOnlineRecognizer
Streaming recognizer handle.
Definition c-api.h:422
const SherpaOnnxOnlineRecognizer * SherpaOnnxCreateOnlineRecognizer(const SherpaOnnxOnlineRecognizerConfig *config)
Create a streaming ASR recognizer.

◆ SherpaOnnxCreateOnlineSpeechDenoiser()

const SherpaOnnxOnlineSpeechDenoiser * SherpaOnnxCreateOnlineSpeechDenoiser ( const SherpaOnnxOnlineSpeechDenoiserConfig config)
Parameters
configOnline denoiser configuration.
Returns
A newly allocated denoiser on success, or NULL on error. Free it with SherpaOnnxDestroyOnlineSpeechDenoiser().

◆ SherpaOnnxCreateOnlineStream()

const SherpaOnnxOnlineStream * SherpaOnnxCreateOnlineStream ( const SherpaOnnxOnlineRecognizer recognizer)

One stream corresponds to one decoding state. Reuse the same recognizer to create multiple streams.

Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
Returns
A newly created stream. The caller owns the returned object and must free it with SherpaOnnxDestroyOnlineStream().
"./sherpa-onnx-streaming-paraformer-bilingual-zh-en/test_wavs/0.wav");
const SherpaOnnxOnlineStream *stream =
const SherpaOnnxOnlineStream * SherpaOnnxCreateOnlineStream(const SherpaOnnxOnlineRecognizer *recognizer)
Create a streaming ASR state object.

◆ SherpaOnnxCreateOnlineStreamWithHotwords()

const SherpaOnnxOnlineStream * SherpaOnnxCreateOnlineStreamWithHotwords ( const SherpaOnnxOnlineRecognizer recognizer,
const char *  hotwords 
)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
hotwordsHotwords text to associate with the stream.
Returns
A newly created stream. The caller owns the returned object and must free it with SherpaOnnxDestroyOnlineStream().
const SherpaOnnxOnlineStream *stream =
"▁HELLO ▁WORLD");
const SherpaOnnxOnlineStream * SherpaOnnxCreateOnlineStreamWithHotwords(const SherpaOnnxOnlineRecognizer *recognizer, const char *hotwords)
Create a streaming ASR state object with per-stream hotwords.

◆ SherpaOnnxCreateSpeakerEmbeddingExtractor()

const SherpaOnnxSpeakerEmbeddingExtractor * SherpaOnnxCreateSpeakerEmbeddingExtractor ( const SherpaOnnxSpeakerEmbeddingExtractorConfig config)
Parameters
configSpeaker embedding extractor configuration.
Returns
A newly allocated extractor on success, or NULL on error. Free it with SherpaOnnxDestroySpeakerEmbeddingExtractor().

◆ SherpaOnnxCreateSpeakerEmbeddingManager()

const SherpaOnnxSpeakerEmbeddingManager * SherpaOnnxCreateSpeakerEmbeddingManager ( int32_t  dim)

The manager stores enrolled speaker embeddings and supports speaker search and verification.

Parameters
dimEmbedding dimension. This should match SherpaOnnxSpeakerEmbeddingExtractorDim().
Returns
A newly allocated manager. Free it with SherpaOnnxDestroySpeakerEmbeddingManager().

◆ SherpaOnnxCreateSpokenLanguageIdentification()

const SherpaOnnxSpokenLanguageIdentification * SherpaOnnxCreateSpokenLanguageIdentification ( const SherpaOnnxSpokenLanguageIdentificationConfig config)
Parameters
configSpoken-language identification configuration.
Returns
A newly allocated identifier on success, or NULL on error. Free it with SherpaOnnxDestroySpokenLanguageIdentification().

◆ SherpaOnnxCreateVoiceActivityDetector()

const SherpaOnnxVoiceActivityDetector * SherpaOnnxCreateVoiceActivityDetector ( const SherpaOnnxVadModelConfig config,
float  buffer_size_in_seconds 
)

Example model files are shown in c-api-examples/vad-whisper-c-api.c.

Parameters
configVAD configuration.
buffer_size_in_secondsInternal buffering capacity in seconds.
Returns
A newly allocated detector on success, or NULL on configuration error. Free it with SherpaOnnxDestroyVoiceActivityDetector().
memset(&config, 0, sizeof(config));
config.silero_vad.model = "./silero_vad.onnx";
config.silero_vad.threshold = 0.25f;
config.silero_vad.window_size = 512;
config.sample_rate = 16000;
config.num_threads = 1;
const SherpaOnnxVoiceActivityDetector * SherpaOnnxCreateVoiceActivityDetector(const SherpaOnnxVadModelConfig *config, float buffer_size_in_seconds)
Create a voice activity detector.
struct SherpaOnnxVoiceActivityDetector SherpaOnnxVoiceActivityDetector
Opaque voice activity detector handle.
Definition c-api.h:2054

◆ SherpaOnnxDecodeKeywordStream()

void SherpaOnnxDecodeKeywordStream ( const SherpaOnnxKeywordSpotter spotter,
const SherpaOnnxOnlineStream stream 
)

Call this only when SherpaOnnxIsKeywordStreamReady() returns 1.

Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
streamA pointer returned by SherpaOnnxCreateKeywordStream() or SherpaOnnxCreateKeywordStreamWithKeywords().

◆ SherpaOnnxDecodeMultipleKeywordStreams()

void SherpaOnnxDecodeMultipleKeywordStreams ( const SherpaOnnxKeywordSpotter spotter,
const SherpaOnnxOnlineStream **  streams,
int32_t  n 
)

The caller must ensure every stream in streams is ready before calling this function.

Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
streamsArray of ready streams.
nNumber of elements in streams.

◆ SherpaOnnxDecodeMultipleOfflineStreams()

void SherpaOnnxDecodeMultipleOfflineStreams ( const SherpaOnnxOfflineRecognizer recognizer,
const SherpaOnnxOfflineStream **  streams,
int32_t  n 
)

The caller must have already provided one utterance to each stream via SherpaOnnxAcceptWaveformOffline().

Parameters
recognizerA pointer returned by SherpaOnnxCreateOfflineRecognizer().
streamsArray of n offline stream pointers.
nNumber of streams in streams.
const SherpaOnnxOfflineStream *streams[2] = {stream1, stream2};
void SherpaOnnxDecodeMultipleOfflineStreams(const SherpaOnnxOfflineRecognizer *recognizer, const SherpaOnnxOfflineStream **streams, int32_t n)
Run offline ASR on multiple streams in parallel.

◆ SherpaOnnxDecodeMultipleOnlineStreams()

void SherpaOnnxDecodeMultipleOnlineStreams ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream **  streams,
int32_t  n 
)

The caller must ensure every stream in streams is ready before calling this function.

Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamsArray of n stream pointers.
nNumber of streams in streams.
const SherpaOnnxOnlineStream *streams[2] = {stream1, stream2};
SherpaOnnxDecodeMultipleOnlineStreams(recognizer, streams, 2);
void SherpaOnnxDecodeMultipleOnlineStreams(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream **streams, int32_t n)
Decode multiple streaming ASR streams in parallel.

◆ SherpaOnnxDecodeOfflineStream()

void SherpaOnnxDecodeOfflineStream ( const SherpaOnnxOfflineRecognizer recognizer,
const SherpaOnnxOfflineStream stream 
)

Call this after SherpaOnnxAcceptWaveformOffline().

Parameters
recognizerA pointer returned by SherpaOnnxCreateOfflineRecognizer().
streamA pointer returned by SherpaOnnxCreateOfflineStream().
SherpaOnnxDecodeOfflineStream(recognizer, stream);

◆ SherpaOnnxDecodeOnlineStream()

void SherpaOnnxDecodeOnlineStream ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream stream 
)

Call this only when SherpaOnnxIsOnlineStreamReady() returns 1.

Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamA pointer returned by SherpaOnnxCreateOnlineStream().
SherpaOnnxOnlineStreamAcceptWaveform(stream, sample_rate, samples, n);
while (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
SherpaOnnxDecodeOnlineStream(recognizer, stream);
}
void SherpaOnnxOnlineStreamAcceptWaveform(const SherpaOnnxOnlineStream *stream, int32_t sample_rate, const float *samples, int32_t n)
Append audio samples to a streaming ASR stream.
int32_t SherpaOnnxIsOnlineStreamReady(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
Check whether a streaming ASR stream is ready to decode.
void SherpaOnnxDecodeOnlineStream(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
Decode one step of a streaming ASR stream.

◆ SherpaOnnxDestroyAudioTagging()

void SherpaOnnxDestroyAudioTagging ( const SherpaOnnxAudioTagging tagger)
Parameters
taggerA pointer returned by SherpaOnnxCreateAudioTagging().

◆ SherpaOnnxDestroyCircularBuffer()

void SherpaOnnxDestroyCircularBuffer ( const SherpaOnnxCircularBuffer buffer)
Parameters
bufferA pointer returned by SherpaOnnxCreateCircularBuffer().
buffer = NULL;
void SherpaOnnxDestroyCircularBuffer(const SherpaOnnxCircularBuffer *buffer)
Destroy a circular buffer.

◆ SherpaOnnxDestroyDenoisedAudio()

void SherpaOnnxDestroyDenoisedAudio ( const SherpaOnnxDenoisedAudio p)

◆ SherpaOnnxDestroyDisplay()

void SherpaOnnxDestroyDisplay ( const SherpaOnnxDisplay display)
Parameters
displayA pointer returned by SherpaOnnxCreateDisplay().

◆ SherpaOnnxDestroyKeywordResult()

void SherpaOnnxDestroyKeywordResult ( const SherpaOnnxKeywordResult r)
Parameters
rA pointer returned by SherpaOnnxGetKeywordResult().

◆ SherpaOnnxDestroyKeywordSpotter()

void SherpaOnnxDestroyKeywordSpotter ( const SherpaOnnxKeywordSpotter spotter)
Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().

◆ SherpaOnnxDestroyLinearResampler()

void SherpaOnnxDestroyLinearResampler ( const SherpaOnnxLinearResampler p)
Parameters
pA pointer returned by SherpaOnnxCreateLinearResampler().

◆ SherpaOnnxDestroyOfflinePunctuation()

void SherpaOnnxDestroyOfflinePunctuation ( const SherpaOnnxOfflinePunctuation punct)
Parameters
punctA pointer returned by SherpaOnnxCreateOfflinePunctuation().

◆ SherpaOnnxDestroyOfflineRecognizer()

void SherpaOnnxDestroyOfflineRecognizer ( const SherpaOnnxOfflineRecognizer recognizer)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOfflineRecognizer().
recognizer = NULL;
void SherpaOnnxDestroyOfflineRecognizer(const SherpaOnnxOfflineRecognizer *recognizer)
Destroy a non-streaming recognizer.

◆ SherpaOnnxDestroyOfflineRecognizerResult()

void SherpaOnnxDestroyOfflineRecognizerResult ( const SherpaOnnxOfflineRecognizerResult r)
Parameters
rA pointer returned by SherpaOnnxGetOfflineStreamResult().
r = NULL;
void SherpaOnnxDestroyOfflineRecognizerResult(const SherpaOnnxOfflineRecognizerResult *r)
Destroy a result returned by SherpaOnnxGetOfflineStreamResult().

◆ SherpaOnnxDestroyOfflineSourceSeparation()

void SherpaOnnxDestroyOfflineSourceSeparation ( const SherpaOnnxOfflineSourceSeparation ss)
Parameters
ssA pointer returned by SherpaOnnxCreateOfflineSourceSeparation().

◆ SherpaOnnxDestroyOfflineSpeakerDiarization()

void SherpaOnnxDestroyOfflineSpeakerDiarization ( const SherpaOnnxOfflineSpeakerDiarization sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization().

◆ SherpaOnnxDestroyOfflineSpeechDenoiser()

void SherpaOnnxDestroyOfflineSpeechDenoiser ( const SherpaOnnxOfflineSpeechDenoiser sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeechDenoiser().

◆ SherpaOnnxDestroyOfflineStream()

void SherpaOnnxDestroyOfflineStream ( const SherpaOnnxOfflineStream stream)
Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream() or SherpaOnnxCreateOfflineStreamWithHotwords().
stream = NULL;
void SherpaOnnxDestroyOfflineStream(const SherpaOnnxOfflineStream *stream)
Destroy a non-streaming ASR stream.

◆ SherpaOnnxDestroyOfflineStreamResultJson()

void SherpaOnnxDestroyOfflineStreamResultJson ( const char *  s)
Parameters
sA pointer returned by SherpaOnnxGetOfflineStreamResultAsJson().
json = NULL;
void SherpaOnnxDestroyOfflineStreamResultJson(const char *s)
Free a JSON string returned by SherpaOnnxGetOfflineStreamResultAsJson().

◆ SherpaOnnxDestroyOfflineTts()

void SherpaOnnxDestroyOfflineTts ( const SherpaOnnxOfflineTts tts)
Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().

◆ SherpaOnnxDestroyOfflineTtsGeneratedAudio()

void SherpaOnnxDestroyOfflineTtsGeneratedAudio ( const SherpaOnnxGeneratedAudio p)
Parameters
pA pointer returned by one of the SherpaOnnxOfflineTtsGenerate* functions.

◆ SherpaOnnxDestroyOnlinePunctuation()

void SherpaOnnxDestroyOnlinePunctuation ( const SherpaOnnxOnlinePunctuation punctuation)
Parameters
punctuationA pointer returned by SherpaOnnxCreateOnlinePunctuation().

◆ SherpaOnnxDestroyOnlineRecognizer()

void SherpaOnnxDestroyOnlineRecognizer ( const SherpaOnnxOnlineRecognizer recognizer)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
recognizer = NULL;
void SherpaOnnxDestroyOnlineRecognizer(const SherpaOnnxOnlineRecognizer *recognizer)
Destroy a streaming recognizer.

◆ SherpaOnnxDestroyOnlineRecognizerResult()

void SherpaOnnxDestroyOnlineRecognizerResult ( const SherpaOnnxOnlineRecognizerResult r)
Parameters
rA pointer returned by SherpaOnnxGetOnlineStreamResult().
r = NULL;
void SherpaOnnxDestroyOnlineRecognizerResult(const SherpaOnnxOnlineRecognizerResult *r)
Destroy a result returned by SherpaOnnxGetOnlineStreamResult().

◆ SherpaOnnxDestroyOnlineSpeechDenoiser()

void SherpaOnnxDestroyOnlineSpeechDenoiser ( const SherpaOnnxOnlineSpeechDenoiser sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOnlineSpeechDenoiser().

◆ SherpaOnnxDestroyOnlineStream()

void SherpaOnnxDestroyOnlineStream ( const SherpaOnnxOnlineStream stream)
Parameters
streamA pointer returned by SherpaOnnxCreateOnlineStream() or SherpaOnnxCreateOnlineStreamWithHotwords().
stream = NULL;
void SherpaOnnxDestroyOnlineStream(const SherpaOnnxOnlineStream *stream)
Destroy a streaming ASR state object.

◆ SherpaOnnxDestroyOnlineStreamResultJson()

void SherpaOnnxDestroyOnlineStreamResultJson ( const char *  s)
Parameters
sA pointer returned by SherpaOnnxGetOnlineStreamResultAsJson().
json = NULL;
void SherpaOnnxDestroyOnlineStreamResultJson(const char *s)
Free a JSON string returned by SherpaOnnxGetOnlineStreamResultAsJson().

◆ SherpaOnnxDestroySourceSeparationOutput()

void SherpaOnnxDestroySourceSeparationOutput ( const SherpaOnnxSourceSeparationOutput p)
Parameters
pA pointer returned by SherpaOnnxOfflineSourceSeparationProcess().

◆ SherpaOnnxDestroySpeakerEmbeddingExtractor()

void SherpaOnnxDestroySpeakerEmbeddingExtractor ( const SherpaOnnxSpeakerEmbeddingExtractor p)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingExtractor().

◆ SherpaOnnxDestroySpeakerEmbeddingManager()

void SherpaOnnxDestroySpeakerEmbeddingManager ( const SherpaOnnxSpeakerEmbeddingManager p)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().

◆ SherpaOnnxDestroySpeechSegment()

void SherpaOnnxDestroySpeechSegment ( const SherpaOnnxSpeechSegment p)
Parameters
pA pointer returned by SherpaOnnxVoiceActivityDetectorFront().

◆ SherpaOnnxDestroySpokenLanguageIdentification()

void SherpaOnnxDestroySpokenLanguageIdentification ( const SherpaOnnxSpokenLanguageIdentification slid)
Parameters
slidA pointer returned by SherpaOnnxCreateSpokenLanguageIdentification().

◆ SherpaOnnxDestroySpokenLanguageIdentificationResult()

void SherpaOnnxDestroySpokenLanguageIdentificationResult ( const SherpaOnnxSpokenLanguageIdentificationResult r)
Parameters
rA pointer returned by SherpaOnnxSpokenLanguageIdentificationCompute().

◆ SherpaOnnxDestroyVoiceActivityDetector()

void SherpaOnnxDestroyVoiceActivityDetector ( const SherpaOnnxVoiceActivityDetector p)
Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().

◆ SherpaOnnxFileExists()

int32_t SherpaOnnxFileExists ( const char *  filename)
Parameters
filenameFile path to test.
Returns
1 if the file exists; otherwise 0.
if (!SherpaOnnxFileExists("./Obama.wav")) {
fprintf(stderr, "Please download Obama.wav\n");
}
int32_t SherpaOnnxFileExists(const char *filename)
Check whether a file exists.

◆ SherpaOnnxFreeKeywordResultJson()

void SherpaOnnxFreeKeywordResultJson ( const char *  s)
Parameters
sA pointer returned by SherpaOnnxGetKeywordResultAsJson().

◆ SherpaOnnxFreeMultiChannelWave()

void SherpaOnnxFreeMultiChannelWave ( const SherpaOnnxMultiChannelWave wave)
Parameters
waveA pointer returned by SherpaOnnxReadWaveMultiChannel().

◆ SherpaOnnxFreeWave()

void SherpaOnnxFreeWave ( const SherpaOnnxWave wave)

◆ SherpaOnnxGetGitDate()

const char * SherpaOnnxGetGitDate ( )

The returned pointer refers to statically allocated memory owned by the library. Do not free it and do not modify it.

Returns
Build date string, for example "Fri Jun 20 11:22:52 2025".

◆ SherpaOnnxGetGitSha1()

const char * SherpaOnnxGetGitSha1 ( )

The returned pointer refers to statically allocated memory owned by the library. Do not free it and do not modify it.

Returns
Short Git SHA1 string, for example "6982b86c".

◆ SherpaOnnxGetKeywordResult()

const SherpaOnnxKeywordResult * SherpaOnnxGetKeywordResult ( const SherpaOnnxKeywordSpotter spotter,
const SherpaOnnxOnlineStream stream 
)

The returned snapshot may represent either "no trigger yet" or a detected keyword. A common pattern is to check whether strlen(r->keyword) != 0.

Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
streamA pointer returned by SherpaOnnxCreateKeywordStream() or SherpaOnnxCreateKeywordStreamWithKeywords().
Returns
A newly allocated result snapshot. Free it with SherpaOnnxDestroyKeywordResult().
if (r && r->json && strlen(r->keyword)) {
fprintf(stderr, "Detected keyword: %s\n", r->json);
}
void SherpaOnnxDestroyKeywordResult(const SherpaOnnxKeywordResult *r)
Destroy a keyword result snapshot.
void SherpaOnnxResetKeywordStream(const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
Reset a keyword stream after a keyword is detected.
const SherpaOnnxKeywordResult * SherpaOnnxGetKeywordResult(const SherpaOnnxKeywordSpotter *spotter, const SherpaOnnxOnlineStream *stream)
Get the current keyword spotting result for a stream.
Snapshot of the current keyword spotting result.
Definition c-api.h:1577
const char * keyword
Definition c-api.h:1584
const char * json
Definition c-api.h:1619

◆ SherpaOnnxGetKeywordResultAsJson()

const char * SherpaOnnxGetKeywordResultAsJson ( const SherpaOnnxKeywordSpotter spotter,
const SherpaOnnxOnlineStream stream 
)
Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
streamA pointer returned by SherpaOnnxCreateKeywordStream() or SherpaOnnxCreateKeywordStreamWithKeywords().
Returns
A newly allocated JSON string. Free it with SherpaOnnxFreeKeywordResultJson().

◆ SherpaOnnxGetOfflineStreamResult()

const SherpaOnnxOfflineRecognizerResult * SherpaOnnxGetOfflineStreamResult ( const SherpaOnnxOfflineStream stream)

Call this after SherpaOnnxDecodeOfflineStream() or SherpaOnnxDecodeMultipleOfflineStreams().

Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream().
Returns
A newly allocated result snapshot. Free it with SherpaOnnxDestroyOfflineRecognizerResult().
printf("%s\n", r->text);
if (r->timestamps) {
printf("First token starts at %.3f seconds\n", r->timestamps[0]);
}
const SherpaOnnxOfflineRecognizerResult * SherpaOnnxGetOfflineStreamResult(const SherpaOnnxOfflineStream *stream)
Get the recognition result for an offline ASR stream.
Recognition result for a non-streaming ASR stream.
Definition c-api.h:1442

◆ SherpaOnnxGetOfflineStreamResultAsJson()

const char * SherpaOnnxGetOfflineStreamResultAsJson ( const SherpaOnnxOfflineStream stream)
Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream().
Returns
A newly allocated JSON string. Free it with SherpaOnnxDestroyOfflineStreamResultJson().
const char *json = SherpaOnnxGetOfflineStreamResultAsJson(stream);
puts(json);
const char * SherpaOnnxGetOfflineStreamResultAsJson(const SherpaOnnxOfflineStream *stream)
Get the offline ASR result as JSON.

◆ SherpaOnnxGetOnlineStreamResult()

const SherpaOnnxOnlineRecognizerResult * SherpaOnnxGetOnlineStreamResult ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream stream 
)

The returned snapshot is independent from the stream state. The caller owns it and must free it with SherpaOnnxDestroyOnlineRecognizerResult().

Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamA pointer returned by SherpaOnnxCreateOnlineStream().
Returns
A newly allocated result snapshot.
SherpaOnnxGetOnlineStreamResult(recognizer, stream);
printf("%s\n", r->text);
// r->tokens_arr[i] and r->timestamps[i] are parallel when timestamps
// are available.
const SherpaOnnxOnlineRecognizerResult * SherpaOnnxGetOnlineStreamResult(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
Get the current streaming ASR result for a stream.
Incremental recognition result for a streaming ASR stream.
Definition c-api.h:391

◆ SherpaOnnxGetOnlineStreamResultAsJson()

const char * SherpaOnnxGetOnlineStreamResultAsJson ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream stream 
)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamA pointer returned by SherpaOnnxCreateOnlineStream().
Returns
A newly allocated JSON string. Free it with SherpaOnnxDestroyOnlineStreamResultJson().
const char *json =
puts(json);
const char * SherpaOnnxGetOnlineStreamResultAsJson(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
Get the current streaming ASR result as JSON.

◆ SherpaOnnxGetVersionStr()

const char * SherpaOnnxGetVersionStr ( )

The returned pointer refers to statically allocated memory owned by the library. Do not free it and do not modify it.

Returns
Version string, for example "1.12.1".
printf("sherpa-onnx version: %s\n", SherpaOnnxGetVersionStr());
const char * SherpaOnnxGetVersionStr()
Return the sherpa-onnx version string.

◆ SherpaOnnxIsKeywordStreamReady()

int32_t SherpaOnnxIsKeywordStreamReady ( const SherpaOnnxKeywordSpotter spotter,
const SherpaOnnxOnlineStream stream 
)
Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
streamA pointer returned by SherpaOnnxCreateKeywordStream() or SherpaOnnxCreateKeywordStreamWithKeywords().
Returns
1 if the stream is ready to decode; otherwise 0.

◆ SherpaOnnxIsOnlineStreamReady()

int32_t SherpaOnnxIsOnlineStreamReady ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream stream 
)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamA pointer returned by SherpaOnnxCreateOnlineStream().
Returns
1 if enough frames are available for decoding; otherwise 0.
if (SherpaOnnxIsOnlineStreamReady(recognizer, stream)) {
SherpaOnnxDecodeOnlineStream(recognizer, stream);
}

◆ SherpaOnnxLinearResamplerResample()

const SherpaOnnxResampleOut * SherpaOnnxLinearResamplerResample ( const SherpaOnnxLinearResampler p,
const float *  input,
int32_t  input_dim,
int32_t  flush 
)

Set flush to 1 for the final chunk so buffered samples are emitted.

Parameters
pA pointer returned by SherpaOnnxCreateLinearResampler().
inputInput sample array.
input_dimNumber of input samples.
flush1 if this is the final chunk; otherwise 0.
Returns
A newly allocated output chunk. Free it with SherpaOnnxLinearResamplerResampleFree().

◆ SherpaOnnxLinearResamplerResampleFree()

void SherpaOnnxLinearResamplerResampleFree ( const SherpaOnnxResampleOut p)
Parameters
pA pointer returned by SherpaOnnxLinearResamplerResample().

◆ SherpaOnnxLinearResamplerResampleGetInputSampleRate()

int32_t SherpaOnnxLinearResamplerResampleGetInputSampleRate ( const SherpaOnnxLinearResampler p)
Parameters
pA pointer returned by SherpaOnnxCreateLinearResampler().
Returns
Input sample rate in Hz.

◆ SherpaOnnxLinearResamplerResampleGetOutputSampleRate()

int32_t SherpaOnnxLinearResamplerResampleGetOutputSampleRate ( const SherpaOnnxLinearResampler p)
Parameters
pA pointer returned by SherpaOnnxCreateLinearResampler().
Returns
Output sample rate in Hz.

◆ SherpaOnnxLinearResamplerReset()

void SherpaOnnxLinearResamplerReset ( const SherpaOnnxLinearResampler p)
Parameters
pA pointer returned by SherpaOnnxCreateLinearResampler().

◆ SherpaOnnxOfflineRecognizerSetConfig()

void SherpaOnnxOfflineRecognizerSetConfig ( const SherpaOnnxOfflineRecognizer recognizer,
const SherpaOnnxOfflineRecognizerConfig config 
)
Parameters
recognizerRecognizer handle.
configNew recognizer configuration.
void SherpaOnnxOfflineRecognizerSetConfig(const SherpaOnnxOfflineRecognizer *recognizer, const SherpaOnnxOfflineRecognizerConfig *config)
Update the configuration of an existing offline recognizer.

◆ SherpaOnnxOfflineSourceSeparationGetNumberOfStems()

int32_t SherpaOnnxOfflineSourceSeparationGetNumberOfStems ( const SherpaOnnxOfflineSourceSeparation ss)

For Spleeter 2-stems this returns 2 (vocals + accompaniment).

Parameters
ssA pointer returned by SherpaOnnxCreateOfflineSourceSeparation().
Returns
Number of output stems.

◆ SherpaOnnxOfflineSourceSeparationGetOutputSampleRate()

int32_t SherpaOnnxOfflineSourceSeparationGetOutputSampleRate ( const SherpaOnnxOfflineSourceSeparation ss)
Parameters
ssA pointer returned by SherpaOnnxCreateOfflineSourceSeparation().
Returns
Output sample rate in Hz.

◆ SherpaOnnxOfflineSourceSeparationProcess()

const SherpaOnnxSourceSeparationOutput * SherpaOnnxOfflineSourceSeparationProcess ( const SherpaOnnxOfflineSourceSeparation ss,
const float *const *  samples,
int32_t  num_channels,
int32_t  num_samples,
int32_t  sample_rate 
)

All input channels must have the same number of samples.

Parameters
ssA pointer returned by SherpaOnnxCreateOfflineSourceSeparation().
samplessamples[c] is a float array for channel c, values in [-1, 1].
num_channelsNumber of input channels.
num_samplesNumber of samples per channel (all channels must have the same length).
sample_rateInput sample rate in Hz.
Returns
A newly allocated output on success, or NULL on error. Free it with SherpaOnnxDestroySourceSeparationOutput().

◆ SherpaOnnxOfflineSpeakerDiarizationDestroyResult()

void SherpaOnnxOfflineSpeakerDiarizationDestroyResult ( const SherpaOnnxOfflineSpeakerDiarizationResult r)
Parameters
rA pointer returned by one of the SherpaOnnxOfflineSpeakerDiarizationProcess*() functions.

◆ SherpaOnnxOfflineSpeakerDiarizationDestroySegment()

void SherpaOnnxOfflineSpeakerDiarizationDestroySegment ( const SherpaOnnxOfflineSpeakerDiarizationSegment s)

◆ SherpaOnnxOfflineSpeakerDiarizationGetSampleRate()

int32_t SherpaOnnxOfflineSpeakerDiarizationGetSampleRate ( const SherpaOnnxOfflineSpeakerDiarization sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization().
Returns
Required input sample rate in Hz.

◆ SherpaOnnxOfflineSpeakerDiarizationProcess()

const SherpaOnnxOfflineSpeakerDiarizationResult * SherpaOnnxOfflineSpeakerDiarizationProcess ( const SherpaOnnxOfflineSpeakerDiarization sd,
const float *  samples,
int32_t  n 
)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization().
samplesInput mono PCM samples normalized to [-1, 1].
nNumber of input samples.
Returns
A newly allocated diarization result. Free it with SherpaOnnxOfflineSpeakerDiarizationDestroyResult().

◆ SherpaOnnxOfflineSpeakerDiarizationProcessWithCallback()

const SherpaOnnxOfflineSpeakerDiarizationResult * SherpaOnnxOfflineSpeakerDiarizationProcessWithCallback ( const SherpaOnnxOfflineSpeakerDiarization sd,
const float *  samples,
int32_t  n,
SherpaOnnxOfflineSpeakerDiarizationProgressCallback  callback,
void *  arg 
)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization().
samplesInput mono PCM samples normalized to [-1, 1].
nNumber of input samples.
callbackProgress callback.
argUser pointer forwarded to callback.
Returns
A newly allocated diarization result. Free it with SherpaOnnxOfflineSpeakerDiarizationDestroyResult().
static int32_t ProgressCallback(int32_t done, int32_t total, void *arg) {
fprintf(stderr, "progress %.2f%%\n", 100.0f * done / total);
return 0;
}

◆ SherpaOnnxOfflineSpeakerDiarizationProcessWithCallbackNoArg()

const SherpaOnnxOfflineSpeakerDiarizationResult * SherpaOnnxOfflineSpeakerDiarizationProcessWithCallbackNoArg ( const SherpaOnnxOfflineSpeakerDiarization sd,
const float *  samples,
int32_t  n,
SherpaOnnxOfflineSpeakerDiarizationProgressCallbackNoArg  callback 
)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization().
samplesInput mono PCM samples normalized to [-1, 1].
nNumber of input samples.
callbackProgress callback.
Returns
A newly allocated diarization result. Free it with SherpaOnnxOfflineSpeakerDiarizationDestroyResult().

◆ SherpaOnnxOfflineSpeakerDiarizationResultGetNumSegments()

int32_t SherpaOnnxOfflineSpeakerDiarizationResultGetNumSegments ( const SherpaOnnxOfflineSpeakerDiarizationResult r)
Parameters
rA pointer returned by one of the SherpaOnnxOfflineSpeakerDiarizationProcess*() functions.
Returns
Number of segments.

◆ SherpaOnnxOfflineSpeakerDiarizationResultGetNumSpeakers()

int32_t SherpaOnnxOfflineSpeakerDiarizationResultGetNumSpeakers ( const SherpaOnnxOfflineSpeakerDiarizationResult r)
Parameters
rA pointer returned by one of the SherpaOnnxOfflineSpeakerDiarizationProcess*() functions.
Returns
Number of speaker clusters.

◆ SherpaOnnxOfflineSpeakerDiarizationResultSortByStartTime()

const SherpaOnnxOfflineSpeakerDiarizationSegment * SherpaOnnxOfflineSpeakerDiarizationResultSortByStartTime ( const SherpaOnnxOfflineSpeakerDiarizationResult r)

The returned array contains exactly SherpaOnnxOfflineSpeakerDiarizationResultGetNumSegments() entries.

Parameters
rA pointer returned by one of the SherpaOnnxOfflineSpeakerDiarizationProcess*() functions.
Returns
A newly allocated segment array. Free it with SherpaOnnxOfflineSpeakerDiarizationDestroySegment().

◆ SherpaOnnxOfflineSpeakerDiarizationSetConfig()

void SherpaOnnxOfflineSpeakerDiarizationSetConfig ( const SherpaOnnxOfflineSpeakerDiarization sd,
const SherpaOnnxOfflineSpeakerDiarizationConfig config 
)

Only config->clustering is used. Other fields are ignored.

Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeakerDiarization().
configConfiguration whose clustering field will be applied.

◆ SherpaOnnxOfflineSpeechDenoiserGetSampleRate()

int32_t SherpaOnnxOfflineSpeechDenoiserGetSampleRate ( const SherpaOnnxOfflineSpeechDenoiser sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeechDenoiser().
Returns
Required input sample rate in Hz.

◆ SherpaOnnxOfflineSpeechDenoiserRun()

const SherpaOnnxDenoisedAudio * SherpaOnnxOfflineSpeechDenoiserRun ( const SherpaOnnxOfflineSpeechDenoiser sd,
const float *  samples,
int32_t  n,
int32_t  sample_rate 
)
Parameters
sdA pointer returned by SherpaOnnxCreateOfflineSpeechDenoiser().
samplesInput mono PCM samples normalized to [-1, 1].
nNumber of input samples.
sample_rateInput sample rate in Hz.
Returns
A newly allocated denoised waveform. Free it with SherpaOnnxDestroyDenoisedAudio().
const SherpaOnnxDenoisedAudio *denoised =
SherpaOnnxOfflineSpeechDenoiserRun(sd, wave->samples, wave->num_samples,
wave->sample_rate);
SherpaOnnxWriteWave(denoised->samples, denoised->n, denoised->sample_rate,
"./enhanced.wav");
const SherpaOnnxDenoisedAudio * SherpaOnnxOfflineSpeechDenoiserRun(const SherpaOnnxOfflineSpeechDenoiser *sd, const float *samples, int32_t n, int32_t sample_rate)
Run offline speech denoising on a complete waveform.
int32_t SherpaOnnxWriteWave(const float *samples, int32_t n, int32_t sample_rate, const char *filename)
Write floating-point PCM to a mono 16-bit WAVE file.
void SherpaOnnxDestroyDenoisedAudio(const SherpaOnnxDenoisedAudio *p)
Destroy denoised audio returned by a speech enhancement API.
Denoised audio returned by offline or online speech enhancement APIs.
Definition c-api.h:4096
const float * samples
Definition c-api.h:4098

◆ SherpaOnnxOfflineStreamGetOption()

const char * SherpaOnnxOfflineStreamGetOption ( const SherpaOnnxOfflineStream stream,
const char *  key 
)
Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream().
keyOption name.
Returns
The option value. The returned pointer is owned by the stream, must not be freed by the caller, and may be invalidated if the option is overwritten or the stream is destroyed.
const char *value = SherpaOnnxOfflineStreamGetOption(stream, "language");
const char * SherpaOnnxOfflineStreamGetOption(const SherpaOnnxOfflineStream *stream, const char *key)
Get a per-stream runtime option for offline ASR.

◆ SherpaOnnxOfflineStreamHasOption()

int32_t SherpaOnnxOfflineStreamHasOption ( const SherpaOnnxOfflineStream stream,
const char *  key 
)
Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream().
keyOption name.
Returns
1 if the option exists; otherwise 0.
int32_t has_language =
SherpaOnnxOfflineStreamHasOption(stream, "language");
int32_t SherpaOnnxOfflineStreamHasOption(const SherpaOnnxOfflineStream *stream, const char *key)
Check whether a per-stream runtime option exists.

◆ SherpaOnnxOfflineStreamSetOption()

void SherpaOnnxOfflineStreamSetOption ( const SherpaOnnxOfflineStream stream,
const char *  key,
const char *  value 
)
Parameters
streamA pointer returned by SherpaOnnxCreateOfflineStream().
keyOption name.
valueOption value represented as text.
SherpaOnnxOfflineStreamSetOption(stream, "language", "en");
void SherpaOnnxOfflineStreamSetOption(const SherpaOnnxOfflineStream *stream, const char *key, const char *value)
Set a per-stream runtime option for offline ASR.

◆ SherpaOnnxOfflineTtsGenerate()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerate ( const SherpaOnnxOfflineTts tts,
const char *  text,
int32_t  sid,
float  speed 
)
Deprecated:
Use SherpaOnnxOfflineTtsGenerateWithConfig() instead.
Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
textInput text.
sidSpeaker ID for multi-speaker models.
speedSpeech rate. Values > 1 are faster.
Returns
Generated audio, or NULL on error. Free it with SherpaOnnxDestroyOfflineTtsGeneratedAudio().
SherpaOnnxOfflineTtsGenerate(tts, "Hello from sherpa-onnx!", 0, 1.0f);
SherpaOnnxWriteWave(audio->samples, audio->n, audio->sample_rate,
"./generated.wav");
void SherpaOnnxDestroyOfflineTtsGeneratedAudio(const SherpaOnnxGeneratedAudio *p)
Destroy audio returned by a TTS generation API.
const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerate(const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed)
Generate speech from text using the simple sid/speed interface.
Generated waveform returned by TTS APIs.
Definition c-api.h:2426
const float * samples
Definition c-api.h:2428

◆ SherpaOnnxOfflineTtsGenerateWithCallback()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithCallback ( const SherpaOnnxOfflineTts tts,
const char *  text,
int32_t  sid,
float  speed,
SherpaOnnxGeneratedAudioCallback  callback 
)
Deprecated:
Use SherpaOnnxOfflineTtsGenerateWithConfig() instead.

The callback receives newly generated samples. The sample pointer is valid only for the duration of the callback.

Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
textInput text.
sidSpeaker ID for multi-speaker models.
speedSpeech rate. Values > 1 are faster.
callbackIncremental callback. Return 0 to stop generation early.
Returns
Final generated audio, or NULL on error. Free it with SherpaOnnxDestroyOfflineTtsGeneratedAudio().

◆ SherpaOnnxOfflineTtsGenerateWithCallbackWithArg()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithCallbackWithArg ( const SherpaOnnxOfflineTts tts,
const char *  text,
int32_t  sid,
float  speed,
SherpaOnnxGeneratedAudioCallbackWithArg  callback,
void *  arg 
)
Deprecated:
Use SherpaOnnxOfflineTtsGenerateWithConfig() instead.
Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
textInput text.
sidSpeaker ID for multi-speaker models.
speedSpeech rate. Values > 1 are faster.
callbackIncremental callback with user pointer.
argUser pointer forwarded to callback.
Returns
Final generated audio, or NULL on error. Free it with SherpaOnnxDestroyOfflineTtsGeneratedAudio().

◆ SherpaOnnxOfflineTtsGenerateWithConfig()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithConfig ( const SherpaOnnxOfflineTts tts,
const char *  text,
const SherpaOnnxGenerationConfig config,
SherpaOnnxGeneratedAudioProgressCallbackWithArg  callback,
void *  arg 
)

This is the preferred API for new integrations. It supports callback-based progress reporting and model-specific options such as reference audio.

Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
textInput text.
configGeneration-time configuration.
callbackOptional progress callback with user pointer. Return 0 to stop early.
argUser pointer forwarded to callback.
Returns
Generated audio, or NULL on error. Free it with SherpaOnnxDestroyOfflineTtsGeneratedAudio().
memset(&cfg, 0, sizeof(cfg));
cfg.sid = 0;
cfg.speed = 1.0f;
cfg.silence_scale = 0.2f;
"Today as always, men fall into two groups.",
&cfg, NULL, NULL);
const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithConfig(const SherpaOnnxOfflineTts *tts, const char *text, const SherpaOnnxGenerationConfig *config, SherpaOnnxGeneratedAudioProgressCallbackWithArg callback, void *arg)
Generate speech using the advanced configuration interface.

◆ SherpaOnnxOfflineTtsGenerateWithProgressCallback()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithProgressCallback ( const SherpaOnnxOfflineTts tts,
const char *  text,
int32_t  sid,
float  speed,
SherpaOnnxGeneratedAudioProgressCallback  callback 
)
Deprecated:
Use SherpaOnnxOfflineTtsGenerateWithConfig() instead.
Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
textInput text.
sidSpeaker ID for multi-speaker models.
speedSpeech rate. Values > 1 are faster.
callbackProgress callback. Return 0 to stop generation early.
Returns
Final generated audio, or NULL on error. Free it with SherpaOnnxDestroyOfflineTtsGeneratedAudio().
int32_t Progress(const float *samples, int32_t n, float p) {
fprintf(stderr, "Progress: %.2f%%\n", p * 100);
return 1;
}
Progress);
const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithProgressCallback(const SherpaOnnxOfflineTts *tts, const char *text, int32_t sid, float speed, SherpaOnnxGeneratedAudioProgressCallback callback)
Generate speech with a progress callback.

◆ SherpaOnnxOfflineTtsGenerateWithProgressCallbackWithArg()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithProgressCallbackWithArg ( const SherpaOnnxOfflineTts tts,
const char *  text,
int32_t  sid,
float  speed,
SherpaOnnxGeneratedAudioProgressCallbackWithArg  callback,
void *  arg 
)
Deprecated:
Use SherpaOnnxOfflineTtsGenerateWithConfig() instead.
Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
textInput text.
sidSpeaker ID for multi-speaker models.
speedSpeech rate. Values > 1 are faster.
callbackProgress callback with user pointer. Return 0 to stop early.
argUser pointer forwarded to callback.
Returns
Final generated audio, or NULL on error. Free it with SherpaOnnxDestroyOfflineTtsGeneratedAudio().

◆ SherpaOnnxOfflineTtsGenerateWithZipvoice()

const SherpaOnnxGeneratedAudio * SherpaOnnxOfflineTtsGenerateWithZipvoice ( const SherpaOnnxOfflineTts tts,
const char *  text,
const char *  prompt_text,
const float *  prompt_samples,
int32_t  n_prompt,
int32_t  prompt_sr,
float  speed,
int32_t  num_steps 
)

◆ SherpaOnnxOfflineTtsNumSpeakers()

int32_t SherpaOnnxOfflineTtsNumSpeakers ( const SherpaOnnxOfflineTts tts)

Single-speaker models often return 1.

Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
Returns
Number of speakers supported by the model.

◆ SherpaOnnxOfflineTtsSampleRate()

int32_t SherpaOnnxOfflineTtsSampleRate ( const SherpaOnnxOfflineTts tts)
Parameters
ttsA pointer returned by SherpaOnnxCreateOfflineTts().
Returns
Output sample rate in Hz.

◆ SherpaOnnxOnlinePunctuationAddPunct()

const char * SherpaOnnxOnlinePunctuationAddPunct ( const SherpaOnnxOnlinePunctuation punctuation,
const char *  text 
)
Parameters
punctuationA pointer returned by SherpaOnnxCreateOnlinePunctuation().
textInput text chunk.
Returns
A newly allocated punctuated string. Free it with SherpaOnnxOnlinePunctuationFreeText().
const char *out =
"how are you i am fine thank you");
printf("%s\n", out);
const char * SherpaOnnxOnlinePunctuationAddPunct(const SherpaOnnxOnlinePunctuation *punctuation, const char *text)
Add punctuation to one text chunk using the online punctuation model.
void SherpaOnnxOnlinePunctuationFreeText(const char *text)
Free a string returned by SherpaOnnxOnlinePunctuationAddPunct().

◆ SherpaOnnxOnlinePunctuationFreeText()

void SherpaOnnxOnlinePunctuationFreeText ( const char *  text)
Parameters
textA pointer returned by SherpaOnnxOnlinePunctuationAddPunct().

◆ SherpaOnnxOnlineSpeechDenoiserFlush()

const SherpaOnnxDenoisedAudio * SherpaOnnxOnlineSpeechDenoiserFlush ( const SherpaOnnxOnlineSpeechDenoiser sd)

This also resets the denoiser so it can be reused for a new utterance.

Parameters
sdA pointer returned by SherpaOnnxCreateOnlineSpeechDenoiser().
Returns
A newly allocated denoised chunk, or NULL if no buffered output remains. Free non-NULL results with SherpaOnnxDestroyDenoisedAudio().

◆ SherpaOnnxOnlineSpeechDenoiserGetFrameShiftInSamples()

int32_t SherpaOnnxOnlineSpeechDenoiserGetFrameShiftInSamples ( const SherpaOnnxOnlineSpeechDenoiser sd)

Example programs feed audio to the online denoiser in this chunk size.

Parameters
sdA pointer returned by SherpaOnnxCreateOnlineSpeechDenoiser().
Returns
Frame shift in samples.

◆ SherpaOnnxOnlineSpeechDenoiserGetSampleRate()

int32_t SherpaOnnxOnlineSpeechDenoiserGetSampleRate ( const SherpaOnnxOnlineSpeechDenoiser sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOnlineSpeechDenoiser().
Returns
Required input sample rate in Hz.

◆ SherpaOnnxOnlineSpeechDenoiserReset()

void SherpaOnnxOnlineSpeechDenoiserReset ( const SherpaOnnxOnlineSpeechDenoiser sd)
Parameters
sdA pointer returned by SherpaOnnxCreateOnlineSpeechDenoiser().

◆ SherpaOnnxOnlineSpeechDenoiserRun()

const SherpaOnnxDenoisedAudio * SherpaOnnxOnlineSpeechDenoiserRun ( const SherpaOnnxOnlineSpeechDenoiser sd,
const float *  samples,
int32_t  n,
int32_t  sample_rate 
)

This function is not thread-safe. It may return NULL when not enough input has been accumulated to produce denoised output yet.

Parameters
sdA pointer returned by SherpaOnnxCreateOnlineSpeechDenoiser().
samplesInput chunk normalized to [-1, 1].
nNumber of input samples.
sample_rateInput sample rate in Hz.
Returns
A newly allocated denoised chunk, or NULL if no output is available yet. Free non-NULL results with SherpaOnnxDestroyDenoisedAudio().

◆ SherpaOnnxOnlineStreamAcceptWaveform()

void SherpaOnnxOnlineStreamAcceptWaveform ( const SherpaOnnxOnlineStream stream,
int32_t  sample_rate,
const float *  samples,
int32_t  n 
)

The input is mono floating-point PCM normalized to the range [-1, 1]. If sample_rate differs from the recognizer feature sample rate, sherpa-onnx resamples internally.

Parameters
streamA pointer returned by SherpaOnnxCreateOnlineStream().
sample_rateSample rate of samples.
samplesPointer to n samples in the range [-1, 1].
nNumber of samples.
int32_t start = 0;
int32_t chunk_size = 3200; // 0.2 seconds at 16 kHz
SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate,
wave->samples + start, chunk_size);

◆ SherpaOnnxOnlineStreamGetOption()

const char * SherpaOnnxOnlineStreamGetOption ( const SherpaOnnxOnlineStream stream,
const char *  key 
)
Parameters
streamA pointer returned by SherpaOnnxCreateOnlineStream().
keyOption name.
Returns
The option value. The returned pointer is owned by the stream, must not be freed by the caller, and may be invalidated if the option is overwritten or the stream is destroyed.
const char *value = SherpaOnnxOnlineStreamGetOption(stream, "is_final");
const char * SherpaOnnxOnlineStreamGetOption(const SherpaOnnxOnlineStream *stream, const char *key)
Get a per-stream runtime option.

◆ SherpaOnnxOnlineStreamHasOption()

int32_t SherpaOnnxOnlineStreamHasOption ( const SherpaOnnxOnlineStream stream,
const char *  key 
)
Parameters
streamA pointer returned by SherpaOnnxCreateOnlineStream().
keyOption name.
Returns
1 if the option exists; otherwise 0.
int32_t has_option = SherpaOnnxOnlineStreamHasOption(stream, "is_final");
int32_t SherpaOnnxOnlineStreamHasOption(const SherpaOnnxOnlineStream *stream, const char *key)
Check whether a per-stream runtime option exists.

◆ SherpaOnnxOnlineStreamInputFinished()

void SherpaOnnxOnlineStreamInputFinished ( const SherpaOnnxOnlineStream stream)

After calling this function, do not append more samples to the stream.

Parameters
streamA pointer returned by SherpaOnnxCreateOnlineStream().
void SherpaOnnxOnlineStreamInputFinished(const SherpaOnnxOnlineStream *stream)
Signal end-of-input for a streaming ASR stream.

◆ SherpaOnnxOnlineStreamIsEndpoint()

int32_t SherpaOnnxOnlineStreamIsEndpoint ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream stream 
)
Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamA pointer returned by SherpaOnnxCreateOnlineStream().
Returns
1 if an endpoint is detected; otherwise 0.
if (SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream)) {
SherpaOnnxOnlineStreamReset(recognizer, stream);
}
int32_t SherpaOnnxOnlineStreamIsEndpoint(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
Check whether endpoint detection has triggered for a stream.
void SherpaOnnxOnlineStreamReset(const SherpaOnnxOnlineRecognizer *recognizer, const SherpaOnnxOnlineStream *stream)
Reset a streaming ASR stream after an endpoint or utterance boundary.

◆ SherpaOnnxOnlineStreamReset()

void SherpaOnnxOnlineStreamReset ( const SherpaOnnxOnlineRecognizer recognizer,
const SherpaOnnxOnlineStream stream 
)

This clears the decoder state for the stream so that it can be reused for a new utterance.

Parameters
recognizerA pointer returned by SherpaOnnxCreateOnlineRecognizer().
streamA pointer returned by SherpaOnnxCreateOnlineStream().
if (SherpaOnnxOnlineStreamIsEndpoint(recognizer, stream)) {
SherpaOnnxOnlineStreamReset(recognizer, stream);
}

◆ SherpaOnnxOnlineStreamSetOption()

void SherpaOnnxOnlineStreamSetOption ( const SherpaOnnxOnlineStream stream,
const char *  key,
const char *  value 
)

This is a generic extension point for model-specific or runtime-specific options such as "is_final" for streaming Paraformer.

Parameters
streamA pointer returned by SherpaOnnxCreateOnlineStream().
keyOption name.
valueOption value represented as text.
SherpaOnnxOnlineStreamSetOption(stream, "is_final", "1");
void SherpaOnnxOnlineStreamSetOption(const SherpaOnnxOnlineStream *stream, const char *key, const char *value)
Set a per-stream runtime option.

◆ SherpaOnnxPrint()

void SherpaOnnxPrint ( const SherpaOnnxDisplay display,
int32_t  idx,
const char *  s 
)
Parameters
displayA pointer returned by SherpaOnnxCreateDisplay().
idxSegment or utterance index to print.
sText to print.
SherpaOnnxPrint(display, segment_id, r->text);
void SherpaOnnxPrint(const SherpaOnnxDisplay *display, int32_t idx, const char *s)
Print one line of text using the display helper.

◆ SherpaOnnxReadWave()

const SherpaOnnxWave * SherpaOnnxReadWave ( const char *  filename)
Parameters
filenameInput WAVE filename.
Returns
A newly allocated wave object, or NULL on error. Free it with SherpaOnnxFreeWave().
const SherpaOnnxWave *wave = SherpaOnnxReadWave("./Obama.wav");
if (wave) {
printf("sample_rate=%d, num_samples=%d\n",
wave->sample_rate, wave->num_samples);
}
void SherpaOnnxFreeWave(const SherpaOnnxWave *wave)
Destroy a wave object returned by SherpaOnnxReadWave() or SherpaOnnxReadWaveFromBinaryData().

◆ SherpaOnnxReadWaveFromBinaryData()

const SherpaOnnxWave * SherpaOnnxReadWaveFromBinaryData ( const char *  data,
int32_t  n 
)
Parameters
dataPointer to the WAVE file bytes.
nSize of data in bytes.
Returns
A newly allocated wave object, or NULL on error. Free it with SherpaOnnxFreeWave().

◆ SherpaOnnxReadWaveMultiChannel()

const SherpaOnnxMultiChannelWave * SherpaOnnxReadWaveMultiChannel ( const char *  filename)
Parameters
filenameInput WAVE filename.
Returns
A newly allocated multi-channel wave object, or NULL on error. Free it with SherpaOnnxFreeMultiChannelWave().

◆ SherpaOnnxResetKeywordStream()

void SherpaOnnxResetKeywordStream ( const SherpaOnnxKeywordSpotter spotter,
const SherpaOnnxOnlineStream stream 
)

The examples call this immediately after a successful trigger so the next keyword can be detected independently.

Parameters
spotterA pointer returned by SherpaOnnxCreateKeywordSpotter().
streamA pointer returned by SherpaOnnxCreateKeywordStream() or SherpaOnnxCreateKeywordStreamWithKeywords().

◆ SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding()

const float * SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding ( const SherpaOnnxSpeakerEmbeddingExtractor p,
const SherpaOnnxOnlineStream s 
)

The returned vector has SherpaOnnxSpeakerEmbeddingExtractorDim(p) elements. Free it with SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding().

Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingExtractor().
sA pointer returned by SherpaOnnxSpeakerEmbeddingExtractorCreateStream().
Returns
A newly allocated embedding vector.
const SherpaOnnxOnlineStream *stream =
SherpaOnnxOnlineStreamAcceptWaveform(stream, wave->sample_rate,
wave->samples, wave->num_samples);
const float *v =
}
void SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding(const float *v)
Destroy an embedding vector returned by SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding().
const float * SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding(const SherpaOnnxSpeakerEmbeddingExtractor *p, const SherpaOnnxOnlineStream *s)
Compute the embedding for a stream.
int32_t SherpaOnnxSpeakerEmbeddingExtractorIsReady(const SherpaOnnxSpeakerEmbeddingExtractor *p, const SherpaOnnxOnlineStream *s)
Check whether enough audio has been provided to compute an embedding.
const SherpaOnnxOnlineStream * SherpaOnnxSpeakerEmbeddingExtractorCreateStream(const SherpaOnnxSpeakerEmbeddingExtractor *p)
Create a streaming feature buffer for embedding extraction.

◆ SherpaOnnxSpeakerEmbeddingExtractorCreateStream()

const SherpaOnnxOnlineStream * SherpaOnnxSpeakerEmbeddingExtractorCreateStream ( const SherpaOnnxSpeakerEmbeddingExtractor p)

◆ SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding()

void SherpaOnnxSpeakerEmbeddingExtractorDestroyEmbedding ( const float *  v)
Parameters
vA pointer returned by SherpaOnnxSpeakerEmbeddingExtractorComputeEmbedding().

◆ SherpaOnnxSpeakerEmbeddingExtractorDim()

int32_t SherpaOnnxSpeakerEmbeddingExtractorDim ( const SherpaOnnxSpeakerEmbeddingExtractor p)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingExtractor().
Returns
Embedding dimension.

◆ SherpaOnnxSpeakerEmbeddingExtractorIsReady()

int32_t SherpaOnnxSpeakerEmbeddingExtractorIsReady ( const SherpaOnnxSpeakerEmbeddingExtractor p,
const SherpaOnnxOnlineStream s 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingExtractor().
sA pointer returned by SherpaOnnxSpeakerEmbeddingExtractorCreateStream().
Returns
1 if the stream is ready; otherwise 0.

◆ SherpaOnnxSpeakerEmbeddingManagerAdd()

int32_t SherpaOnnxSpeakerEmbeddingManagerAdd ( const SherpaOnnxSpeakerEmbeddingManager p,
const char *  name,
const float *  v 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
nameSpeaker name.
vEmbedding vector with exactly dim elements.
Returns
1 on success; 0 on error.

◆ SherpaOnnxSpeakerEmbeddingManagerAddList()

int32_t SherpaOnnxSpeakerEmbeddingManagerAddList ( const SherpaOnnxSpeakerEmbeddingManager p,
const char *  name,
const float **  v 
)

v is a NULL-terminated array of embedding pointers: v[0], v[1], ..., v[n - 1], followed by v[n] == NULL.

Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
nameSpeaker name.
vNULL-terminated array of embedding pointers.
Returns
1 on success; 0 on error.
const float *spk1_vec[4] = {e1, e2, e3, NULL};
SherpaOnnxSpeakerEmbeddingManagerAddList(manager, "fangjun", spk1_vec);
int32_t SherpaOnnxSpeakerEmbeddingManagerAddList(const SherpaOnnxSpeakerEmbeddingManager *p, const char *name, const float **v)
Add multiple enrollment embeddings for one speaker.

◆ SherpaOnnxSpeakerEmbeddingManagerAddListFlattened()

int32_t SherpaOnnxSpeakerEmbeddingManagerAddListFlattened ( const SherpaOnnxSpeakerEmbeddingManager p,
const char *  name,
const float *  v,
int32_t  n 
)

The input contains n embeddings laid out consecutively, so the total array length must be n * dim.

Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
nameSpeaker name.
vFlattened embedding array.
nNumber of embeddings in v.
Returns
1 on success; 0 on error.

◆ SherpaOnnxSpeakerEmbeddingManagerContains()

int32_t SherpaOnnxSpeakerEmbeddingManagerContains ( const SherpaOnnxSpeakerEmbeddingManager p,
const char *  name 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
nameSpeaker name.
Returns
1 if the speaker exists; otherwise 0.

◆ SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers()

void SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers ( const char *const *  names)
Parameters
namesA pointer returned by SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers().

◆ SherpaOnnxSpeakerEmbeddingManagerFreeBestMatches()

void SherpaOnnxSpeakerEmbeddingManagerFreeBestMatches ( const SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult r)
Parameters
rA pointer returned by SherpaOnnxSpeakerEmbeddingManagerGetBestMatches().

◆ SherpaOnnxSpeakerEmbeddingManagerFreeSearch()

void SherpaOnnxSpeakerEmbeddingManagerFreeSearch ( const char *  name)
Parameters
nameA pointer returned by SherpaOnnxSpeakerEmbeddingManagerSearch().

◆ SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers()

const char *const * SherpaOnnxSpeakerEmbeddingManagerGetAllSpeakers ( const SherpaOnnxSpeakerEmbeddingManager p)

The returned array is NULL-terminated. If no speakers are enrolled, the returned array still exists and its first element is NULL.

Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
Returns
A newly allocated NULL-terminated array of speaker names. Free it with SherpaOnnxSpeakerEmbeddingManagerFreeAllSpeakers().

◆ SherpaOnnxSpeakerEmbeddingManagerGetBestMatches()

const SherpaOnnxSpeakerEmbeddingManagerBestMatchesResult * SherpaOnnxSpeakerEmbeddingManagerGetBestMatches ( const SherpaOnnxSpeakerEmbeddingManager p,
const float *  v,
float  threshold,
int32_t  n 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
vQuery embedding vector.
thresholdMinimum similarity threshold in the range [0, 1].
nMaximum number of matches to return.
Returns
A newly allocated result object, or NULL if no matches are found. Free it with SherpaOnnxSpeakerEmbeddingManagerFreeBestMatches().

◆ SherpaOnnxSpeakerEmbeddingManagerNumSpeakers()

int32_t SherpaOnnxSpeakerEmbeddingManagerNumSpeakers ( const SherpaOnnxSpeakerEmbeddingManager p)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
Returns
Number of enrolled speakers.

◆ SherpaOnnxSpeakerEmbeddingManagerRemove()

int32_t SherpaOnnxSpeakerEmbeddingManagerRemove ( const SherpaOnnxSpeakerEmbeddingManager p,
const char *  name 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
nameSpeaker name to remove.
Returns
1 if removed; otherwise 0. Returns 0 if the speaker does not exist.

◆ SherpaOnnxSpeakerEmbeddingManagerSearch()

const char * SherpaOnnxSpeakerEmbeddingManagerSearch ( const SherpaOnnxSpeakerEmbeddingManager p,
const float *  v,
float  threshold 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
vQuery embedding vector.
thresholdMinimum similarity threshold in the range [0, 1].
Returns
A newly allocated speaker name on match, or NULL if no speaker passes the threshold. Free the returned name with SherpaOnnxSpeakerEmbeddingManagerFreeSearch().

◆ SherpaOnnxSpeakerEmbeddingManagerVerify()

int32_t SherpaOnnxSpeakerEmbeddingManagerVerify ( const SherpaOnnxSpeakerEmbeddingManager p,
const char *  name,
const float *  v,
float  threshold 
)
Parameters
pA pointer returned by SherpaOnnxCreateSpeakerEmbeddingManager().
nameSpeaker name to compare against.
vQuery embedding vector.
thresholdMinimum similarity threshold in the range [0, 1].
Returns
1 if the speaker matches; otherwise 0.

◆ SherpaOnnxSpokenLanguageIdentificationCompute()

const SherpaOnnxSpokenLanguageIdentificationResult * SherpaOnnxSpokenLanguageIdentificationCompute ( const SherpaOnnxSpokenLanguageIdentification slid,
const SherpaOnnxOfflineStream s 
)

Example:

SherpaOnnxAcceptWaveformOffline(stream, wave->sample_rate, wave->samples,
wave->num_samples);
printf("lang=%s\n", result->lang);
const SherpaOnnxSpokenLanguageIdentificationResult * SherpaOnnxSpokenLanguageIdentificationCompute(const SherpaOnnxSpokenLanguageIdentification *slid, const SherpaOnnxOfflineStream *s)
Run spoken-language identification on an offline stream.
SherpaOnnxOfflineStream * SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream(const SherpaOnnxSpokenLanguageIdentification *slid)
Create an offline stream for spoken-language identification.
void SherpaOnnxDestroySpokenLanguageIdentificationResult(const SherpaOnnxSpokenLanguageIdentificationResult *r)
Destroy a spoken-language identification result.
Result of spoken-language identification.
Definition c-api.h:2979
Parameters
slidA pointer returned by SherpaOnnxCreateSpokenLanguageIdentification().
sA pointer returned by SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream().
Returns
A newly allocated result object. Free it with SherpaOnnxDestroySpokenLanguageIdentificationResult().

◆ SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream()

SherpaOnnxOfflineStream * SherpaOnnxSpokenLanguageIdentificationCreateOfflineStream ( const SherpaOnnxSpokenLanguageIdentification slid)

Feed audio to the returned stream with SherpaOnnxAcceptWaveformOffline(), and then call SherpaOnnxSpokenLanguageIdentificationCompute().

Parameters
slidA pointer returned by SherpaOnnxCreateSpokenLanguageIdentification().
Returns
A newly allocated offline stream. Free it with SherpaOnnxDestroyOfflineStream().

◆ SherpaOnnxVoiceActivityDetectorAcceptWaveform()

void SherpaOnnxVoiceActivityDetectorAcceptWaveform ( const SherpaOnnxVoiceActivityDetector p,
const float *  samples,
int32_t  n 
)

Input samples are mono floating-point PCM in the range [-1, 1].

Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().
samplesPointer to n samples.
nNumber of samples.
wave->samples + i,
window_size);
void SherpaOnnxVoiceActivityDetectorAcceptWaveform(const SherpaOnnxVoiceActivityDetector *p, const float *samples, int32_t n)
Feed audio samples to the VAD.

◆ SherpaOnnxVoiceActivityDetectorClear()

void SherpaOnnxVoiceActivityDetectorClear ( const SherpaOnnxVoiceActivityDetector p)
Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().

◆ SherpaOnnxVoiceActivityDetectorDetected()

int32_t SherpaOnnxVoiceActivityDetectorDetected ( const SherpaOnnxVoiceActivityDetector p)
Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().
Returns
1 if speech is currently detected; otherwise 0.

◆ SherpaOnnxVoiceActivityDetectorEmpty()

int32_t SherpaOnnxVoiceActivityDetectorEmpty ( const SherpaOnnxVoiceActivityDetector p)
Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().
Returns
1 if no completed speech segment is available; otherwise 0.

◆ SherpaOnnxVoiceActivityDetectorFlush()

void SherpaOnnxVoiceActivityDetectorFlush ( const SherpaOnnxVoiceActivityDetector p)

Call this after the last chunk of input has been fed.

Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().
void SherpaOnnxVoiceActivityDetectorFlush(const SherpaOnnxVoiceActivityDetector *p)
Flush buffered tail samples and force final segmentation.

◆ SherpaOnnxVoiceActivityDetectorFront()

const SherpaOnnxSpeechSegment * SherpaOnnxVoiceActivityDetectorFront ( const SherpaOnnxVoiceActivityDetector p)

The returned segment is a copy owned by the caller. Free it with SherpaOnnxDestroySpeechSegment().

Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().
Returns
The first queued speech segment, or NULL if none is available.
const SherpaOnnxSpeechSegment *segment =
printf("start=%d, samples=%d\n", segment->start, segment->n);
}
const SherpaOnnxSpeechSegment * SherpaOnnxVoiceActivityDetectorFront(const SherpaOnnxVoiceActivityDetector *p)
Get the first queued speech segment.
int32_t SherpaOnnxVoiceActivityDetectorEmpty(const SherpaOnnxVoiceActivityDetector *p)
Check whether the detector currently has any completed speech segment.
void SherpaOnnxVoiceActivityDetectorPop(const SherpaOnnxVoiceActivityDetector *p)
Remove the front speech segment from the detector queue.
void SherpaOnnxDestroySpeechSegment(const SherpaOnnxSpeechSegment *p)
Destroy a speech segment returned by SherpaOnnxVoiceActivityDetectorFront().
One detected speech segment returned by the VAD.
Definition c-api.h:2044

◆ SherpaOnnxVoiceActivityDetectorPop()

void SherpaOnnxVoiceActivityDetectorPop ( const SherpaOnnxVoiceActivityDetector p)

Call this after consuming the segment returned by SherpaOnnxVoiceActivityDetectorFront().

Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().

◆ SherpaOnnxVoiceActivityDetectorReset()

void SherpaOnnxVoiceActivityDetectorReset ( const SherpaOnnxVoiceActivityDetector p)
Parameters
pA pointer returned by SherpaOnnxCreateVoiceActivityDetector().

◆ SherpaOnnxWaveFileSize()

int64_t SherpaOnnxWaveFileSize ( int32_t  n_samples)
Parameters
n_samplesNumber of PCM samples.
Returns
Required buffer size in bytes.

◆ SherpaOnnxWriteWave()

int32_t SherpaOnnxWriteWave ( const float *  samples,
int32_t  n,
int32_t  sample_rate,
const char *  filename 
)
Parameters
samplesPointer to n samples in the range [-1, 1].
nNumber of samples.
sample_rateSample rate in Hz.
filenameOutput filename.
Returns
1 on success; 0 on failure.
SherpaOnnxWriteWave(audio->samples, audio->n, audio->sample_rate,
"./generated-kokoro-en.wav");

◆ SherpaOnnxWriteWaveMultiChannel()

int32_t SherpaOnnxWriteWaveMultiChannel ( const float *const *  samples,
int32_t  n,
int32_t  sample_rate,
int32_t  num_channels,
const char *  filename 
)
Parameters
samplessamples[c] is a pointer to channel c samples in [-1, 1].
nNumber of samples per channel.
sample_rateSample rate in Hz.
num_channelsNumber of channels.
filenameOutput filename.
Returns
1 on success; 0 on failure.

◆ SherpaOnnxWriteWaveToBuffer()

void SherpaOnnxWriteWaveToBuffer ( const float *  samples,
int32_t  n,
int32_t  sample_rate,
char *  buffer 
)

Allocate at least SherpaOnnxWaveFileSize(n) bytes before calling.

Parameters
samplesPointer to n samples in the range [-1, 1].
nNumber of samples.
sample_rateSample rate in Hz.
bufferOutput buffer.