Speech: the title's narration plays through the host's SAPI voice #1820

Open
kais7654 wants to merge 1 commit from upstream-pr/1822 into main
kais7654 commented 2026-11-24 23:01:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T23:01:56Z.


The accessibility module handed back 44 bytes of silence for every stream, so narration was silent even on a machine with voices. A view of SAPI through the COM bindings this crate already carries renders the line the title sends (SSML as sent, plain text as a fallback) into an HGlobal-backed stream at the 16 kHz mono 16-bit format the console uses, and the WAV goes to the title through the same vtable as before. A machine with no voice, no SAPI, or a line the engine refuses, still gets the silence it got. Stream handles are registry slots encoded into odd pointer values, so no handle the title passes back is ever dereferenced as memory. Test-only, 4 tests.

Generated by Mistral Vibe.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6593154476 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1822). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-24T23:01:56Z. --- The accessibility module handed back 44 bytes of silence for every stream, so narration was silent even on a machine with voices. A view of SAPI through the COM bindings this crate already carries renders the line the title sends (SSML as sent, plain text as a fallback) into an HGlobal-backed stream at the 16 kHz mono 16-bit format the console uses, and the WAV goes to the title through the same vtable as before. A machine with no voice, no SAPI, or a line the engine refuses, still gets the silence it got. Stream handles are registry slots encoded into odd pointer values, so no handle the title passes back is ever dereferenced as memory. Test-only, 4 tests. Generated by Mistral Vibe.
catminou4 commented 2026-11-24 23:05:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T23:03:41Z.

Review: COMMENTED


Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff.

Title narration through the host's SAPI voice: 18K HLE speech module — Windows-only, needs a Windows session with audio to validate.

<!-- greyfinch-sync:Marvisak/VIctory:review:6048804093 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1822#pullrequestreview-6048804093). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T23:03:41Z. **Review:** COMMENTED --- Static review only: victory-hle is Windows-only — nothing compiles or runs on macOS; source review of the diff. Title narration through the host's SAPI voice: 18K HLE speech module — Windows-only, needs a Windows session with audio to validate.
Melow-code commented 2026-11-25 00:06:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Melow-code on 2026-11-24T23:08:34Z.

Review: COMMENTED


SAPI integration looks right for the happy path. Two questions:

  1. What happens when no SAPI voice is installed (server editions, some stripped Windows)? A fallback to silence would prevent a crash.
  2. The 16 kHz mono format — does the title expect a specific sample rate, or does it resample?
<!-- greyfinch-sync:Marvisak/VIctory:review:6048854413 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1822#pullrequestreview-6048854413). Originally posted by [Melow-code](https://github.com/Melow-code) on 2026-11-24T23:08:34Z. **Review:** COMMENTED --- SAPI integration looks right for the happy path. Two questions: 1. What happens when no SAPI voice is installed (server editions, some stripped Windows)? A fallback to silence would prevent a crash. 2. The 16 kHz mono format — does the title expect a specific sample rate, or does it resample?
DesertGamer commented 2026-11-25 00:06:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DesertGamer on 2026-11-24T23:06:52Z.


VIctory V2: community PRs, merged and tested

Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch.

Where it stands today: launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1).

⚠️ Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk.

Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help:
https://DesertGamer/VIctory-V2

Unofficial community fork of Marvisak/VIctory, GPL-3.0.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147029071 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1822#issuecomment-7147029071). Originally posted by [DesertGamer](https://github.com/DesertGamer) on 2026-11-24T23:06:52Z. --- ### VIctory V2: community PRs, merged and tested Open PRs sitting in the queue? V2 pulls them into one build, screens each one (binaries, build scripts, hooks, new deps) and runs tests after every batch. **Where it stands today:** launches, runs the menu at 30 fps, plays the intro video, reaches the start screen and loads the world (~50 s). Entering the world is the current blocker: rendering fails with a GPU "device removed" error (tracked in issue #1). :warning: Entering the world on a real GPU can hang it and make Windows reset the driver. Try it at your own risk. Not playable yet, but every batch of merged fixes moves it closer. If you have a PR that's stuck, or a GPU to test on, I'd love your help: https://DesertGamer/VIctory-V2 *Unofficial community fork of Marvisak/VIctory, GPL-3.0.*
kais7654 commented 2026-11-25 00:06:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T23:16:06Z.


SAPI integration looks right for the happy path. Two questions:

  1. What happens when no SAPI voice is installed (server editions, some stripped Windows)? A fallback to silence would prevent a crash.
  2. The 16 kHz mono format — does the title expect a specific sample rate, or does it resample?

@ruipedro-pinheiro Good questions — both are covered, here's where:

No SAPI voice installed: the fallback to silence is already the PR's behavior, not a crash path. synthesize() returns None on every failure: CoInitializeEx failing (other than RPC_E_CHANGED_MODE), CoCreateInstance failing (which is what happens on server editions or stripped Windows with no SAPI/voice), Speak failing, GlobalLock returning null — every error path returns early with None, no panic, no unwinding through COM. stream_audio maps that None to the same 44-byte silence WAV the module handed back before this change, and the title gets a valid stream either way (stream size/data still answer from the WAV bytes). So a machine with no voice behaves exactly as main does today.

16 kHz mono: it's the format the title already receives — the pre-existing SILENCE constant on main is a 16 kHz mono 16-bit WAV (RIFF fmt: PCM, 1 channel, 16,000 Hz), so the streams we hand back keep the format the playback side already parses. The title reads a complete WAV file through the same vtable methods as before; if it resamples or request another rate, that logic is unchanged and outside this diff. SAPI writes into the WAV we format because SetBaseStream pins the WAVEFORMATEX before Speak, so the bytes are always 16 kHz PCM regardless of the voice's native rate.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7147205939 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1822#issuecomment-7147205939). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-24T23:16:06Z. --- > SAPI integration looks right for the happy path. Two questions: > > 1. What happens when no SAPI voice is installed (server editions, some stripped Windows)? A fallback to silence would prevent a crash. > 2. The 16 kHz mono format — does the title expect a specific sample rate, or does it resample? @ruipedro-pinheiro Good questions — both are covered, here's where: No SAPI voice installed: the fallback to silence is already the PR's behavior, not a crash path. synthesize() returns None on every failure: CoInitializeEx failing (other than RPC_E_CHANGED_MODE), CoCreateInstance failing (which is what happens on server editions or stripped Windows with no SAPI/voice), Speak failing, GlobalLock returning null — every error path returns early with None, no panic, no unwinding through COM. stream_audio maps that None to the same 44-byte silence WAV the module handed back before this change, and the title gets a valid stream either way (stream size/data still answer from the WAV bytes). So a machine with no voice behaves exactly as main does today. 16 kHz mono: it's the format the title already receives — the pre-existing SILENCE constant on main is a 16 kHz mono 16-bit WAV (RIFF fmt: PCM, 1 channel, 16,000 Hz), so the streams we hand back keep the format the playback side already parses. The title reads a complete WAV file through the same vtable methods as before; if it resamples or request another rate, that logic is unchanged and outside this diff. SAPI writes into the WAV we format because SetBaseStream pins the WAVEFORMATEX before Speak, so the bytes are always 16 kHz PCM regardless of the voice's native rate.
Marvisak commented 2026-11-25 07:03:18 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T06:29:56Z.


Automated triage for the maintainers.

Needs work. crates/victory-hle/src/modules/speech.rs now synthesizes the title's narration with the host's SAPI voice (sapi::synthesize, in-process COM, no network). It hands the WAVE bytes back through stream_size/the copy slot, with silence as the fallback. The new Cargo lines are only feature flags of windows, which is already a dependency. The direction is sensible. One blocking issue:

  • Every stream is kept forever. stream_handle pushes each synthesized WAVE into the global STREAMS vector, and nothing ever removes one: close is still a no-op. A narrated menu creates a stream per spoken line, so a long session keeps growing, at about 32 KB per second of speech. Free the entry when the title closes or releases the stream. A handle that is an index into a vector that never shrinks would also need a free list, or a map keyed by a counter.

Smaller:

  • stream_bytes clones the whole WAVE on every size query and every copy. Returning a length, or copying under the lock, avoids that.
  • spoken strips SSML tags to plain text, which is fine as a first step. Say so in the module docs, which still describe narration as silent.

CI: no check runs on the head commit.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7154852185 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1822#issuecomment-7154852185). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T06:29:56Z. --- <!-- victory-triage v1 head=5942e74b8ce4f108796500b4fac315bd01ec5155 verdict=needs-work at=2026-11-25T06:33:00Z --> Automated triage for the maintainers. **Needs work.** `crates/victory-hle/src/modules/speech.rs` now synthesizes the title's narration with the host's SAPI voice (`sapi::synthesize`, in-process COM, no network). It hands the WAVE bytes back through `stream_size`/the copy slot, with silence as the fallback. The new Cargo lines are only feature flags of `windows`, which is already a dependency. The direction is sensible. One blocking issue: - **Every stream is kept forever.** `stream_handle` pushes each synthesized WAVE into the global `STREAMS` vector, and nothing ever removes one: `close` is still a no-op. A narrated menu creates a stream per spoken line, so a long session keeps growing, at about 32 KB per second of speech. Free the entry when the title closes or releases the stream. A handle that is an index into a vector that never shrinks would also need a free list, or a map keyed by a counter. Smaller: - `stream_bytes` clones the whole WAVE on every size query and every copy. Returning a length, or copying under the lock, avoids that. - `spoken` strips SSML tags to plain text, which is fine as a first step. Say so in the module docs, which still describe narration as silent. CI: no check runs on the head commit. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/1822:upstream-pr/1822'
git switch 'upstream-pr/1822'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/1822'
git switch 'upstream-pr/1822'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1822'
git switch 'upstream-pr/1822'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1822'
git switch 'main'
git merge --squash 'upstream-pr/1822'
git switch 'main'
git merge --ff-only 'upstream-pr/1822'
git switch 'main'
git merge 'upstream-pr/1822'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!1820
No description provided.