# MicroslopSam Run SAPI4 text-to-speech voices on Linux. Primary approach: a **Winelib host** — a native Linux ELF that uses Wine's libraries to load the original 32-bit SAPI4 runtime and TTS engine DLLs. Voice targets: - Microsoft Sam / Mary / Mike — MSTTS engine (`msttssyn.dll` + `.vce` data) - AT&T Flextalk 2.1 — "Keith Bell" and "Kerry Watson" (`FlexTalk.dll`) Long-term: replace Wine-provided pieces with own shims (rehost) for a pure-native build, and keep a path to a fully portable engine. ## Status (working) - Winelib host builds and runs: `build/sapi4host.exe` (launcher) + `build/sapi4host.exe.so` (native 32-bit ELF). - Voices enumerate and synthesize: - MSTTS: Sam, Mary, Mike (+ telephone and effect variants) - AT&T Flextalk: Keith Bell, Kerry Watson - Test output: `build/test_sam.wav` (22.05 kHz), `build/test_Keith_Bell.wav`, `build/test_Kerry_Watson.wav` (11.025 kHz). ## Build Everything in one command (idempotent; sudo only for system packages): setup/install.sh Manual steps, if needed: sudo setup/install-deps.sh # Wine/Winelib/helpers setup/setup-prefix.sh # prefix + SAPI4 runtime + MSTTS voices setup/setup-flextalk.sh # Flextalk extraction + registry # host build: winegcc -m32 -O2 -o build/sapi4host-winlib host/sapi4host.c -I../reference \ -lole32 -luser32 -ladvapi32 i686-w64-mingw32-gcc -O2 -static -o build/sapi4host.exe host/sapi4host.c \ -I../reference -lole32 -luser32 -ladvapi32 -luuid ## Usage setup/run.sh -l setup/run.sh -v Sam -t "Hello." -o sam.wav setup/run.sh -v "Keith Bell" -t "Hello." -o keith.wav -p 100 -s 150 Options: `-v` voice, `-t` text, `-o` output WAV, `-p` pitch, `-s` speed, `-V` volume (volume is engine-specific; not used by the Veskslop wrapper). ## Veskslop integration export VESKSLOP_TTS_CMD="$PWD/setup/vekslop-tts.sh {out} {text_file}" export VESKSLOP_TTS_VOICES="$(setup/vekslop-tts.sh --voices)" The wrapper maps voice IDs (`sam`, `mary`, `mike`, `keith-bell`, `kerry-watson`, plus the MSTTS variants), reads `VESKSLOP_TTS_VOICE`, `VESKSLOP_TTS_SPEED` (multiplier) and `VESKSLOP_TTS_PITCH` (semitones), starts Xvfb when `DISPLAY` is unset, and writes a 48 kHz mono s16le WAV trimmed, faded and normalized to about -16 LUFS (-3 dBFS true peak). Speed and pitch apply to every voice (Flextalk's numeric settings must be `REG_DWORD`, which the setup script writes). Mapping details are in `docs/TTS-DESIGN.md`. ## Layout - `host/sapi4host.c` — host: voice select, pitch/speed, text -> WAV - `setup/install.sh` — one-shot installer (runs all steps below) - `setup/install-deps.sh` — Wine/Winelib/helpers (root) - `setup/setup-prefix.sh` — prefix + SAPI4 runtime + MSTTS engine/voices - `setup/setup-flextalk.sh` — Flextalk files + registry - `setup/inf2reg.py` — INF AddReg -> `.reg` converter - `setup/run.sh` — run helper (prefix + Xvfb) - `setup/vekslop-tts.sh` — Veskslop command-provider wrapper (post-processing included) - `docs/NOTES.md` — registry/CLSID facts, runtime RE notes, gotchas - `docs/TTS-DESIGN.md` — integration contract with Veskslop plus engine clarifications ## Known issues - `xvfb-run` is flaky on this host. `setup/run.sh` starts a persistent Xvfb (`:77`) instead; Wine needs a working X display because the runtime creates windows. - Flextalk numeric speaker settings must be `REG_DWORD` (the installer script handles this); `REG_SZ` values cause a monotone buzz. Pitch and speed work on all voices. - The Flextalk archive lacks `data2.cab`; `unshield -O` extracts `data1.cab` but one tail file (`WatsonUNInstall.dll`) is incomplete. ## Reference material (not in this repo) - `../reference/speech.h` — SAPI4 SDK header - `../reference/SAPI4-CLI`, `../reference/TETYYS-SAPI4` — host examples - `../Microsoft-Sam-Mary-Mike-TruVoice-WSAPI4` — installers/payloads - `../flextalk` — Flextalk installer archive + extraction - `/mnt/ghidra/decomp/{msttssyn.dll,speech.dll}/` — decompiled corpora