Text-to-speech · Synthesize multilingual speech with Supertonic3 / 5

Synthesize multilingual speech with Supertonic

Example on GitHub(packages/sdk/examples/tts/supertonic-multilingual.ts)

Now that we can synthesize English with Supertonic, we're going to add languages. Supertonic 3 covers 31 languages from a single multilingual GGUF.

The load matches the English Supertonic setup. The only field that changes is language:

const modelId = await loadModel({
  modelSrc: TTS_MULTILINGUAL_SUPERTONIC3_Q8_0,
  modelConfig: {
    ttsEngine: "supertonic",
    language: "es",
    voice: "F1",
    ttsSpeed: 1.05,
    ttsNumInferenceSteps: 5,
  },
});

The voices are language-agnostic. F1 is a female voice, F2 a second female voice, M1 and M2 male voices. The same voice ID reads out the text in whatever language modelConfig.language selects. Switching from "es" to "fr" gives you the same voice reading French.

Same synth-call signature, with language: "es" carried into the options. Consider the following synth call:

const result = textToSpeech({
  modelId,
  text: "Hola mundo. Esta es una demostración de síntesis de voz con Supertonic en español.",
  inputType: "text",
  stream: false,
});
const audioBuffer = await result.buffer;
console.log(`▸ TTS complete. Total samples: ${audioBuffer.length}`);

Note: language codes that aren't in the Supertonic model's vocabulary fall back to English. If you need a specific dialect or regional accent, check the upstream Supertonic docs for the supported language list.

Questions

Question 1 of 2

What's the relationship between a Supertonic voice ID like F1 and modelConfig.language?

Question 2 of 2

What happens if you pass a language code that isn't in Supertonic's vocabulary?

index.ts
Loading editor...

Run your code, check your answer, or ask a question. It all shows up here.