Link subtitles to their speaker and audio stream #493

Manually merged
github merged 8 commits from github-bot/gh-493 into gh-pr/493/base 2026-11-28 02:02:24 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 19:02 UTC · original
holdmysocks:claude/dialogue-speaker-audio → master · +1276 −25 · 8 files · 8 commits · merged 2026-11-28 01:57 UTC

Summary

Fixes the v0.12.0 known issue "Dialogue: subtitles aren't linked to their speaker or audio stream yet".

  • New sixng dialogue-links writes <work>/dialogue_links.json from two sources:
    • --conversations <archive> reads links from the game's own conversation files. A conversation lists its characters and its lines in spoken order. Each line stores its subtitle label in plain text, its audio cue and its take. The subtitle key is joaat(label) and the wave is <cue>_<take>. The stream is the one stream with that wave's ID in the archive's SixNG audio index or, when that has none, in the first other archive with an audio index (story lines also play from audio.rpf). Generic speech sits in several banks, one per character voice; such a line plays from its speaker's voice bank: the candidate whose container (from audio-meta) holds at least two of the speaker's single-bank lines while no other candidate holds any. The speaker is the conversation's character. When several characters talk, each character has a slot number and each line names the slot of its speaker; a line without one falls back to the character whose single-speaker conversations use the line's voice. Lines are matched by their shape rather than by unnamed struct IDs, and field names fall back to their case-sensitive hashes.
    • --addresses <tsv> (optional) reads a local address table that only names the stream. Each address is rebuilt from the audio index: the stream at the bank offset and position must have the given ID, and the encoded range comes from the index. A row for a subtitle that the conversation files already link is not added; it is compared with the derived link (table_check) and only gives it a stream when the files have none. A table speaker ID that no conversation file uses for a character is counted apart (speaker_id_not_in_files). Other rows fill the gaps.
    • The report counts conversation files, lines, speakers, streams (by the archive holding them, and how many a voice bank picked) and lines without a speaker (by reason) per archive, plus table rows linked and rejected (confirmed and unconfirmed separately). Rejections are grouped by reason.
  • CLI: text --label and text --find add a dialogue list (speaker, speaker hash, archive, bank, stream position, stream ID, wave name, stem window) to each label that has links.
  • Viewer: Audio adds a Subtitle column (speaker and line; hover lists every subtitle key) to banks with linked streams. Scenes fills a dialogue row's audio from its subtitle's link when the link names exactly one stream, and adds linked lines that name a scene.
  • README: a "Dialogue links" section. The table and the generated file stay local, since they hold game data.

Validation

  • Synthetic tests: conversation decoding by shape (unresolved field names, repeated and loose copies, speakers from slots that are not list positions, from voices and in single-speaker conversations, unknown slots and voices); linking a line to its one stream, falling back to a second archive, a wave in several banks picked by the speaker's voice bank or left out with too little support, and a missing wave; table rows that agree with, differ from or fill derived links; TSV parsing with confirmed and unconfirmed tallies, a stale range, a mismatched stream ID, a wrong wave name and speaker states; link lookups; the Audio column labels; and the Scenes merge.
  • cargo test passed locally on Windows for sixng-core, sixng-cli and sixng-gui; after the story-pack change, the sixng-core and sixng-cli dialogue tests again (the viewer code is unchanged).
  • Local run on the current Xbox build:
    • Minigame pack: 5 conversation files, 1,980 lines, all with a speaker; 1,967 linked to a stream (the other 13 have no recorded audio in the pack).
    • Story packs: 731 conversation files, 151,113 lines, all with a speaker; 130,537 linked to a stream (1,057 of them from audio.rpf or the main story pack, and 242 generic speech lines from the speaker's voice bank). 20,183 lines name a wave that no indexed archive holds (no other archive has audio banks), and 393 generic speech lines stay unlinked: their speaker has too few single-bank lines to pick a voice bank. The picks are consistent: each speaker's picks fall in one voice bank (one stray line), and no voice bank is picked for two speakers.
    • English subtitle text joined for 147,249 links.
    • A separately received address table, against the derived links it covers: streams 79,327 agree (including all 4 voice-bank picks the table covers), 124 differ (the table names a generic ambient wave where the conversation file names the mission's own) and 287 filled from the table; speakers 61,569 agree, 7 differ, and 7,569 rows use the table's own speaker IDs. Its other rows linked through SixNG's own audio index with no stream ID or byte range disagreeing.
**@⁠holdmysocks** on GitHub · 2026-11-27 19:02 UTC · [original](https://github.com/holdmysocks/SixNG/pull/493) `holdmysocks:claude/dialogue-speaker-audio` → `master` · +1276 −25 · 8 files · 8 commits · merged 2026-11-28 01:57 UTC ### Summary Fixes the v0.12.0 known issue "Dialogue: subtitles aren't linked to their speaker or audio stream yet". - New `sixng dialogue-links` writes `<work>/dialogue_links.json` from two sources: - **`--conversations <archive>`** reads links from the game's own conversation files. A conversation lists its characters and its lines in spoken order. Each line stores its subtitle label in plain text, its audio cue and its take. The subtitle key is `joaat(label)` and the wave is `<cue>_<take>`. The stream is the one stream with that wave's ID in the archive's SixNG audio index or, when that has none, in the first other archive with an audio index (story lines also play from `audio.rpf`). Generic speech sits in several banks, one per character voice; such a line plays from its speaker's voice bank: the candidate whose container (from `audio-meta`) holds at least two of the speaker's single-bank lines while no other candidate holds any. The speaker is the conversation's character. When several characters talk, each character has a slot number and each line names the slot of its speaker; a line without one falls back to the character whose single-speaker conversations use the line's voice. Lines are matched by their shape rather than by unnamed struct IDs, and field names fall back to their case-sensitive hashes. - **`--addresses <tsv>`** (optional) reads a local address table that only names the stream. Each address is rebuilt from the audio index: the stream at the bank offset and position must have the given ID, and the encoded range comes from the index. A row for a subtitle that the conversation files already link is not added; it is compared with the derived link (`table_check`) and only gives it a stream when the files have none. A table speaker ID that no conversation file uses for a character is counted apart (`speaker_id_not_in_files`). Other rows fill the gaps. - The report counts conversation files, lines, speakers, streams (by the archive holding them, and how many a voice bank picked) and lines without a speaker (by reason) per archive, plus table rows linked and rejected (confirmed and unconfirmed separately). Rejections are grouped by reason. - CLI: `text --label` and `text --find` add a `dialogue` list (speaker, speaker hash, archive, bank, stream position, stream ID, wave name, stem window) to each label that has links. - Viewer: Audio adds a **Subtitle** column (speaker and line; hover lists every subtitle key) to banks with linked streams. Scenes fills a dialogue row's audio from its subtitle's link when the link names exactly one stream, and adds linked lines that name a scene. - README: a "Dialogue links" section. The table and the generated file stay local, since they hold game data. ### Validation - Synthetic tests: conversation decoding by shape (unresolved field names, repeated and loose copies, speakers from slots that are not list positions, from voices and in single-speaker conversations, unknown slots and voices); linking a line to its one stream, falling back to a second archive, a wave in several banks picked by the speaker's voice bank or left out with too little support, and a missing wave; table rows that agree with, differ from or fill derived links; TSV parsing with confirmed and unconfirmed tallies, a stale range, a mismatched stream ID, a wrong wave name and speaker states; link lookups; the Audio column labels; and the Scenes merge. - `cargo test` passed locally on Windows for sixng-core, sixng-cli and sixng-gui; after the story-pack change, the sixng-core and sixng-cli dialogue tests again (the viewer code is unchanged). - Local run on the current Xbox build: - Minigame pack: 5 conversation files, 1,980 lines, all with a speaker; 1,967 linked to a stream (the other 13 have no recorded audio in the pack). - Story packs: 731 conversation files, 151,113 lines, all with a speaker; 130,537 linked to a stream (1,057 of them from `audio.rpf` or the main story pack, and 242 generic speech lines from the speaker's voice bank). 20,183 lines name a wave that no indexed archive holds (no other archive has audio banks), and 393 generic speech lines stay unlinked: their speaker has too few single-bank lines to pick a voice bank. The picks are consistent: each speaker's picks fall in one voice bank (one stray line), and no voice bank is picked for two speakers. - English subtitle text joined for 147,249 links. - A separately received address table, against the derived links it covers: streams 79,327 agree (including all 4 voice-bank picks the table covers), 124 differ (the table names a generic ambient wave where the conversation file names the mission's own) and 287 filled from the table; speakers 61,569 agree, 7 differ, and 7,569 rows use the table's own speaker IDs. Its other rows linked through SixNG's own audio index with no stream ID or byte range disagreeing.
sixng dialogue-links reads a local address table and writes
<work>/dialogue_links.json. Each audio address is rebuilt from the
archive's SixNG audio index: the stream at the bank offset and position
must have the given ID, the encoded range comes from the index, and a
wave name is kept only when its joaat gives the stream ID. Rejections
are reported by reason, confirmed and unconfirmed rows apart.

text --label and --find list each label's speaker and stream. Audio
shows the speaker and line beside linked streams. Scenes fills a
dialogue row's audio from its subtitle's link and adds linked lines of
a scene.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 19:04:11 +00:00
dialogue-links --conversations <archive> decodes the archive's
conversation files: each line's subtitle label, audio cue and take, and
the conversation's characters. The subtitle key is joaat(label), the
wave <cue>_<take> names the stream, and a line's speaker comes from the
conversation (or from its voice when several characters talk). The
address table becomes optional: a row for a subtitle the files already
link is only compared with the derived link.
Conversation lines take their speaker from the line's speaker slot, which
names one of the conversation's characters; the voice is only a fallback for
lines without one. A wave missing from the pack's audio index is looked up in
the other archives with an audio index. The report counts lines without a
speaker by reason and linked streams by archive. A table row now also fills a
stream the conversation files give none, and a table speaker ID the files
never use for a character is counted apart from real disagreements.
A wave in several banks (generic speech each character voice records) goes
to the candidate bank whose container, from audio-meta, holds at least two
of the speaker's lines that are in one bank only, while no other candidate
holds any. The report counts these picks per archive.
github-bot changed target branch from master to gh-pr/493/base 2026-11-28 02:02:22 +00:00
github manually merged commit da562fc100 into gh-pr/493/base 2026-11-28 02:02:24 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.