Speech synthesis via Windows.Media.SpeechSynthesis — would you take it? #825
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#825
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@gabrielvbraga on GitHub · 2026-11-24 11:41 UTC · original
speech.rsreturns an empty WAVE stream for every request, so the title's accessibility narration is silent. I'd like to implement it with the host's WinRT synthesizer, which already returns a WAVE stream and accepts both plain text (slot 0x68) and SSML (slot 0xa8).Plan:
create_streamsynthesizes withSpeechSynthesizer::SynthesizeTextToStreamAsync/SynthesizeSsmlToStreamAsyncand keeps the bytes in a per-stream buffer;stream_size/stream_dataserve them; closing frees them.#[ignore]test writes the WAV out to listen to.Questions before I start:
windows(featuresMedia_SpeechSynthesis,Storage_Streams,Foundation) as a non-optional Windows dependency of victory-hle acceptable, or would you prefer it behind a feature?enumerate_voicesstart reporting the host's voices, or stay empty for now (default voice only)? I don't know the callback's signature yet.I can't run the title (no console), so I can test synthesis on Windows 11 / RTX 5060 Ti but not the in-game narration; that part would need a check on your side.
@gabrielvbraga on GitHub · 2026-11-24 11:51 UTC · original
Quick prototype results (standalone program, nothing in the repo yet), Windows 11,
windows0.62.2:SynthesizeTextToStreamAsyncandSynthesizeSsmlToStreamAsyncboth return valid RIFF/WAVE streams.Foundation,Foundation_Collections,Media_Core,Media_SpeechSynthesis,Storage_Streams(the stream type and the synthesize methods are gated behindMedia_Core).set_custom_voice/enumerate_voices) will matter for players whose system voices don't match the title's language.@gabrielvbraga on GitHub · 2026-11-24 12:08 UTC · original
Implementation ready, but pull requests are limited to collaborators, so I couldn't open one. It's a single commit on my fork: https://github.com/gabrielvbraga/VIctory/tree/speech-synthesis (185bd7b)
To bring it in:
git fetch https://github.com/gabrielvbraga/VIctory speech-synthesis
git cherry-pick 185bd7b
What it does:
Windows.Media.SpeechSynthesisfrom plain text (slot 0x68) and SSML (slot 0xa8), on a dedicated "victory speech" thread; COM is initialized there only, never on the title's threads. Title threads wait at most 10 s per line.windowsdependency is now non-optional withFoundation,Media_Core,Media_SpeechSynthesisandStorage_Streamsadded (question 1); I can move speech behind a feature instead if you prefer.enumerate_voicesstill reports none.Tested on Windows 11: both clippy runs from CI (with and without
--all-features) andcargo test --workspacepass; the ignored testlines_are_spokenwrites a text line and an SSML line to the temp folder and both play correctly. In-game narration still needs a check on your side, since I can't run the title.If you'd rather receive it another way (patch file, or collaborator access for a PR), just say.
@Sunkiller-qc on GitHub · 2026-11-24 13:21 UTC · original
Heads up: there are already two open PRs for the same thing. #82 (permadiego, "speak the title's narration with the host's speech synthesizer") and #691 (arthercz, "speak accessibility narration through the host's WinRT synthesizer"). Your plan and prototype (text slot 0x68, SSML slot 0xa8, per-stream buffer) look very close to #691. It would help to say on #691 or #82 what your branch does differently, if anything, and to post your Windows 11 test there, rather than add a third version.
@gabrielvbraga on GitHub · 2026-11-24 13:47 UTC · original
Thanks for the pointer, I missed those. #82 covers this and more (resampling, SSML fallback), so I've tested it here and posted the results there, along with two small differences from my branch (a timeout on synthesis and safe handling of repeated or unknown stream handles). Closing this in favour of #82.