# Where to Find Supertonic Examples: Complete Guide for All Languages

> Find Supertonic examples for Python, Node.js, Java, Go, and more in the supertone-inc/supertonic repository. Discover complete implementations for all your language needs today.

- Repository: [Supertone Inc./supertonic](https://github.com/supertone-inc/supertonic)
- Tags: getting-started
- Published: 2026-06-13

---

**Supertonic examples are located in language-specific directories within the `supertone-inc/supertonic` repository, covering Python, Node.js, Java, Go, C++, C#, Swift, Rust, Flutter, and WebGPU implementations.**

The `supertone-inc/supertonic` repository houses comprehensive Text-to-Speech (TTS) implementation examples across eleven programming languages and platforms. These **Supertonic examples** demonstrate how to perform on-device inference using the ONNX Runtime, with each language directory containing a complete runnable project. The top-level README includes a "Programming Language Support" table that maps each language to its corresponding directory and build requirements.

## Repository Structure and Language Directories

According to the source code, examples are organized under the repository root with the following structure:

- **Python** (`py/`): Contains [`example_onnx.py`](https://github.com/supertone-inc/supertonic/blob/main/example_onnx.py) with UV-managed [`pyproject.toml`](https://github.com/supertone-inc/supertonic/blob/main/pyproject.toml)
- **Node.js** (`nodejs/`): Includes [`example.js`](https://github.com/supertone-inc/supertonic/blob/main/example.js) and a WebGPU-enabled browser demo
- **Browser/WebGPU** (`web/`): Vite-based web app using `onnxruntime-web`
- **Java** (`java/`): Maven project with [`pom.xml`](https://github.com/supertone-inc/supertonic/blob/main/pom.xml) and [`Example.java`](https://github.com/supertone-inc/supertonic/blob/main/Example.java)
- **C++** (`cpp/`): CMake build with [`example_onnx.cpp`](https://github.com/supertone-inc/supertonic/blob/main/example_onnx.cpp)
- **C#** (`csharp/`): .NET 6+ project with `Supertonic.csproj` and [`Program.cs`](https://github.com/supertone-inc/supertonic/blob/main/Program.cs)
- **Go** (`go/`): Go modules with [`example_onnx.go`](https://github.com/supertone-inc/supertonic/blob/main/example_onnx.go)
- **Swift** (`swift/`): SwiftPM package with [`example_onnx.swift`](https://github.com/supertone-inc/supertonic/blob/main/example_onnx.swift)
- **iOS** (`ios/`): Xcode project `ExampleiOSApp` with UI components
- **Rust** (`rust/`): Cargo project with [`example_onnx.rs`](https://github.com/supertone-inc/supertonic/blob/main/example_onnx.rs)
- **Flutter** (`flutter/`): Cross-platform mobile and desktop implementation

Each directory contains a dedicated [`README.md`](https://github.com/supertone-inc/supertonic/blob/main/README.md) with step-by-step build instructions and prerequisites specific to that platform.

## Python Example Implementation

The Python example in [`py/example_onnx.py`](https://github.com/supertone-inc/supertonic/blob/main/py/example_onnx.py) demonstrates the minimal setup required to generate speech. The script uses the `TTS` class with automatic model downloading:

```python
from supertonic import TTS

# Download model on first run

tts = TTS(auto_download=True)

style = tts.get_voice_style(voice_name="M1")
wav, duration = tts.synthesize(
    text="Supertonic is a lightning‑fast, on‑device TTS system.",
    lang="en",
    voice_style=style,
    total_steps=8,
    speed=1.05,
)
tts.save_audio(wav, "output.wav")
print(f"Generated {duration[0]:.2f}s of audio")

```

## JavaScript and Web Browser Examples

### Node.js Example

The Node.js implementation in [`nodejs/example.js`](https://github.com/supertone-inc/supertonic/blob/main/nodejs/example.js) uses the `@supertone/supertonic` package:

```javascript
import { TTS } from '@supertone/supertonic';
const tts = new TTS({ autoDownload: true });

(async () => {
  const voice = await tts.getVoiceStyle('M1');
  const { wav, duration } = await tts.synthesize({
    text: 'Supertonic runs locally with zero network.',
    lang: 'en',
    voiceStyle: voice,
    totalSteps: 8,
    speed: 1.0,
  });
  await tts.saveAudio(wav, 'output.wav');
  console.log(`Created ${duration}s of audio`);
})();

```

### WebGPU Browser Example

For browser-based inference, the [`web/src/main.ts`](https://github.com/supertone-inc/supertonic/blob/main/web/src/main.ts) example leverages WebGPU through `onnxruntime-web`:

```typescript
import { TTS } from '@supertone/supertonic-web';
const tts = new TTS({ autoDownload: true });

async function synthesize() {
  const voice = await tts.getVoiceStyle('M1');
  const { wav } = await tts.synthesize({
    text: 'Supertonic in the browser!',
    lang: 'en',
    voiceStyle: voice,
  });
  // Play the resulting Float32Array in the browser
  const audioCtx = new AudioContext({ sampleRate: 44100 });
  const buffer = audioCtx.createBuffer(1, wav.length, 44100);
  buffer.copyToChannel(wav, 0);
  const source = audioCtx.createBufferSource();
  source.buffer = buffer;
  source.connect(audioCtx.destination);
  source.start();
}
synthesize();

```

## Java and Go Examples

### Java Implementation

The Java example in [`java/src/main/java/Example.java`](https://github.com/supertone-inc/supertonic/blob/main/java/src/main/java/Example.java) uses the Maven build system and Java ONNX Runtime bindings:

```java
import com.supertone.supertonic.TTS;
import com.supertone.supertonic.VoiceStyle;

public class Example {
  public static void main(String[] args) throws Exception {
    TTS tts = new TTS(true); // autoDownload = true
    VoiceStyle style = tts.getVoiceStyle("M1");
    float[] wav = tts.synthesize(
        "Supertonic on Java.", "en", style, 8, 1.0f);
    tts.saveAudio(wav, "output.wav");
    System.out.println("Audio saved.");
  }
}

```

### Go Implementation

The Go example in [`go/example_onnx.go`](https://github.com/supertone-inc/supertonic/blob/main/go/example_onnx.go) demonstrates native module usage:

```go
package main

import (
    "log"
    "supertone/supertonic"
)

func main() {
    tts, err := supertonic.NewTTS(true) // auto download
    if err != nil { log.Fatal(err) }
    style, _ := tts.GetVoiceStyle("M1")
    wav, dur, err := tts.Synthesize("Supertonic in Go.", "en", style, 8, 1.0)
    if err != nil { log.Fatal(err) }
    tts.SaveAudio(wav, "output.wav")
    log.Printf("Generated %.2f seconds", dur)
}

```

## Additional Language Support

Beyond the examples above, the repository includes working implementations for:

- **C++** ([`cpp/example_onnx.cpp`](https://github.com/supertone-inc/supertonic/blob/main/cpp/example_onnx.cpp)): Native ONNX Runtime C++ API with CMake
- **C#** ([`csharp/Program.cs`](https://github.com/supertone-inc/supertonic/blob/main/csharp/Program.cs)): .NET console application using the C# ONNX Runtime wrapper

- **Swift** ([`swift/example_onnx.swift`](https://github.com/supertone-inc/supertonic/blob/main/swift/example_onnx.swift)): SwiftPM package for macOS on-device inference
- **iOS** ([`ios/ExampleiOSApp/ContentView.swift`](https://github.com/supertone-inc/supertonic/blob/main/ios/ExampleiOSApp/ContentView.swift)): Full Xcode project with UI components
- **Rust** ([`rust/src/main.rs`](https://github.com/supertone-inc/supertonic/blob/main/rust/src/main.rs)): Cargo-based project using the Rust ONNX Runtime crate
- **Flutter** (`flutter/lib/main.dart`): Cross-platform mobile and desktop implementation

## Model Assets and Prerequisites

All examples require the ONNX model files and voice presets stored in the `assets/` directory. According to the repository's Prerequisites section (lines 109-121 of the top-level README), you must clone these assets from Hugging Face separately using Git LFS. Each language-specific [`README.md`](https://github.com/supertone-inc/supertonic/blob/main/README.md) details the exact version requirements, such as Java JDK 17 for the Maven project or .NET 9 for the C# implementation.

## Summary

- Supertonic examples are located in language-specific directories under the repository root, including `py/`, `nodejs/`, `web/`, `java/`, `go/`, and seven others.
- Each example follows the same inference pattern: instantiate the `TTS` class with `auto_download` enabled, retrieve a voice style using `get_voice_style()`, call `synthesize()`, and save the output with `save_audio()`.
- The `assets/` directory contains required model files that must be downloaded separately from Hugging Face.
- All examples support zero-network, on-device inference using ONNX Runtime across Python, JavaScript, Java, Go, C++, C#, Swift, Rust, and mobile platforms.

## Frequently Asked Questions

### Where are the Supertonic Python examples located?

The Python examples are located in the `py/` directory at the repository root. The main file [`py/example_onnx.py`](https://github.com/supertone-inc/supertonic/blob/main/py/example_onnx.py) contains a complete inference script using ONNX Runtime, and the directory includes a [`pyproject.toml`](https://github.com/supertone-inc/supertonic/blob/main/pyproject.toml) managed by UV for dependency resolution.

### Do the Supertonic examples require an internet connection?

No. While the examples support automatic model downloading via the `auto_download` parameter (or `autoDownload` in JavaScript), once the assets are cached locally, all inference runs completely offline. The WebGPU browser example also runs entirely client-side after the initial model fetch.

### Which platforms support GPU acceleration in the examples?

The WebGPU example in [`web/src/main.ts`](https://github.com/supertone-inc/supertonic/blob/main/web/src/main.ts) specifically targets browser-based GPU acceleration using `onnxruntime-web`. Other language examples typically use CPU inference by default, though the underlying ONNX Runtime supports GPU execution providers where configured.

### How do I set up the model assets for the examples?

Clone the model assets from Hugging Face using Git LFS into the `assets/` directory as described in the top-level README's Prerequisites section (lines 109-121). Each language-specific README contains additional instructions for linking or loading these assets in the respective build system.