fdemelo/open-supertonic2-pytorch
PyTorch implementation and voice cloning encoders for Supertonic 2
2 min readupdated
The repository contains everything needed to run and train the Supertonic 2 speech generation (TTS) pipeline in PyTorch. The author created an independent implementation and added three missing modules for zero-shot voice cloning from a few seconds of audio: a speech encoder, as well as TTL and DP style token encoders. The official release offers only ten preset voices as fixed embeddings, whereas the new encoders compute the exact same embeddings from arbitrary audio and output a JSON format compatible with the official ONNX runtime. The model will be useful for researchers and voice assistant developers who need fast voice cloning.
Key features
- Voice encoders: Three newly trained modules for extracting style embeddings from a short speech sample.
- Exact compatibility: Converted modules reproduce official ONNX outputs (waveforms match with a tolerance of up to 1e-6).
- Full PyTorch pipeline: Code for inference, training, and evaluation of models based on PyTorch.
- Multilingual support: Support for English, Spanish, French, Korean, and Portuguese languages.
What you can do
- Voice cloning: Extract style from 3–10 seconds of clean speech from any speaker into a JSON file for subsequent generation.
- Speech synthesis: Generate audio from text using the obtained voice style.
- Training and fine-tuning: Use the speech encoder and architecture components for experiments with speech generation.
Example
Example of inference with voice cloning and speech generation using a Python script:
import torch, torchaudio
from supertonic_tts.models.speech_generator import SpeechGenerator
from supertonic_tts.models.modules.text_vectorizer import TextVectorizer
pt = "supertonic2-pytorch/pt"
gen = SpeechGenerator(); gen.load_from_pt(pt); gen.eval()
encoder = torch.load(f"{pt}/speech-encoder.pt", weights_only=False).eval()
vocoder = torch.load(f"{pt}/vocoder.pt", weights_only=False).eval()
wav, sr = torchaudio.load("speaker.wav")
wav = torchaudio.functional.resample(wav.mean(0, keepdim=True), sr, 44100)
style = gen.encode_voice_style(wav, speech_encoder=encoder)
style.save("speaker.json")
Read more
DetailsBenchmarks (SIM-o): clean reference 0.796, degraded reference 0.790 (best preset is 0.786).
Requirements: weights contain model files ranging from 0.34 M to 33.1 M parameters.
Limitations: a strong deviation of the voice from the preset distribution or poor archival recordings can reduce cloning quality.
License: BigScience Open RAIL-M License (with restrictions on use in Attachment A).










Comments