What Are the Core Components of Supertonic?
Supertonic is a multi-language Text-to-Speech library that provides minimal "Helper" modules for each supported programming language, abstracting ONNX inference behind a unified API surface.
Supertonic by supertone-inc/supertonic is a cross-platform TTS solution designed to deliver consistent Text-to-Speech functionality across diverse programming ecosystems. The architecture follows a deliberately minimal design pattern where each language implementation wraps the core ONNX inference workflow. This approach allows developers to switch between languages without rewriting their TTS integration logic.
Language-Specific Helper Modules
The repository organizes code by language, with each directory containing a compact Helper module that handles model loading, tensor preparation, inference execution, and audio post-processing.
Go Implementation
The Go helper is implemented in [go/helper.go](https://github.com/supertone-inc/supertonic/blob/main/go/helper.go). It utilizes the onnxruntime-go bindings to load the ONNX model and return PCM audio data. The module exposes methods like Synthesize() that handle the full inference pipeline from text input to audio output.
Rust Implementation
Located at [rust/src/helper.rs](https://github.com/supertone-inc/supertonic/blob/main/rust/src/helper.rs), the Rust helper wraps the ort crate (ONNX Runtime for Rust). This provides a memory-safe, idiomatic Rust API while maintaining the same public interface as other language implementations.
Python Implementation
The Python helper in [py/helper.py](https://github.com/supertone-inc/supertonic/blob/main/py/helper.py) uses the standard onnxruntime package. It exposes a straightforward synthesize(text) function that abstracts the tensor manipulation and returns raw audio bytes.
Node.js Implementation
Found in [nodejs/helper.js](https://github.com/supertone-inc/supertonic/blob/main/nodejs/helper.js), this JavaScript wrapper leverages onnxruntime-node. It returns audio data as a Float32Array, making it compatible with Web Audio API and Node.js buffer operations.
Java Implementation
The Java API resides in [java/Helper.java](https://github.com/supertone-inc/supertonic/blob/main/java/Helper.java). It provides JNI bindings to ONNX Runtime, exposing a byte[] synthesize(String text) method that handles the native inference calls and returns PCM audio data.
Swift Implementation
For iOS and macOS development, [swift/Sources/Helper.swift](https://github.com/supertone-inc/supertonic/blob/main/swift/Sources/Helper.swift) offers a Swift-friendly wrapper. This implementation uses Apple's MLModel bridge to load the ONNX model and returns Data objects containing PCM audio samples.
C++ Implementation
The native C++ interface consists of [cpp/helper.h](https://github.com/supertone-inc/supertonic/blob/main/cpp/helper.h) and [cpp/helper.cpp](https://github.com/supertone-inc/supertonic/blob/main/cpp/helper.cpp). These files implement the ONNX Runtime C API directly, providing maximum performance for embedded applications and systems programming.
C# Implementation
The .NET helper in [csharp/Helper.cs](https://github.com/supertone-inc/supertonic/blob/main/csharp/Helper.cs) wraps the ONNX Runtime NuGet package. It exposes async synthesis methods that integrate naturally with C# async/await patterns while maintaining parity with the synchronous APIs in other languages.
Flutter Integration
Supertonic does not include a dedicated Dart helper. Instead, the Flutter example demonstrates integration via platform channels, calling the native Android (Java) and iOS (Swift) helpers from Dart code. Configuration details are documented in the [flutter/README.md](https://github.com/supertone-inc/supertonic/blob/main/flutter/README.md).
Shared Architecture and Configuration
All Helper modules rely on the same ONNX model (model.onnx) bundled with repository releases. They share a common configuration schema that defines voice characteristics, sample rates, and inference parameters. This standardization ensures that a synthesize() call in Python produces identical output to a synthesize() call in Rust or Go, given the same input text and configuration.
Implementation Examples
The following examples demonstrate the consistent three-step workflow across languages: instantiate the Helper, call synthesize(), and write the resulting PCM data.
Go Usage
package main
import (
"log"
"os"
"supertonic/go"
)
func main() {
helper, err := go.NewHelper("model.onnx")
if err != nil {
log.Fatalf("init error: %v", err)
}
audio, err := helper.Synthesize("Hello, Supertonic!")
if err != nil {
log.Fatalf("synthesis error: %v", err)
}
_ = os.WriteFile("output.wav", audio, 0644)
}
Python Usage
from supertonic import Helper
helper = Helper("model.onnx")
audio = helper.synthesize("Hello, Supertonic!")
with open("output.wav", "wb") as f:
f.write(audio)
Node.js Usage
const { Helper } = require('supertonic-node');
(async () => {
const helper = new Helper('model.onnx');
const audio = await helper.synthesize('Hello, Supertonic!');
const fs = require('fs');
fs.writeFileSync('output.wav', Buffer.from(audio));
})();
Summary
- Multi-language support: Supertonic provides dedicated Helper modules for Go, Rust, Python, Node.js, Java, Swift, C++, and C#.
- Unified API: Each implementation exposes consistent methods like
synthesize(),runModel(), andsetConfig()across all languages. - ONNX-based: All helpers interface with the same
model.onnxfile using language-specific ONNX Runtime bindings. - Minimal abstraction: Each Helper module is intentionally small, handling only model loading, inference, and audio output.
- Flutter via platform channels: Dart/Flutter integration occurs through native platform channels rather than a dedicated Dart helper.
Frequently Asked Questions
What is the primary purpose of Supertonic's Helper modules?
The Helper modules abstract the complex ONNX inference workflow into simple, language-idiomatic APIs. They handle model initialization, input tensor preparation, inference execution, and audio post-processing, allowing developers to generate speech with minimal code.
How does Supertonic maintain API consistency across different programming languages?
According to the supertone-inc/supertonic source code, each Helper implements the same public method signatures—particularly synthesize(), runModel(), and setConfig()—ensuring that switching from Python to Go or Rust requires only syntax changes, not architectural changes.
Which ONNX Runtime bindings does Supertonic use for different languages?
Supertonic selects language-appropriate ONNX Runtime bindings: onnxruntime-go for Go, the ort crate for Rust, onnxruntime pip package for Python, onnxruntime-node for JavaScript, JNI bindings for Java, the ONNX Runtime C API for C++, and the NuGet package for C#.
Is there a native Dart or Flutter helper in the Supertonic repository?
No, Supertonic does not include a dedicated Dart helper. Instead, the Flutter implementation uses platform channels to invoke the native Java (Android) and Swift (iOS) helpers, as documented in the Flutter example directory.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →