The classic BestSpeech / Keynote Gold formant speech synthesizer, running on macOS — both as a standalone app and as a system voice for VoiceOver / Spoken Content.
Unlike most "TTS engine ports," no source code for this engine exists. BestSpeech
ships only as b32_tts.dll, a 32-bit Windows PE binary from 1995. This project
runs that binary unmodified, headless, inside a small x86 CPU emulator
(Unicorn Engine) with a hand-written shim
standing in for the ~56 Windows APIs (KERNEL32/USER32/WINMM) it calls —
no Wine, no Windows, no real audio device involved.
b32_tts.dll (unmodified, 1995 x86 PE binary)
▲ loaded into emulated memory
CBestSpeech (C) PE loader + Unicorn x86-32 emulator + Win32 shims;
▲ waveOut* is captured to a buffer, never played
BestSpeechKit (Swift) BestSpeechSynthesizer: text -> AVAudioPCMBuffer
▲ ▲
BestSpeech.app (SwiftUI) BestSpeechVoice.appex (AVSpeechSynthesisProviderAudioUnit)
macOS registers 14 BestSpeech voices as system voices
| Layer | Path |
|---|---|
| PE loader + emulator + Win32 shims | Sources/CBestSpeech/bst_shim.c |
| Clean C API over the emulated engine | Sources/CBestSpeech/include/bst_shim.h |
| Swift wrapper, voices, shared settings | Sources/BestSpeechKit/ |
| Standalone app (macOS) | Apps/BestSpeechApp/ |
| System-voice extension | Apps/BestSpeechVoiceExtension/ |
| Xcode project generator | project.yml (xcodegen) |
b32_tts.dll itself is bundled as a BestSpeechKit resource (see Licensing
below on why that's a temporary/personal-use arrangement, not something to
redistribute).
The DLL's entire Windows footprint is six waveOut* calls, a couple dozen
KERNEL32 memory/TLS/locale functions, and a handful of USER32 calls it uses
to run a hidden message-only window (its own internal buffer-release handshake).
CBestSpeech:
- Parses the PE headers and maps the DLL's sections into emulated memory at its preferred image base (no relocation needed).
- Points every import at a small stub; a Unicorn code-hook intercepts calls
there and runs a native C implementation instead — memory allocation is a
bump allocator, critical sections are no-ops (single-threaded), and
waveOutWritecopies PCM into a Swift-visible buffer instead of playing audio. - Drives
TtsWavas a small co-routine: the engine's internal message pump won't return until the host callsbstRelBufonce per buffer, so synthesis yields, releases the buffer, and resumes until the engine finishes. - Hands the resulting 11025 Hz 16-bit PCM back through
BestSpeechKitas anAVAudioPCMBuffer.
Because everything after step 1 is code we wrote, there's no dependency on Wine, a real Windows environment, or even a real audio device — the "hardware" this DLL thinks it's talking to doesn't exist outside of our shim.
brew install unicorn xcodegen
git clone <this repo> && cd BestSpeechApple
xcodegen generate
swift test # CBestSpeech + BestSpeechKit tests (renders real, non-silent audio)
open BestSpeech.xcodeproj # build/run the appTo sign for your own device, set your Apple Team ID in project.yml
(DEVELOPMENT_TEAM), and update the App Group identifier in both
.entitlements files and BestSpeechSettingsStore.appGroup to match.
Third-party speech providers are only picked up from an installed app:
cp -R "$(xcodebuild -project BestSpeech.xcodeproj -scheme BestSpeechApp-macOS \
-showBuildSettings 2>/dev/null | awk '/ BUILT_PRODUCTS_DIR /{print $3}')/BestSpeech.app" /Applications/
open /Applications/BestSpeech.app # registers the extensionThe 14 voices (Fred, Sara, Hary, Wendy, Dexter, Alien, Kit, Bruno, Ghost, Peeper,
Dracula, Granny, Martha, Tim) then appear in System Settings → Accessibility →
Spoken Content → System Voice, and are available to VoiceOver and any app using
AVSpeechSynthesisVoice.
- Unicorn is statically linked. A sandboxed app extension cannot load a
dylib from
/opt/homebrewat runtime, soPackage.swiftlinkslibunicorn.adirectly rather than-lunicorn. com.apple.security.cs.allow-jit. Unicorn JIT-compiles the emulated x86 code; without this entitlement (plus the hardened runtime) on the extension target, synthesis silently produces nothing. Confirmed working inside the sandboxed, hardened-runtime.appexon Apple Silicon.
- Licensing:
b32_tts.dllis a compiled binary of the proprietary "Keynote Gold" engine, of unclear distribution rights (community-circulated, not officially released) — fine for personal/experimental builds, not for public distribution without clearance. Treat this repo, and especially the bundled DLL, accordingly. - iOS is not yet supported. Homebrew's Unicorn build is macOS-arm64 only, and iOS forbids JIT entirely, so an iOS build needs Unicorn compiled as an xcframework using its non-JIT interpreter backend (TCG interpreter) — a follow-up, not yet done.
- Currently ships the 14 stock voices; no custom-voice designer or
.dtvimport/export yet (the NVDA add-on and the sibling DECtalk-for-Apple project both have one; this one doesn't yet). - The settings-sharing plumbing (App Group) exists, but the app's Settings UI isn't fully wired to it yet — rate/volume sliders in the demo app work locally but don't yet persist to the system voice.
- Engine output is 11025 Hz mono; the extension upsamples to 22050 Hz.
- samtupy/b32tts_wrapper — the original Windows wrapper this project is built around, and the source of the voice parameter tables.
- rommix0 — for surfacing the Windows x86 build of BestSpeech/Keynote Gold to the blind community, and for the built-in voice designs.
- Unicorn Engine — the CPU emulator this is built on.
- Apple integration architecture (the AVSpeechSynthesisProviderAudioUnit
approach, App-Group-shared settings) modeled on this project's sibling,
DECtalk for Apple, itself modeled on
tgeczy/TGSpeechBox.