Fix no audio: send raw SAPI XML instead of a W3C SSML document - #6
Open
stiio wants to merge 1 commit into
Open
Conversation
SpeakInternal wrapped every utterance in a W3C SSML document (<speak xmlns="http://www.w3.org/2001/10/synthesis"> ... </speak>). Inside that document SAPI does not honor the proprietary <voice required="Name=..."> tag, so the configured voice was never applied and playback silently fell back to the system default voice. When that default is a neural voice (e.g. exposed through NaturalVoiceSAPIAdapter) the embedded engine additionally rejects the markup with SPERR_UNSUPPORTED_FORMAT (0x80045003), so nothing is spoken at all. Send the raw SAPI XML fragment as-is (the Wrath of the Righteous version already does this for its main Speak/SpeakDialog/SpeakPreview paths). This restores voice selection and makes both classic SAPI5 and neural voices audible. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Owner
|
I'll have a look at this soon, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Pathfinder: Kingmaker the mod produced no speech at all — not for dialog, not for the Preview "Play" button — while the Wrath of the Righteous build works. Voice enumeration worked (all voices listed) and the native
WindowsVoice.dllloaded fine, so the voice stack itself was healthy.Root cause
WindowsSpeech.SpeakInternalwraps every utterance in a W3C SSML document:This mixes W3C SSML (the
<speak xmlns=".../synthesis">root) with SAPI‑proprietary tags (<voice required="Name=...">,<pitch absmiddle>, …). Once SAPI sees the W3C namespace it parses in W3C mode, where:<voice required="Name=...">is not recognized (W3C uses<voice name="...">), so the configured voice is ignored and playback falls back to the system default voice.SPERR_UNSUPPORTED_FORMAT(0x80045003) → no audio.The WotR build avoids this because its main
Speak/SpeakDialog/SpeakPreviewcallWindowsVoiceUnity.Speakdirectly (raw SAPI XML), whereas the Kingmaker build routes everything throughSpeakInternal(which adds the wrapper).Fix
Don't wrap in
<speak>inSpeakInternal; send the raw SAPI XML fragment as-is (SPF_IS_XMLaccepts a<voice .../>fragment).Verified (native SAPI, reproduced outside the game)
<speak>wrapper0x80045003<speak>wrapperrequired=ignoredIn-game after the fix: dialog auto-play and the Preview button work, and the voice picker actually changes the voice.
Note:
SpeakBegin/SpeakEndare now unused — left in for a minimal diff; happy to remove if preferred.