sherpa-onnx C API 1.0
Public C API and C++ wrapper for sherpa-onnx
Loading...
Searching...
No Matches
sherpa_onnx::cxx::OfflineTts Class Reference

RAII wrapper for offline TTS. More...

#include <cxx-api.h>

Inheritance diagram for sherpa_onnx::cxx::OfflineTts:
Collaboration diagram for sherpa_onnx::cxx::OfflineTts:

Public Member Functions

void Destroy (const SherpaOnnxOfflineTts *p) const
 Destroy the wrapped C handle.
int32_t SampleRate () const
 Return the output sample rate of generated audio.
int32_t NumSpeakers () const
 Return the number of supported speakers.
std::string Lang () const
 Return the language/voice of the model, e.g., "en-us".
GeneratedAudio Generate (const std::string &text, int32_t sid=0, float speed=1.0, OfflineTtsCallback callback=nullptr, void *arg=nullptr) const
 Generate speech using the simple speaker-id and speed interface.
GeneratedAudio Generate (const std::string &text, const GenerationConfig &config, OfflineTtsCallback callback=nullptr, void *arg=nullptr) const
 Generate speech using the advanced generation configuration.
std::shared_ptr< GeneratedAudio > Generate2 (const std::string &text, int32_t sid=0, float speed=1.0, OfflineTtsCallback callback=nullptr, void *arg=nullptr) const
 Like Generate(), but returns a shared pointer to the result.
std::shared_ptr< GeneratedAudio > Generate2 (const std::string &text, const GenerationConfig &config, OfflineTtsCallback callback=nullptr, void *arg=nullptr) const
 Like the advanced Generate() overload, but returns a shared pointer.
Public Member Functions inherited from sherpa_onnx::cxx::MoveOnly< OfflineTts, SherpaOnnxOfflineTts >
 MoveOnly ()=default
 Construct an empty wrapper.
 ~MoveOnly ()
 Destroy the wrapped handle if present.
MoveOnly & operator= (const MoveOnly &)=delete
const SherpaOnnxOfflineTts * Get () const
 Return the wrapped raw pointer without transferring ownership.
const SherpaOnnxOfflineTts * Release ()
 Release ownership of the wrapped raw pointer.

Static Public Member Functions

static OfflineTts Create (const OfflineTtsConfig &config)
 Create an offline TTS engine.

Additional Inherited Members

Protected Attributes inherited from sherpa_onnx::cxx::MoveOnly< OfflineTts, SherpaOnnxOfflineTts >
const SherpaOnnxOfflineTts * p_

Detailed Description

Example using Pocket TTS:

"./sherpa-onnx-pocket-tts-int8-2026-01-26/lm_flow.int8.onnx";
"./sherpa-onnx-pocket-tts-int8-2026-01-26/lm_main.int8.onnx";
"./sherpa-onnx-pocket-tts-int8-2026-01-26/encoder.onnx";
"./sherpa-onnx-pocket-tts-int8-2026-01-26/decoder.int8.onnx";
"./sherpa-onnx-pocket-tts-int8-2026-01-26/text_conditioner.onnx";
"./sherpa-onnx-pocket-tts-int8-2026-01-26/vocab.json";
"./sherpa-onnx-pocket-tts-int8-2026-01-26/token_scores.json";
Configuration for offline TTS.
Definition cxx-api.h:1329
OfflineTtsModelConfig model
Definition cxx-api.h:1331
OfflineTtsPocketModelConfig pocket
Definition cxx-api.h:1274

Definition at line 1382 of file cxx-api.h.

Member Function Documentation

◆ Create()

OfflineTts sherpa_onnx::cxx::OfflineTts::Create ( const OfflineTtsConfig & config)
static

◆ Destroy()

void sherpa_onnx::cxx::OfflineTts::Destroy ( const SherpaOnnxOfflineTts * p) const

◆ Generate() [1/2]

GeneratedAudio sherpa_onnx::cxx::OfflineTts::Generate ( const std::string & text,
const GenerationConfig & config,
OfflineTtsCallback callback = nullptr,
void * arg = nullptr ) const

◆ Generate() [2/2]

GeneratedAudio sherpa_onnx::cxx::OfflineTts::Generate ( const std::string & text,
int32_t sid = 0,
float speed = 1.0,
OfflineTtsCallback callback = nullptr,
void * arg = nullptr ) const

This overload mirrors the legacy/simple TTS API. Prefer the GenerationConfig overload for new code.

◆ Generate2() [1/2]

std::shared_ptr< GeneratedAudio > sherpa_onnx::cxx::OfflineTts::Generate2 ( const std::string & text,
const GenerationConfig & config,
OfflineTtsCallback callback = nullptr,
void * arg = nullptr ) const

◆ Generate2() [2/2]

std::shared_ptr< GeneratedAudio > sherpa_onnx::cxx::OfflineTts::Generate2 ( const std::string & text,
int32_t sid = 0,
float speed = 1.0,
OfflineTtsCallback callback = nullptr,
void * arg = nullptr ) const

◆ Lang()

std::string sherpa_onnx::cxx::OfflineTts::Lang ( ) const

Returns an empty string if such information is not available.

◆ NumSpeakers()

int32_t sherpa_onnx::cxx::OfflineTts::NumSpeakers ( ) const

◆ SampleRate()

int32_t sherpa_onnx::cxx::OfflineTts::SampleRate ( ) const

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