sherpa-onnx C API 1.0
Public C API and C++ wrapper for sherpa-onnx
Loading...
Searching...
No Matches
SherpaOnnxGenerationConfig Struct Reference

Generation-time parameters shared by advanced TTS APIs. More...

#include <c-api.h>

Public Attributes

float silence_scale
float speed
int32_t sid
const float * reference_audio
int32_t reference_audio_len
int32_t reference_sample_rate
const char * reference_text
int32_t num_steps
const char * extra
const int32_t * phoneme_codepoints
const int32_t * phoneme_codepoints_lens
int32_t phoneme_codepoints_num_sentences
const char *const * tokens
const int32_t * tokens_lens
int32_t tokens_num_sentences

Detailed Description

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:2798
const float * reference_audio
Definition c-api.h:2806
See also
SherpaOnnxOfflineTtsGenerateWithConfig

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

Member Data Documentation

◆ extra

const char* SherpaOnnxGenerationConfig::extra

Optional model-specific JSON string with extra key/value pairs.

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

◆ num_steps

int32_t SherpaOnnxGenerationConfig::num_steps

Optional number of flow-matching steps.

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

◆ phoneme_codepoints

const int32_t* SherpaOnnxGenerationConfig::phoneme_codepoints

Pre-phonemized input as Unicode codepoints.

Phonemize the text yourself (for instance with piper_phonemize) and pass the resulting codepoints here. When set, it is used in place of text. Leave as NULL to use text with a lexicon.

Each sentence is one sub-array. All codepoints of all sentences are stored flattened in this array; see phoneme_codepoints_lens for the boundaries.

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

◆ phoneme_codepoints_lens

const int32_t* SherpaOnnxGenerationConfig::phoneme_codepoints_lens

Number of codepoints in each sentence. It has phoneme_codepoints_num_sentences entries. If not NULL, every entry must be > 0.

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

◆ phoneme_codepoints_num_sentences

int32_t SherpaOnnxGenerationConfig::phoneme_codepoints_num_sentences

Number of sentences in phoneme_codepoints_lens.

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

◆ reference_audio

const float* SherpaOnnxGenerationConfig::reference_audio

Optional reference audio for zero-shot or voice-cloning models.

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

◆ reference_audio_len

int32_t SherpaOnnxGenerationConfig::reference_audio_len

Length of reference_audio in samples.

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

◆ reference_sample_rate

int32_t SherpaOnnxGenerationConfig::reference_sample_rate

Sample rate of reference_audio.

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

◆ reference_text

const char* SherpaOnnxGenerationConfig::reference_text

Optional reference text associated with reference_audio.

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

◆ sid

int32_t SherpaOnnxGenerationConfig::sid

Speaker ID for multi-speaker models.

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

◆ silence_scale

float SherpaOnnxGenerationConfig::silence_scale

Silence scale between sentences.

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

◆ speed

float SherpaOnnxGenerationConfig::speed

Speech rate. Used only by models that support it.

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

◆ tokens

const char* const* SherpaOnnxGenerationConfig::tokens

Pre-tokenized input, e.g. Chinese pinyin like "zhong1".

Each sentence is one sub-array. All token strings of all sentences are stored flattened in this array; see tokens_lens for the boundaries.

Mutually exclusive with phoneme_codepoints: if both are set, a warning is printed and generation fails.

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

◆ tokens_lens

const int32_t* SherpaOnnxGenerationConfig::tokens_lens

Number of tokens in each sentence. It has tokens_num_sentences entries. If not NULL, every entry must be > 0.

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

◆ tokens_num_sentences

int32_t SherpaOnnxGenerationConfig::tokens_num_sentences

Number of sentences in tokens_lens.

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


The documentation for this struct was generated from the following file: