supertonic-3-vi
| Info about this model | Download the model | Android APK | Python API | C API |
| C++ API | Rust API | Node.js API | Dart API | Swift API |
| C# API | Kotlin API | Java API | Pascal API | Go API |
| Samples |
Info about this model
This model is supertonic 3 from https://huggingface.co/Supertone/supertonic-3
It supports 31 languages: en, ko, ja, ar, bg, cs, da, de, el, es, et, fi, fr, hi, hr, hu, id, it, lt, lv, nl, pl, pt, ro, ru, sk, sl, sv, tr, uk, vi.
This page shows samples for Vietnamese (vi).
| Number of speakers | Sample rate |
|---|---|
| 10 | 24000 |
Speaker IDs
| sid | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
|---|
Download the model
Click to expand
Model download address
Android APK
Click to expand
The following table shows the Android TTS Engine APK with this model for sherpa-onnx v1.13.2
If you don’t know what ABI is, you probably need to select
arm64-v8a.
The source code for the APK can be found at
https://github.com/k2-fsa/sherpa-onnx/tree/master/android/SherpaOnnxTtsEngine
Please refer to the documentation for how to build the APK from source code.
More Android APKs can be found at
Python API
Click to expand
Assume you have installed sherpa-onnx via
pip install sherpa-onnx
and you have downloaded the model from
You can use the following code to play with supertonic-3
import sherpa_onnx
import soundfile as sf
tts_config = sherpa_onnx.OfflineTtsConfig(
model=sherpa_onnx.OfflineTtsModelConfig(
supertonic=sherpa_onnx.OfflineTtsSupertonicModelConfig(
duration_predictor="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx",
text_encoder="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx",
vector_estimator="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx",
vocoder="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx",
tts_json="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json",
unicode_indexer="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin",
voice_style="sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin",
),
debug=False,
num_threads=2,
provider="cpu",
),
)
tts = sherpa_onnx.OfflineTts(tts_config)
gen_config = sherpa_onnx.GenerationConfig()
gen_config.sid = 0
gen_config.num_steps = 8
gen_config.speed = 1.0
gen_config.extra["lang"] = "vi"
audio = tts.generate("Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo", gen_config)
sf.write("test.wav", audio.samples, samplerate=audio.sample_rate)
C API
Click to expand
You can use the following code to play with supertonic-3 with C API.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sherpa-onnx/c-api/c-api.h"
static int32_t ProgressCallback(const float *samples, int32_t num_samples,
float progress, void *arg) {
fprintf(stderr, "Progress: %.3f%%\n", progress * 100);
// return 1 to continue generating
// return 0 to stop generating
return 1;
}
int32_t main(int32_t argc, char *argv[]) {
SherpaOnnxOfflineTtsConfig config;
memset(&config, 0, sizeof(config));
config.model.supertonic.duration_predictor = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx";
config.model.supertonic.text_encoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx";
config.model.supertonic.vector_estimator = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx";
config.model.supertonic.vocoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx";
config.model.supertonic.tts_json = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json";
config.model.supertonic.unicode_indexer = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin";
config.model.supertonic.voice_style = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin";
config.model.num_threads = 2;
// If you don't want to see debug messages, please set it to 0
config.model.debug = 1;
const char *text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo";
const SherpaOnnxOfflineTts *tts = SherpaOnnxCreateOfflineTts(&config);
SherpaOnnxGenerationConfig gen_cfg;
memset(&gen_cfg, 0, sizeof(gen_cfg));
gen_cfg.sid = 0;
gen_cfg.num_steps = 8;
gen_cfg.speed = 1.0;
gen_cfg.extra = "{\"lang\": \"vi\"}";
const SherpaOnnxGeneratedAudio *audio =
SherpaOnnxOfflineTtsGenerateWithConfig(tts, text, &gen_cfg,
ProgressCallback, NULL);
SherpaOnnxWriteWave(audio->samples, audio->n, audio->sample_rate,
"./test.wav");
// You need to free the pointers to avoid memory leak in your app
SherpaOnnxDestroyOfflineTtsGeneratedAudio(audio);
SherpaOnnxDestroyOfflineTts(tts);
printf("Saved to ./test.wav\n");
return 0;
}
Use shared library (dynamic link)
cd /tmp
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
mkdir build-shared
cd build-shared
cmake \
-DSHERPA_ONNX_ENABLE_C_API=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared \
..
make
make install
You can find required header file and library files inside /tmp/sherpa-onnx/shared.
Assume you have saved the above example file as /tmp/test-supertonic.c.
Then you can compile it with the following command:
gcc \
-I /tmp/sherpa-onnx/shared/include \
-L /tmp/sherpa-onnx/shared/lib \
-lsherpa-onnx-c-api \
-lonnxruntime \
-o /tmp/test-supertonic \
/tmp/test-supertonic.c
Now you can run
cd /tmp
# Assume you have downloaded the model and extracted it to /tmp
./test-supertonic
You probably need to run
# For Linux export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH # For macOS export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATHbefore you run
/tmp/test-supertonic.
Use static library (static link)
Please see the documentation at
C++ API
Click to expand
You can use the following code to play with supertonic-3 with C++ API.
#include <cstdint>
#include <cstdio>
#include <string>
#include "sherpa-onnx/c-api/cxx-api.h"
static int32_t ProgressCallback(const float *samples, int32_t num_samples,
float progress, void *arg) {
fprintf(stderr, "Progress: %.3f%%\n", progress * 100);
// return 1 to continue generating
// return 0 to stop generating
return 1;
}
int32_t main(int32_t argc, char *argv[]) {
using namespace sherpa_onnx::cxx; // NOLINT
OfflineTtsConfig config;
config.model.supertonic.duration_predictor = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx";
config.model.supertonic.text_encoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx";
config.model.supertonic.vector_estimator = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx";
config.model.supertonic.vocoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx";
config.model.supertonic.tts_json = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json";
config.model.supertonic.unicode_indexer = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin";
config.model.supertonic.voice_style = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin";
config.model.num_threads = 2;
// If you don't want to see debug messages, please set it to 0
config.model.debug = 1;
std::string filename = "./test.wav";
std::string text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo";
auto tts = OfflineTts::Create(config);
GenerationConfig gen_cfg;
gen_cfg.sid = 0;
gen_cfg.num_steps = 8;
gen_cfg.speed = 1.0; // larger -> faster in speech speed
gen_cfg.extra = R"({"lang": "vi"})";
GeneratedAudio audio = tts.Generate(text, gen_cfg, ProgressCallback);
WriteWave(filename, {audio.samples, audio.sample_rate});
fprintf(stderr, "Input text is: %s\n", text.c_str());
fprintf(stderr, "Speaker ID is: %d\n", gen_cfg.sid);
fprintf(stderr, "Saved to: %s\n", filename.c_str());
return 0;
}
Use shared library (dynamic link)
cd /tmp
git clone https://github.com/k2-fsa/sherpa-onnx
cd sherpa-onnx
mkdir build-shared
cd build-shared
cmake \
-DSHERPA_ONNX_ENABLE_C_API=ON \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_INSTALL_PREFIX=/tmp/sherpa-onnx/shared \
..
make
make install
You can find required header file and library files inside /tmp/sherpa-onnx/shared.
Assume you have saved the above example file as /tmp/test-supertonic.cc.
Then you can compile it with the following command:
g++ \
-std=c++17 \
-I /tmp/sherpa-onnx/shared/include \
-L /tmp/sherpa-onnx/shared/lib \
-lsherpa-onnx-cxx-api \
-lsherpa-onnx-c-api \
-lonnxruntime \
-o /tmp/test-supertonic \
/tmp/test-supertonic.cc
Now you can run
cd /tmp
# Assume you have downloaded the model and extracted it to /tmp
./test-supertonic
You probably need to run
# For Linux export LD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$LD_LIBRARY_PATH # For macOS export DYLD_LIBRARY_PATH=/tmp/sherpa-onnx/shared/lib:$DYLD_LIBRARY_PATHbefore you run
/tmp/test-supertonic.
Use static library (static link)
Please see the documentation at
Rust API
Click to expand
You can use the following code to play with supertonic-3 with Rust API.
use sherpa_onnx::{
GenerationConfig, OfflineTts, OfflineTtsConfig, OfflineTtsSupertonicModelConfig,
};
fn main() {
let config = OfflineTtsConfig {
model: sherpa_onnx::OfflineTtsModelConfig {
supertonic: OfflineTtsSupertonicModelConfig {
duration_predictor: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx".into()),
text_encoder: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx".into()),
vector_estimator: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx".into()),
vocoder: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx".into()),
tts_json: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json".into()),
unicode_indexer: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin".into()),
voice_style: Some("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin".into()),
..Default::default()
},
num_threads: 2,
debug: false,
..Default::default()
},
..Default::default()
};
let tts = OfflineTts::create(&config).expect("Failed to create OfflineTts");
println!("Sample rate: {}", tts.sample_rate());
println!("Num speakers: {}", tts.num_speakers());
let text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo";
let gen_config = GenerationConfig {
sid: 0,
num_steps: 8,
speed: 1.0,
extra: Some(r#"{"lang": "vi"}"#.into()),
..Default::default()
};
let audio = tts
.generate_with_config(
text,
&gen_config,
Some(|_samples: &[f32], progress: f32| -> bool {
println!("Progress: {:.1}%", progress * 100.0);
true
}),
)
.expect("Generation failed");
let filename = "./test.wav";
if audio.save(filename) {
println!("Saved to: {}", filename);
} else {
eprintln!("Failed to save {}", filename);
}
}
Please refer to the Rust API documentation for how to build and run the above Rust example.
Node.js (addon) API
Click to expand
You need to install the sherpa-onnx-node npm package first:
npm install sherpa-onnx-node
You can use the following code to play with supertonic-3 with the Node.js addon API.
const sherpa_onnx = require('sherpa-onnx-node');
function createOfflineTts() {
const config = {
model: {
supertonic: {
durationPredictor: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx',
textEncoder: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx',
vectorEstimator: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx',
vocoder: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx',
ttsJson: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json',
unicodeIndexer: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin',
voiceStyle: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin',
},
debug: true,
numThreads: 2,
provider: 'cpu',
},
};
return new sherpa_onnx.OfflineTts(config);
}
const tts = createOfflineTts();
const text = 'Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo';
const generationConfig = new sherpa_onnx.GenerationConfig({
sid: 0,
numSteps: 8,
speed: 1.0,
extra: {lang: 'vi'},
});
let start = Date.now();
const audio = tts.generate({text, generationConfig});
let stop = Date.now();
const elapsed_seconds = (stop - start) / 1000;
const duration = audio.samples.length / audio.sampleRate;
const real_time_factor = elapsed_seconds / duration;
console.log('Wave duration', duration.toFixed(3), 'seconds');
console.log('Elapsed', elapsed_seconds.toFixed(3), 'seconds');
console.log(
`RTF = ${elapsed_seconds.toFixed(3)}/${duration.toFixed(3)} =`,
real_time_factor.toFixed(3));
const filename = 'test.wav';
sherpa_onnx.writeWave(
filename, {samples: audio.samples, sampleRate: audio.sampleRate});
console.log(`Saved to ${filename}`);
Please refer to the Node.js addon API documentation for more details.
Dart API
Click to expand
You can use the following code to play with supertonic-3 with Dart API.
import 'package:sherpa_onnx/sherpa_onnx.dart' as sherpa_onnx;
void main() {
final supertonic = sherpa_onnx.OfflineTtsSupertonicModelConfig(
durationPredictor: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx',
textEncoder: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx',
vectorEstimator: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx',
vocoder: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx',
ttsJson: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json',
unicodeIndexer: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin',
voiceStyle: 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin',
);
final modelConfig = sherpa_onnx.OfflineTtsModelConfig(
supertonic: supertonic,
numThreads: 2,
debug: true,
);
final config = sherpa_onnx.OfflineTtsConfig(
model: modelConfig,
);
final tts = sherpa_onnx.OfflineTts(config);
final genConfig = sherpa_onnx.OfflineTtsGenerationConfig(
sid: 0,
numSteps: 8,
speed: 1.0,
extra: {'lang': 'vi'},
);
final audio = tts.generateWithConfig(text: 'Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo', config: genConfig);
tts.free();
sherpa_onnx.writeWave(
filename: 'test.wav',
samples: audio.samples,
sampleRate: audio.sampleRate,
);
print('Saved to test.wav');
}
Please refer to the Dart API documentation for more details.
Swift API
Click to expand
You can use the following code to play with supertonic-3 with Swift API.
func run() {
let supertonic = sherpaOnnxOfflineTtsSupertonicModelConfig(
durationPredictor: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx",
textEncoder: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx",
vectorEstimator: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx",
vocoder: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx",
ttsJson: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json",
unicodeIndexer: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin",
voiceStyle: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin"
)
let modelConfig = sherpaOnnxOfflineTtsModelConfig(supertonic: supertonic)
var ttsConfig = sherpaOnnxOfflineTtsConfig(model: modelConfig)
let tts = SherpaOnnxOfflineTtsWrapper(config: &ttsConfig)
let text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo"
var genConfig = SherpaOnnxGenerationConfigSwift()
genConfig.sid = 0
genConfig.numSteps = 8
genConfig.speed = 1.0
genConfig.extra = ["lang": "vi"]
let audio = tts.generateWithConfig(text: text, config: genConfig, callback: nil, arg: nil)
let filename = "test.wav"
let ok = audio.save(filename: filename)
if ok == 1 {
print("Saved to \(filename)")
} else {
print("Failed to save \(filename)")
}
}
@main
struct App {
static func main() {
run()
}
}
Please refer to the Swift API documentation for more details.
C# API
Click to expand
You can use the following code to play with supertonic-3 with C# API.
using SherpaOnnx;
var config = new OfflineTtsConfig();
config.Model.Supertonic.DurationPredictor = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx";
config.Model.Supertonic.TextEncoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx";
config.Model.Supertonic.VectorEstimator = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx";
config.Model.Supertonic.Vocoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx";
config.Model.Supertonic.TtsJson = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json";
config.Model.Supertonic.UnicodeIndexer = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin";
config.Model.Supertonic.VoiceStyle = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin";
config.Model.NumThreads = 2;
config.Model.Debug = 1;
config.Model.Provider = "cpu";
var tts = new OfflineTts(config);
var text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo";
OfflineTtsGenerationConfig genConfig = new OfflineTtsGenerationConfig();
genConfig.Sid = 0;
genConfig.NumSteps = 8;
genConfig.Speed = 1.0f;
genConfig.Extra = "{\"lang\": \"vi\"}";
var audio = tts.GenerateWithConfig(text, genConfig, null);
var ok = audio.SaveToWaveFile("./test.wav");
if (ok)
{
Console.WriteLine("Saved to ./test.wav");
}
else
{
Console.WriteLine("Failed to save ./test.wav");
}
Please refer to the C# API documentation for more details.
Kotlin API
Click to expand
You can use the following code to play with supertonic-3 with Kotlin API.
package com.k2fsa.sherpa.onnx
fun main() {
var config = OfflineTtsConfig(
model = OfflineTtsModelConfig(
supertonic = OfflineTtsSupertonicModelConfig(
durationPredictor = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx",
textEncoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx",
vectorEstimator = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx",
vocoder = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx",
ttsJson = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json",
unicodeIndexer = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin",
voiceStyle = "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin",
),
numThreads = 2,
debug = true,
),
)
val tts = OfflineTts(config = config)
val genConfig = GenerationConfig(
sid = 0,
numSteps = 8,
speed = 1.0f,
extra = mapOf("lang" to "vi"),
)
val audio = tts.generateWithConfigAndCallback(
text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo",
config = genConfig,
callback = ::callback,
)
audio.save(filename = "test.wav")
tts.release()
println("Saved to test.wav")
}
fun callback(samples: FloatArray): Int {
// 1 means to continue
// 0 means to stop
return 1
}
Please refer to the Kotlin API documentation for more details.
Java API
Click to expand
You can use the following code to play with supertonic-3 with Java API.
import com.k2fsa.sherpa.onnx.*;
public class TtsDemo {
public static void main(String[] args) {
var supertonic = new OfflineTtsSupertonicModelConfig();
supertonic.setDurationPredictor("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx");
supertonic.setTextEncoder("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx");
supertonic.setVectorEstimator("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx");
supertonic.setVocoder("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx");
supertonic.setTtsJson("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json");
supertonic.setUnicodeIndexer("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin");
supertonic.setVoiceStyle("sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin");
var modelConfig = new OfflineTtsModelConfig();
modelConfig.setSupertonic(supertonic);
modelConfig.setNumThreads(2);
modelConfig.setDebug(true);
var config = new OfflineTtsConfig();
config.setModel(modelConfig);
var tts = new OfflineTts(config);
var text = "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo";
var genConfig = new GenerationConfig();
genConfig.setSid(0);
genConfig.setNumSteps(8);
genConfig.setSpeed(1.0f);
genConfig.setExtra("{\"lang\": \"vi\"}");
var audio = tts.generateWithConfigAndCallback(text, genConfig, (samples) -> {
// 1 means to continue, 0 means to stop
return 1;
});
audio.save("test.wav");
tts.release();
System.out.println("Saved to test.wav");
}
}
Please refer to the Java API documentation for more details.
Pascal API
Click to expand
You can use the following code to play with supertonic-3 with Pascal API.
program test_supertonic;
{$mode objfpc}
uses
SysUtils,
sherpa_onnx;
var
Config: TSherpaOnnxOfflineTtsConfig;
Tts: TSherpaOnnxOfflineTts;
Audio: TSherpaOnnxGeneratedAudio;
GenConfig: TSherpaOnnxGenerationConfig;
begin
FillChar(Config, SizeOf(Config), 0);
Config.Model.Supertonic.DurationPredictor := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx';
Config.Model.Supertonic.TextEncoder := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx';
Config.Model.Supertonic.VectorEstimator := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx';
Config.Model.Supertonic.Vocoder := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx';
Config.Model.Supertonic.TtsJson := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json';
Config.Model.Supertonic.UnicodeIndexer := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin';
Config.Model.Supertonic.VoiceStyle := 'sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin';
Config.Model.NumThreads := 2;
Config.Model.Debug := True;
Tts := TSherpaOnnxOfflineTts.Create(@Config);
GenConfig.Sid := 0;
GenConfig.NumSteps := 8;
GenConfig.Speed := 1.0;
GenConfig.Extra := '{"lang": "vi"}';
Audio := Tts.GenerateWithConfig('Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo', @GenConfig, nil);
WriteWave('./test.wav', Audio.Samples, Audio.N, Audio.SampleRate);
WriteLn('Saved to ./test.wav');
Audio.Free;
Tts.Free;
end.
Please refer to the Pascal API documentation for more details.
Go API
Click to expand
You can use the following code to play with supertonic-3 with Go API.
package main
import (
"fmt"
sherpa "github.com/k2-fsa/sherpa-onnx-go/sherpa_onnx"
)
func main() {
config := sherpa.OfflineTtsConfig{
Model: sherpa.OfflineTtsModelConfig{
Supertonic: sherpa.OfflineTtsSupertonicModelConfig{
DurationPredictor: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/duration_predictor.int8.onnx",
TextEncoder: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/text_encoder.int8.onnx",
VectorEstimator: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vector_estimator.int8.onnx",
Vocoder: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/vocoder.int8.onnx",
TtsJson: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/tts.json",
UnicodeIndexer: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/unicode_indexer.bin",
VoiceStyle: "sherpa-onnx-supertonic-3-tts-int8-2026-05-11/voice.bin",
},
NumThreads: 2,
Debug: true,
},
}
tts := sherpa.NewOfflineTts(&config)
defer tts.Delete()
text := "Đây là công cụ chuyển văn bản thành giọng nói sử dụng kaldi thế hệ tiếp theo"
genConfig := sherpa.GenerationConfig{
Sid: 0,
NumSteps: 8,
Speed: 1.0,
Extra: `{"lang": "vi"}`,
}
audio := tts.GenerateWithConfig(text, &genConfig, nil)
filename := "./test.wav"
sherpa.WriteWave(filename, audio.Samples, audio.SampleRate)
fmt.Printf("Saved to %s\n", filename)
}
Please refer to the Go API documentation for more details.
Samples
sample audios for different speakers are listed below:
Speaker 0
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 1
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 2
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 3
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 4
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 5
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 6
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 7
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 8
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.
Speaker 9
0
Xin chào thế giới.
1
Hôm nay bạn thế nào?
2
Bầu trời xanh và gió rất nhẹ.
3
Học máy giúp máy tính học từ dữ liệu.
4
Tổng hợp giọng nói chuyển văn bản thành âm thanh rõ ràng.
5
Học sinh đọc một câu chuyện ngắn trong thư viện.
6
Tàu bị trễ vì công việc bảo trì đường ray.
7
Các mô hình nhỏ chạy nhanh trên thiết bị cục bộ.
8
Trợ lý giọng nói hỗ trợ các công việc hằng ngày.
9
Việc đọc ổn định rất quan trọng cho câu ngắn và câu dài.