Skip to content

Commit 6f543ec

Browse files
committed
Remove TTS — extracted to the standalone VanillaTTS DLL
C_VoiceChat / C_TTSSettings (the SAPI text-to-speech surface) is moving to its own injected DLL (C:\Git\VanillaTTS) so it can grow a cross-platform software-synthesis backend (Flite under Wine) without bloating ClassicAPI. - Delete src/voicechat/Tts.cpp. - Drop the ole32 link from CMakeLists (it was only for SAPI/COM). - Strip the VoiceChat section + TOC from docs/API.md and the VoiceChat row + VOICE_CHAT_TTS_* events from the README. CVar::Factory stays — it's general-purpose infra now, not TTS-specific (reworded its header comment to drop the TTS example).
1 parent d9102ba commit 6f543ec

5 files changed

Lines changed: 3 additions & 691 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,7 @@ target_compile_definitions(
9999
${PROJECT_NAME}
100100
PRIVATE CLASSICAPI_VERSION_VALUE=${CLASSICAPI_VERSION_VALUE})
101101

102-
# ole32: COM (CoInitializeEx / CoCreateInstance / CoTaskMemFree) for the
103-
# SAPI text-to-speech backend in src/voicechat/Tts.cpp. The SAPI GUIDs are
104-
# instantiated in that TU via <initguid.h>, so no sapi.lib is needed.
105-
target_link_libraries(${PROJECT_NAME} PRIVATE minhook advapi32 ole32)
102+
target_link_libraries(${PROJECT_NAME} PRIVATE minhook advapi32)
106103

107104
target_include_directories(
108105
${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src

README.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ Full per-function reference: **[docs/API.md](docs/API.md)**.
5959
| [UIColor](docs/API.md#uicolor) | `C_UIColor.GetColors` |
6060
| [Unit](docs/API.md#unit) | `GetUnitSpeed`, `UnitClassBase`, `UnitGUID`, `UnitInRange`, `UnitIsAFK`, `UnitIsDND`, `UnitIsFeignDeath`, `UnitIsInMyGuild`, `UnitIsPossessed`, `UnitPower`, `UnitPowerMax`, `UnitPowerType`, `UnitRaceBase`, `UnitStandState`, `UnitSubName`, `UnitTokenFromGUID` |
6161
| [UnitAuras](docs/API.md#unitauras) | `C_UnitAuras.GetAuraDataByIndex`, `C_UnitAuras.GetAuraDataBySpellName`, `C_UnitAuras.GetAuraDispelTypeColor`, `C_UnitAuras.GetBuffDataByIndex`, `C_UnitAuras.GetDebuffDataByIndex`, `C_UnitAuras.GetPlayerAuraBySpellID`, `C_UnitAuras.GetUnitAuraBySpellID`, `C_UnitAuras.GetUnitAuras` |
62-
| [VoiceChat](docs/API.md#voicechat) | `C_VoiceChat.GetTtsVoices`, `C_VoiceChat.GetRemoteTtsVoices`, `C_VoiceChat.SpeakText`, `C_VoiceChat.StopSpeakingText`, `C_TTSSettings.GetSpeechRate`, `C_TTSSettings.GetSpeechVolume`, `C_TTSSettings.GetSpeechVoiceID`, `C_TTSSettings.GetVoiceOptionName`, `C_TTSSettings.SetSpeechRate`, `C_TTSSettings.SetSpeechVolume`, `C_TTSSettings.SetVoiceOption`, `C_TTSSettings.SetVoiceOptionByName`, `C_TTSSettings.SetDefaultSettings`, `C_TTSSettings.RefreshVoices` |
6362

6463
### GlueXML calls
6564

@@ -133,10 +132,6 @@ when launching with `-console`), not as Lua functions. See the
133132
| `QUEST_DATA_LOAD_RESULT` | `questID, success` |
134133
| `QUEST_TURNED_IN` | `questID, xpReward, moneyReward` |
135134
| `UPDATE_SHAPESHIFT_FORM` | *(none)* |
136-
| `VOICE_CHAT_TTS_PLAYBACK_STARTED` | `numConsumers, utteranceID, durationMS, destination` |
137-
| `VOICE_CHAT_TTS_PLAYBACK_FINISHED` | `numConsumers, utteranceID, destination` |
138-
| `VOICE_CHAT_TTS_PLAYBACK_FAILED` | `status, utteranceID, destination` |
139-
| `VOICE_CHAT_TTS_VOICES_UPDATE` | *(none)* |
140135

141136
### Globals
142137

docs/API.md

Lines changed: 0 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,6 @@ build instructions.
392392
- [`C_UnitAuras.GetUnitAuras(unit [, filter])`](#c_unitaurasgetunitaurasunit--filter)
393393
- [`C_UnitAuras.GetAuraDispelTypeColor(dispelName)`](#c_unitaurasgetauradispeltypecolordispelname)
394394

395-
- [VoiceChat](#voicechat)
396-
- [`C_VoiceChat.GetTtsVoices()` / `C_VoiceChat.GetRemoteTtsVoices()`](#c_voicechatgetttsvoices--c_voicechatgetremotettsvoices)
397-
- [`C_VoiceChat.SpeakText(voiceID, text [, destination, rate, volume])`](#c_voicechatspeaktextvoiceid-text--destination-rate-volume)
398-
- [`C_VoiceChat.StopSpeakingText()`](#c_voicechatstopspeakingtext)
399-
- [`C_TTSSettings` — getters & setters](#c_ttssettings--getters--setters)
400-
- [TTS events](#tts-events)
401-
- [TTS CVars](#tts-cvars)
402-
403395
## Account
404396

405397
### `SaveAccount(name, password)` / `DeleteAccount(name)` / `GetSavedAccounts()` / `LoginWithSavedAccount(name)` — GlueXML only
@@ -9463,122 +9455,3 @@ builds. So the returned value carries the mixin methods
94639455
`.r/.g/.b/.a` fields. Falls back to a plain `{r,g,b,a}` table if
94649456
`CreateColor` isn't loaded yet (shouldn't happen — `!!!ClassicAPI`
94659457
loads first thanks to the triple-`!` prefix).
9466-
9467-
## VoiceChat
9468-
9469-
Backport of modern WoW's text-to-speech surface — the `C_VoiceChat` and
9470-
`C_TTSSettings` namespaces — backed by **Windows SAPI** (the OS speech
9471-
engine). All playback is **local** (rendered on your own machine);
9472-
vanilla 1.12 has no voice-chat transport, so there is nothing "remote" to
9473-
transmit synthesized speech into.
9474-
9475-
SAPI is created lazily on first use. If SAPI is unavailable (e.g. running
9476-
the client under Wine, or a stripped Windows), every call degrades
9477-
gracefully: `GetTtsVoices` returns an empty table, `SpeakText` fires
9478-
`VOICE_CHAT_TTS_PLAYBACK_FAILED` and does nothing, and the client stays
9479-
stable — there is no crash. Install more voices under **Windows Settings →
9480-
Time & Language → Speech**, then call `C_TTSSettings.RefreshVoices()`.
9481-
9482-
### `C_VoiceChat.GetTtsVoices()` / `C_VoiceChat.GetRemoteTtsVoices()`
9483-
9484-
Return a numerically-indexed array of voice tables — one per SAPI voice
9485-
installed on the machine:
9486-
9487-
```lua
9488-
for _, v in ipairs(C_VoiceChat.GetTtsVoices()) do
9489-
print(v.voiceID, v.name) -- e.g. 0 "Microsoft David Desktop - English (United States)"
9490-
end
9491-
```
9492-
9493-
Each entry is `{ voiceID = <0-based index>, name = <display name> }`. The
9494-
`voiceID` is the index you pass to `SpeakText` and store via
9495-
`C_TTSSettings.SetVoiceOption`. `GetRemoteTtsVoices` is an alias returning
9496-
the same local list (kept for API parity — vanilla has no voice chat).
9497-
Calling either refreshes the cached voice list and fires
9498-
`VOICE_CHAT_TTS_VOICES_UPDATE` if it changed.
9499-
9500-
### `C_VoiceChat.SpeakText(voiceID, text [, destination, rate, volume])`
9501-
9502-
Speaks `text` aloud using the SAPI voice at index `voiceID`.
9503-
9504-
```lua
9505-
C_VoiceChat.SpeakText(
9506-
C_TTSSettings.GetSpeechVoiceID(), -- use the configured voice
9507-
UnitName("target") or "no target")
9508-
```
9509-
9510-
- **`voiceID`** (number, required) — index into `GetTtsVoices()`. Note this
9511-
is an **explicit argument**`SpeakText` does *not* read the `ttsVoice`
9512-
cvar itself, matching Blizzard's contract. Pass
9513-
`C_TTSSettings.GetSpeechVoiceID()` to honor the configured default.
9514-
- **`text`** (string, required) — UTF-8; spoken as-is.
9515-
- **`destination`** (number, optional, default `1`) — `1` =
9516-
`LOCAL_PLAYBACK`, `4` = `QUEUED_LOCAL_PLAYBACK`. Accepted for parity;
9517-
both queue FIFO through SAPI (no app-side queue).
9518-
- **`rate`** (number, optional, default `0`) — speech rate, clamped to
9519-
`[-10, 10]`.
9520-
- **`volume`** (number, optional, default `100`) — clamped to `[0, 100]`.
9521-
9522-
Speech is asynchronous. The call returns immediately and fires
9523-
`VOICE_CHAT_TTS_PLAYBACK_STARTED` when SAPI begins the utterance and
9524-
`VOICE_CHAT_TTS_PLAYBACK_FINISHED` when it completes (or
9525-
`..._PLAYBACK_FAILED` if the voice/engine is unavailable). Raises a Lua
9526-
error if `voiceID` isn't a number or `text` isn't a string.
9527-
9528-
### `C_VoiceChat.StopSpeakingText()`
9529-
9530-
Stops and purges everything currently playing or queued.
9531-
9532-
### `C_TTSSettings` — getters & setters
9533-
9534-
The settings store (separate from `SpeakText`, which takes its parameters
9535-
explicitly). All three values are backed by CVars (see below), so they
9536-
**persist across sessions** and are clamped to valid ranges on write.
9537-
9538-
| Function | Returns / effect |
9539-
|---|---|
9540-
| `C_TTSSettings.GetSpeechRate()` | configured rate, `[-10, 10]` (default `0`) |
9541-
| `C_TTSSettings.GetSpeechVolume()` | configured volume, `[0, 100]` (default `100`) |
9542-
| `C_TTSSettings.GetSpeechVoiceID()` | configured voice index (default `0`) |
9543-
| `C_TTSSettings.GetVoiceOptionName()` | display name of the configured voice, or `""` |
9544-
| `C_TTSSettings.SetSpeechRate(rate)` | set rate (clamped) |
9545-
| `C_TTSSettings.SetSpeechVolume(volume)` | set volume (clamped) |
9546-
| `C_TTSSettings.SetVoiceOption(voiceID)` | set the voice by index (clamped to installed count) |
9547-
| `C_TTSSettings.SetVoiceOptionByName(name)` | set the voice by display name (case-insensitive exact match) |
9548-
| `C_TTSSettings.SetDefaultSettings()` | reset to voice `1` (if present, else `0`), rate `0`, volume `100` |
9549-
| `C_TTSSettings.RefreshVoices()` | re-enumerate SAPI voices; fires `VOICE_CHAT_TTS_VOICES_UPDATE` if the list changed |
9550-
9551-
```lua
9552-
C_TTSSettings.SetVoiceOptionByName("Microsoft Zira Desktop - English (United States)")
9553-
C_TTSSettings.SetSpeechVolume(150) -- clamps to 100
9554-
print(C_TTSSettings.GetVoiceOptionName()) -- "Microsoft Zira Desktop - ..."
9555-
```
9556-
9557-
### TTS events
9558-
9559-
Registered like any engine event (`frame:RegisterEvent("VOICE_CHAT_TTS_PLAYBACK_STARTED")`).
9560-
9561-
| Event | Args |
9562-
|---|---|
9563-
| `VOICE_CHAT_TTS_PLAYBACK_STARTED` | `numConsumers` (number), `utteranceID` (number), `durationMS` (number, always `0`), `destination` (number) |
9564-
| `VOICE_CHAT_TTS_PLAYBACK_FINISHED` | `numConsumers` (number), `utteranceID` (number), `destination` (number) |
9565-
| `VOICE_CHAT_TTS_PLAYBACK_FAILED` | `status` (string — e.g. `"EngineAllocationFailed"`, `"InternalError"`), `utteranceID` (number), `destination` (number) |
9566-
| `VOICE_CHAT_TTS_VOICES_UPDATE` | *(none)* — the installed-voice list changed |
9567-
| `VOICE_CHAT_TTS_SPEAK_TEXT_UPDATE` | reserved for parity; not currently fired |
9568-
9569-
`utteranceID` correlates the START/FINISHED/FAILED events for a given
9570-
`SpeakText` call. `PLAYBACK_FINISHED` fires only when playback actually
9571-
completes, so it's the signal to start the next utterance in a queue.
9572-
9573-
### TTS CVars
9574-
9575-
The `C_TTSSettings` values are stored as engine CVars, persisted to
9576-
`WTF\Config.wtf`. You can also read/write them with the standard
9577-
`GetCVar`/`SetCVar` (or `/console set`); writes are clamped by the same
9578-
validation:
9579-
9580-
| CVar | Default | Range | Backing setting |
9581-
|---|---|---|---|
9582-
| `ttsVoice` | `0` | `[0, voiceCount-1]` | `GetSpeechVoiceID` / `SetVoiceOption` |
9583-
| `ttsSpeed` | `0` | `[-10, 10]` | `GetSpeechRate` / `SetSpeechRate` |
9584-
| `ttsVolume` | `100` | `[0, 100]` | `GetSpeechVolume` / `SetSpeechVolume` |

src/cvar/Factory.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
// an addon to register a cvar with a change-callback or to react to value
2323
// changes. This wraps the engine's internal registrar (`FUN_REGISTER_CVAR`)
2424
// and value-setter (`FUN_SET_CVAR_VALUE`) so other modules can publish
25-
// persisted, validated settings — e.g. the TTS module's ttsVoice / ttsSpeed
26-
// / ttsVolume.
25+
// persisted, validated settings (clamped via the change callback and saved
26+
// to Config.wtf).
2727
//
2828
// CVars registered here persist to `WTF\Config.wtf` (the engine forces the
2929
// archive flag bit on at registration) and are visible to the in-game Lua

0 commit comments

Comments
 (0)