Unity
A UPM package for Unity 2022.3 LTS and later (Unity 6 included) on Windows, macOS, Linux and Android. Audio is generated at runtime; nothing is drawn by the package.
Manual verification in progress
The C# interop layer is tested in CI with .NET against the native library. The parts that need the Unity editor (components, sample, TextMeshPro typewriter) are being checked by hand with this guide.
Install
Install the package that carries the native libraries. From OpenUPM, with the openupm CLI:
openupm add com.mumble-speech.unityOr in Unity: Package Manager → + → Add package from git URL…
https://github.com/basteez/mumble-speech.git#upmAppend a tag to pin a version, for example #upm/v0.3.0. The upm branch holds the complete package with its native plugins, and every release also has it as a tarball (Add package from tarball…).
From source
bindings/unity in a source checkout (git clone or Download ZIP) contains no native libraries: its Plugins/ folders are empty, and the first call throws a DllNotFoundException naming the missing file and the folder it belongs in. That folder is for contributors, who build the library first.
macOS, Linux, and Windows with Git Bash or MSYS2 (needs Rust):
bindings/unity/build.shWindows without a POSIX shell (PowerShell, from the repository root):
cargo build -p mumble-ffi --release
Copy-Item target\release\mumble_ffi.dll bindings\unity\Plugins\Windows\x86_64\Then Package Manager → + → Add package from disk… and pick bindings/unity/package.json. Build before adding the folder to a project: otherwise Unity may drop the plugins' .meta files, and with them the platform settings.
Android
The package carries the native library for arm64-v8a, armeabi-v7a and x86_64 (Plugins/Android/libs/<abi>/), for Android 5.0 (API level 21) or later. Nothing to configure: build your project for Android and the player includes the library of each architecture you select in Player Settings → Other Settings → Target Architectures.
- Unity needs the IL2CPP scripting backend to build for ARM64, which Google Play requires; ARMv7 works with Mono or IL2CPP.
- The libraries are linked with 16 KB page alignment, as Google Play requires for apps targeting Android 15 and later.
- 32-bit
x86is not included, and iOS is not supported yet. - The libraries are built and checked in CI (exported functions, architecture, alignment, dependencies), but have not been run on a device yet: see the testing guide (U6–U8) and please report what you find.
To build the Android libraries from source (Rust, the Android NDK r27 or later and cargo install cargo-ndk --locked): ANDROID_NDK_HOME=<ndk> bindings/unity/build.sh android.
Use
using MumbleSpeech;
// A GameObject with an AudioSource and a MumbleSpeaker.
speaker.voice = myVoice; // Assets → Create → Mumble Speech → Voice
speaker.onCharacter.AddListener(i => Debug.Log(i)); // UTF-16 index being heard
speaker.onFinished.AddListener(() => Debug.Log("done"));
speaker.Say("Hello there!");
// Typewriter dialogue with TextMeshPro (compiled only when TMP is installed).
typewriter.label = tmpText;
typewriter.speaker = speaker;
typewriter.TypeText("Guh-huh! Did you bring the honey?");Types
| Type | Members |
|---|---|
MumbleVoice (ScriptableObject) | style, pitch, speed, variation, seed |
MumbleSpeaker (MonoBehaviour) | voice; Say, SpeakCharacter → seconds to wait, ResetSpeaker, Stop, IsSpeaking; onCharacter, onFinished |
MumbleTypewriterTMP (MonoBehaviour) | label, speaker; TypeText, Skip, IsTyping; onFinished |
Mumble (static, plain C#) | Render(text, settings, sampleRate), EncodeWav, NativeAbiVersion |
Speaker (plain C#, IDisposable) | Next(text) → samples, advance, sound; Reset |
MumbleSpeaker always synthesizes at Mumble.SpeakerSampleRate (48,000 Hz), whatever the output rate of the device (Project Settings → Audio → System Sample Rate), and Unity resamples the clip on playback; nothing is resampled on a 48 kHz output. A line therefore gives the same samples on every machine (bit-identity holds for the same text, voice and sample rate; what the player hears is identical up to Unity's resampler, which the library does not control). For another rate, call Mumble.Render with an explicit sampleRate.
Mumble and Speaker live in the MumbleSpeech.Core assembly, which has no UnityEngine reference: you can use them from any C# code. Events carry CharIndex and CharLength (UTF-16, so they index C# strings), Style and Variant.