sherpa-onnx C API 1.0
Public C API and C++ wrapper for sherpa-onnx
Loading...
Searching...
No Matches
Spoken Language Identification

sherpa-onnx supports spoken language identification through the SherpaOnnxCreateSpokenLanguageIdentification() API. It uses Whisper-based models to detect the language of spoken audio.

See also
SherpaOnnxCreateSpokenLanguageIdentification, SherpaOnnxSpokenLanguageIdentificationConfig
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";
SherpaOnnxAcceptWaveformOffline(stream, wave->sample_rate,
wave->samples, wave->num_samples);
printf("Detected language: %s\n", result->lang);
struct SherpaOnnxSpokenLanguageIdentification SherpaOnnxSpokenLanguageIdentification
Opaque spoken-language identification handle.
Definition c-api.h:2979
void SherpaOnnxDestroySpokenLanguageIdentification(const SherpaOnnxSpokenLanguageIdentification *slid)
Destroy a spoken-language identifier.
void SherpaOnnxDestroyOfflineStream(const SherpaOnnxOfflineStream *stream)
Destroy a non-streaming ASR stream.
struct SherpaOnnxOfflineStream SherpaOnnxOfflineStream
Non-streaming decoding state for one utterance.
Definition c-api.h:1199
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 SherpaOnnxSpokenLanguageIdentification * SherpaOnnxCreateSpokenLanguageIdentification(const SherpaOnnxSpokenLanguageIdentificationConfig *config)
Create a spoken-language identifier.
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.
Configuration for spoken language identification.
Definition c-api.h:2967
SherpaOnnxSpokenLanguageIdentificationWhisperConfig whisper
Definition c-api.h:2969
Result of spoken-language identification.
Definition c-api.h:3024

Model package: sherpa-onnx-whisper-tiny

Example source: spoken-language-identification-c-api.c