Skip to content

Pisco and Vodka Integration

buntatoes edited this page Nov 29, 2026 · 2 revisions

Pisco and Vodka Integration

Tonic serves as the standalone Apache-2.0 SAPI 5 speech layer for Pisco and Vodka, replacing GPL-3.0 espeak-ng and prebuilt onnxruntime binaries with a pure-Zig, zero-Python, patent-free speech engine.


How Pisco Builds and Packages Tonic

In Pisco's Makefile.in, Tonic is tracked as a git submodule (tonic/, stable branch) and built directly via the tonic target (included in all-dist and default_pfx):

  1. Runs zig build -Doptimize=ReleaseSafe inside tonic/.
  2. Copies all three cross-compiled Windows PE sapi.dll binaries into Pisco's distribution tree:
    • files/lib/vodka/tonic/x86_64-windows/sapi.dll
    • files/lib/vodka/tonic/i386-windows/sapi.dll
    • files/lib/vodka/tonic/aarch64-windows/sapi.dll
  3. Copies the native Linux shared library and CLI tool:
    • files/lib/libtonic.so
    • files/bin/tonic
  4. Records the Tonic submodule revision into files/lib/vodka/tonic/version.

To rebuild only Tonic inside an existing Pisco build directory:

make tonic

Prefix Symlinking & Loader Routing in Pisco

Pisco wires Tonic automatically into every game prefix and launch environment:

1. Default Prefix (zig/src/default_pfx.zig)

During default_pfx generation, setupTonicSymlinks links Tonic's multi-architecture sapi.dll binaries directly into the prefix's Windows system directories:

  • drive_c/windows/system32/sapi.dll -> files/lib/vodka/tonic/x86_64-windows/sapi.dll (or aarch64-windows on ARM64 builds)
  • drive_c/windows/syswow64/sapi.dll -> files/lib/vodka/tonic/i386-windows/sapi.dll

2. Launcher Environment (zig/src/pisco/main.zig)

At game launch, the pisco launcher:

  • Prepends Tonic to VODKADLLPATH:
    • Default graphics path: files/lib/vodka/bitters:files/lib/vodka/tonic:files/lib/vodka
    • Fallback graphics path (PROTON_USE_VODKAGFX=1): files/lib/vodka/tonic:files/lib/vodka
  • Copies/links sapi.dll into the per-game prefix's system32 and syswow64 directories alongside tracked prefix files.
  • Injects the native DLL override: Adds sapi=n to VODKADLLOVERRIDES automatically unless the user explicitly specifies a custom sapi=... override.

Overriding or Disabling Tonic in Steam Launch Options

# Force Tonic's built-in formant synthesizer (skip host speech-dispatcher probe)
TONIC_NO_HOST_SPEECH=1 %command%

# Mute SAPI 5 waveOut playback while keeping SAPI COM calls functional
TONIC_NO_AUDIO_PLAYBACK=1 %command%

# Disable SAPI 5 WinMM microphone capture
TONIC_NO_MIC_CAPTURE=1 %command%

# Override sapi.dll resolution explicitly via Vodka DLL overrides
VODKADLLOVERRIDES="sapi=b" %command%

Runtime Execution Under Vodka

When a Windows game or application running under Vodka creates a SAPI 5 COM object (CLSID_SpVoice, CLSID_SpInprocRecognizer, CLSID_SpSharedRecognizer, CLSID_SpObjectTokenCategory, or CLSID_SpObjectToken):

Windows Title (PE64 or CS=0x23 WoW64 PE32)
  │  CoCreateInstance -> sapi.dll!DllGetClassObject
  ▼
Tonic sapi.dll (freestanding Windows PE, link_libc = false)
  ├── TTS Playback:  winmm.dll (waveOutOpen/Write @ 22050 Hz mono)
  ├── ASR Capture:   winmm.dll (waveInOpen/AddBuffer @ 16000 Hz mono)
  ├── Notifications: user32.dll (PostMessageW), kernel32.dll (CreateEventW)
  └── COM Memory:    ole32.dll (CoTaskMemAlloc / CoTaskMemFree)
        │
        ▼
Vodka Runtime (libvodka_ntdll.so + Win32 DLLs + libvodka_audio.so)
  └── PipeWire (primary) -> ALSA (fallback) -> Software Sink (headless)
  • Because sapi.dll resolves winmm.dll, user32.dll, and ole32.dll dynamically via LoadLibraryA and GetProcAddress, it integrates cleanly with Vodka's PE64 and hardware CS=0x23 PE32/WoW64 loaders without static import dependency bloat.
  • Audio played through ISpVoice or captured through ISpRecognizer flows through Vodka's winmm.dll and libvodka_audio.so directly to PipeWire or ALSA on Linux.

Standalone Usage with Vodka (Without Pisco)

To test a freshly built sapi.dll directly inside a standalone Vodka prefix:

# Build Tonic
zig build -Doptimize=ReleaseSafe

# Point Vodka's DLL search path at Tonic's output directory and enable native sapi.dll
VODKAPREFIX=~/.vodka \
VODKADLLPATH="/path/to/tonic/zig-out/lib/tonic:/path/to/vodka/zig-out/lib/vodka" \
VODKADLLOVERRIDES="sapi=n" \
  /path/to/vodka/zig-out/bin/vodka your_sapi_app.exe

You can also place x86_64-windows/sapi.dll in $VODKAPREFIX/drive_c/windows/system32/sapi.dll and i386-windows/sapi.dll in $VODKAPREFIX/drive_c/windows/syswow64/sapi.dll for persistent per-prefix testing.