mirror of
https://github.com/Dasemu/vnpipe.git
synced 2026-11-26 15:26:27 +00:00
docs: voice track pipeline and [voice] config
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
aea948c53d
commit
3bed94e58d
4 files changed
+112
-2
No files matched your search
@@ -28,6 +28,7 @@ redone unless their input changes.
|
||||
| Text | `fetch`, `parse` | `text.py` |
|
||||
| Annotation | `annotate run/status/prompt/merge` ([details](annotation.md)) | `annotate.py` |
|
||||
| Assets | `assets prompt/import/process/check/status/placeholders/sheet/migrate` | `assets.py` |
|
||||
| Voice (optional) | `voice fetch/asr/build/cut` ([details](voice.md)) | `voice.py`, `voice_align.py` |
|
||||
| Ren'Py | `renpy [--from-parsed] [--with-test] [--out DIR]` | `renpy_gen.py` |
|
||||
|
||||
`--work DIR` (before the subcommand) selects the work root; default is the current directory.
|
||||
@@ -40,6 +41,7 @@ redone unless their input changes.
|
||||
| `src/vnpipe/schemas/` | JSON Schemas: parsed text, annotated text, asset manifest |
|
||||
| `src/vnpipe/prompts/annotate.md` | Annotator instructions and vocabularies (its hash versions the cache) |
|
||||
| `src/vnpipe/renpy_templates/` | Default Ren'Py GUI, screens and fonts |
|
||||
| `scripts/asr.py` | Standalone faster-whisper script run on a GPU host by `voice asr` |
|
||||
| `tests/` | Unit tests on `tests/fixtures/` (a mini work); the Ren'Py SDK tests need `RENPY_SDK` |
|
||||
|
||||
## Asset manifest
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
# Voice track
|
||||
|
||||
A work can play a recording of the text in its original language under the translated text
|
||||
(like subtitled anime). `vnpipe voice` builds it from a public-domain reading: ASR timestamps
|
||||
locate each source-language speech in the audio, the speeches are mapped onto the game's
|
||||
speeches by speaker sequence, and one clip per speech is cut. Anything doubtful stays silent;
|
||||
a wrong voice is never emitted.
|
||||
|
||||
```
|
||||
audio sections (mp3) ──fetch──▶ data/raw/... (gitignored)
|
||||
source-language text ──fetch──▶ data/raw/... (gitignored)
|
||||
audio ──asr (GPU host)──▶ voice/asr/NN.json words with start/end/prob (commit it)
|
||||
text + ASR + annotated.json ──build──▶ voice/map.json, voice/report/<scene>.txt
|
||||
mp3 + map ──cut (ffmpeg)──▶ voice/clips/<first line id>.ogg
|
||||
──renpy──▶ game/voice/*.ogg + `voice` statements
|
||||
```
|
||||
|
||||
## Stages
|
||||
|
||||
| Command | What it does |
|
||||
|---|---|
|
||||
| `voice fetch [--scenes a,b]` | Downloads the source text and the audio sections (skips existing files). |
|
||||
| `voice asr [--scenes] [--host H] [--force]` | `scp`s the sections and `scripts/asr.py` to the GPU host, runs faster-whisper (word timestamps), copies `voice/asr/NN.json` back. Skips sections already present. The only step that needs a GPU; commit the JSON so the rest runs anywhere. |
|
||||
| `voice build [--scenes]` | Parses the source text into speeches, aligns them with the ASR words, maps them onto the game's speeches and writes `voice/map.json` and one report per scene. |
|
||||
| `voice cut [--scenes]` | Cuts and normalises one clip per `ok` speech. Cached by (audio, window, loudness). |
|
||||
|
||||
Then `vnpipe renpy` ships the clips. `--scenes` defaults to `[voice].scenes`, else every
|
||||
`[[voice.sections]]` entry. Config keys: see [work-config.md](work-config.md#voice).
|
||||
|
||||
## How it works
|
||||
|
||||
1. **Source speeches** (`voice_align.parse_speeches`): a speaker label is an upper-case line
|
||||
(`FAUST.`, `MEPHISTOPHELES (zu Faust).`, parentheses may span lines); `( ... )` stage
|
||||
directions are dropped; the label maps to a cast id through `[voice.speakers]`
|
||||
(unknown labels become speeches nobody can be mapped to).
|
||||
2. **Word alignment** (`align`): `difflib.SequenceMatcher` over tokens normalised to lower-case
|
||||
letters (ß/ss and umlauts folded). The narrator reading speaker names or stage directions,
|
||||
and the preamble/outro, have no counterpart in the text, so they are never matched. Per speech,
|
||||
matched ASR words are clustered (a stray match is dropped); the span grows by up to two
|
||||
unmatched edge words that are less than 0.3 s from it (misheard first/last words).
|
||||
3. **Speaker-sequence mapping** (`map_speeches`): global alignment over the two speaker-id
|
||||
sequences; only equal ids pair up, closer lengths score higher. Pairs whose length ratio
|
||||
(game words / source tokens) is outside 0.4-2.5 are dropped (merged or split speeches), unless
|
||||
the difference is at most 4 words (interjections).
|
||||
4. **Filters**: coverage (matched share of the speech's tokens) at least 0.6, and the duration
|
||||
must be plausible for the syllable count (1.6-9 syllables/s). Statuses in the map: `ok`,
|
||||
`unmapped`, `low-coverage`, `implausible-duration`, `cut-failed`. Only `ok` has a clip.
|
||||
5. **Cut**: window = span start-0.1 s .. end+0.25 s, shrunk to 45% of the silence to the
|
||||
neighbouring ASR word so another voice is never pulled in. Two-pass `loudnorm`
|
||||
(I=-18, linear), mono Opus 40 kbps. The clip's duration is checked against the window.
|
||||
6. **Ren'Py**: `voice "voice/<id>.ogg"` before the first box of the speech, `voice sustain`
|
||||
before its other boxes (a stage direction inside the speech keeps the clip going). Clips
|
||||
live in `game/voice/`, never under `audio/`, so they are not music moods. The Preferences
|
||||
screen has a Voice Volume slider (translate it in `tl/`). Credits get a "Voces"/"Voices"
|
||||
section from `[voice].credits` when clips ship.
|
||||
|
||||
`voice/report/<scene>.txt` lists, per scene, the game speeches and their status, the ASR
|
||||
coverage and the source speeches left without a game speech.
|
||||
|
||||
## Quality check
|
||||
|
||||
Re-transcribe the clips with `scripts/asr.py` and compare each transcript with its source
|
||||
speech (recall of the speech's words, precision against extra words = other voices). Clips
|
||||
that fail only because of ASR mishearings on very short utterances are expected; contamination
|
||||
shows as low precision with foreign words at the edges.
|
||||
|
||||
## Running it elsewhere
|
||||
|
||||
- ASR needs `faster-whisper` and a CUDA GPU on the host; it is deliberately not a vnpipe
|
||||
dependency. Medium (int8_float16) fits 4 GB; large-v3 did not.
|
||||
- ffmpeg/ffprobe (libopus, loudnorm) must be on `PATH` for `cut`.
|
||||
- Source text per section is found by its heading line, in order, so repeated headings work.
|
||||
@@ -17,6 +17,7 @@ A work is a directory containing `work.toml`, plus the folders the pipeline fill
|
||||
| `[staging.<scene id>]` | `bg` (background shown after the title card), `mode` (`adv` or `nvl`), `cast = { <char> = "left\|center\|right" }` pins sprite characters for the whole scene, `music` (see Audio; ignores the annotation moods for this scene). |
|
||||
| `[[cues]]` | `at` (line id; fires right before it) plus any of `bg`, `transition` (`dissolve`, `fade`, `flash`, `slow`), `tint` (`none`, `dark`, `red`), `mode`, `hide_all`, `shake`, `move = { <char> = "<pos>" }`, `music` (see Audio; applies from that line until the next cue or the scene end). |
|
||||
| `[[overrides]]` | `from`, `to` (inclusive line ids in one scene), `emotion`: forces the emotion before expression mapping. |
|
||||
| `[voice]` | Voice track (see Voice below): `text_url`, `text_file`, `audio_url` (with `{nn}`), `audio_dir`, `scenes`, `credits`, `[voice.asr]`, `[voice.speakers]`, `[[voice.sections]]`. |
|
||||
|
||||
### Text structure
|
||||
|
||||
@@ -82,3 +83,37 @@ mood (`ann.music`), unless overridden:
|
||||
exists). Attributions are printed verbatim. Labels follow `[work].language`.
|
||||
- Defaults: `preferences.text_cps = 40`, `afm_time = 15`, `window auto`, a blinking
|
||||
click-to-continue arrow. Verse boxes stay at 4 lines; NVL keeps stanza pages.
|
||||
|
||||
### Voice
|
||||
|
||||
Optional; the full pipeline is in [voice.md](voice.md). Everything is work data:
|
||||
|
||||
```toml
|
||||
[voice]
|
||||
scenes = ["calle_1"] # what `vnpipe voice` processes by default (omit: all)
|
||||
text_url = "https://.../pg2229.txt" # source-language text
|
||||
text_file = "data/raw/pg2229.txt" # cache (gitignored)
|
||||
audio_url = "https://.../faust1_{nn:02d}_goethe_64kb.mp3" # one file per section number
|
||||
audio_dir = "data/raw/librivox" # NN.mp3 cache (gitignored)
|
||||
credits = ["Lectura dramatizada de ..."] # lines of the "Voces"/"Voices" credits section
|
||||
|
||||
[voice.asr] # `vnpipe voice asr`: ssh host with faster-whisper
|
||||
host = "user@gpu-host" # (or --host)
|
||||
workdir = "/opt/asr" # cwd on the host; files go to <workdir>/vnpipe-asr/
|
||||
python = ".venv/bin/python"
|
||||
prelude = "export LD_LIBRARY_PATH=..." # shell snippet run before python
|
||||
model = "medium"
|
||||
language = "de"
|
||||
|
||||
[voice.speakers] # source-text speaker label (upper case) -> cast id
|
||||
"FAUST" = "faust"
|
||||
|
||||
[[voice.sections]] # one per scene, in play order
|
||||
scene = "calle_1" # scene id
|
||||
nn = 10 # audio section number (audio_url, voice/asr/NN.json)
|
||||
heading = "Straße (I)" # heading line in the source text, searched in order
|
||||
```
|
||||
|
||||
Voice data lives in the work: `voice/asr/NN.json` (committed ASR cache), `voice/map.json`,
|
||||
`voice/report/<scene>.txt`, `voice/clips/*.ogg`. `vnpipe renpy` copies the clips to
|
||||
`game/voice/` and credits them when `[voice].credits` is set.
|
||||
Reference in new issue
Block a user