Unity text to speech: voice lines and runtime speech
A Unity game needs voice lines long before it has a voice cast: for prototypes, for placeholder dialogue, for tutorials and for small teams that will never book a studio. Text to speech gives every line a voice the day it is written and redoes it in seconds when the script changes.
The free SuperClonica engine voices text offline on an ordinary processor. This guide shows the two ways to use it with Unity, pre-generated clips and runtime speech from C#, and which voices you can ship.
Two ways to give a Unity game a voice
A player’s computer will not run a speech server, so a shipped single-player game should bundle clips.
- Pre-generated clips: voice every line during development and ship WAV files as ordinary AudioClips. Nothing extra runs on the player’s computer.
- Runtime speech: the game sends text to a SuperClonica server and plays the answer. It suits editor tools, prototypes and online games with their own server.
- Either way, voicing runs on an ordinary processor, with no fee per character.
- The model speaks 31 languages; Chinese is not supported yet.
Pick voices free online
On the page of any voice, type a line of your NPC, 30 to 100 characters, choose the language and press Voice it. In a few seconds you hear whether the voice fits the character, with no account.
Pre-generate the dialogue
The same text, voice and seed always give the same audio, so regenerate only the lines that changed and commit the script, not the audio.
- Install the engine: python -m pip install superclonica-cpu.
- Keep the lines in a table with an id, a language and the text.
- A short script loops over it: superclonica --text "Welcome to the village!" --voice npc.json --lang en --output Assets/Audio/Lines/npc_greeting_01.wav.
- Unity imports new WAV files under Assets on its own; use Decompress On Load for short lines and Streaming for long narration.
Speak at runtime from C#
Start the server on any processor: docker run -d -p 8000:8000 -v superclonica-models:/models superclonica/superclonica:cpu. Then call it with the built-in UnityWebRequest, no package needed: [Serializable] class Line { public string text; public string voice; public string lang; } — then, in a coroutine: var req = new UnityWebRequest("http://localhost:8000/synthesize", "POST"); req.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(JsonUtility.ToJson(new Line { text = "Welcome back!", voice = "F1", lang = "en" }))); req.downloadHandler = new DownloadHandlerAudioClip(req.url, AudioType.WAV); req.SetRequestHeader("Content-Type", "application/json"); yield return req.SendWebRequest(); source.PlayOneShot(DownloadHandlerAudioClip.GetContent(req)); A short phrase takes about half a second on a processor; cache the clips of lines that repeat. Never ship an API key inside a game build, where players can extract it: let your own game server call the speech server.
Voices you can ship
For prototypes, any catalog voice is fine. For a released game, use a voice you have the rights to: the ten stock voices of the model, M1 to M5 and F1 to F5, or your own voice trained in the SuperClonica studio from a clean 5 to 10 second recording of an actor who agreed, on a computer with an NVIDIA graphics card, or a custom voice ordered on the exchange. Fan-made character voices are for parody and fan games, not for commercial ones.