Old Tam says "W, A, S and D", not "Wasad" (Gitea #3, first part); make_voice.py re-records a line when how it's spoken changes, not only its text

This commit is contained in:
Paul Bailey
2026-11-08 20:32:09 +00:00
parent 8f3c58c810
commit 4a691b72e1
3 changed files with 64 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
{
"hint_cold": "91c5088e453fb0e6",
"hint_cove": "f7e5c0283b31e1cc",
"hint_crab": "283542496ecd180c",
"hint_died": "e865f8a63622b3c3",
"hint_diet": "3178b319c44e9fa0",
"hint_freezing": "48b1e505119a0fc9",
"hint_hard_winter": "5513aca1655bc278",
"hint_howl": "05792dda3f3f0b60",
"hint_hungry": "ad76f22cb8e034a0",
"hint_night": "2a07d9c0bfae4bf9",
"hint_rotten": "98b69de03dbee089",
"hint_seam": "b353f46816d329b7",
"hint_sheltered": "ba6d6ff8bc4a1c80",
"hint_sick": "ec07963c46638ffc",
"hint_snow": "8f0ac7d093f73840",
"hint_stamina": "82bf5b903db7a29f",
"hint_storm": "f06bb82d15d991c8",
"hint_wet": "6aef86b85d67d7ac",
"hint_wolf_moon": "723b3dbd5439980c",
"tutorial_animals": "e82eb7e35e866812",
"tutorial_axe": "4bb51d6ea8b42840",
"tutorial_bed": "34cf4c842db48c19",
"tutorial_berries": "a7cd3805f11c8898",
"tutorial_campfire": "b21eb5ddefb03f1a",
"tutorial_cook": "7164a8ab27a7821d",
"tutorial_diet": "fd47408ab4f2b5de",
"tutorial_finish": "36c07fc5a64c9d65",
"tutorial_fish": "32f2f3228c036136",
"tutorial_flax": "a87ff75ed8864ca6",
"tutorial_hut": "a10bfa289939dfb2",
"tutorial_look": "a88cca377c368962",
"tutorial_mushroom": "b641b54d2ef35404",
"tutorial_pickaxe": "177e0474e4d0fda6",
"tutorial_rabbit": "6d429ab2cbdc7b19",
"tutorial_rod": "d610281e722e8fd3",
"tutorial_sleep": "e202cbf133500c2a",
"tutorial_sticks": "e526e30ddf8756a7",
"tutorial_torch": "06ebc4c122fd8902",
"tutorial_tree": "58c2488e73c1fe4c",
"tutorial_weapon": "a17d1fe6d5067b8d",
"tutorial_wolf": "feb6bdda64e28161",
"tutorial_workbench": "1b6108ab18f05de9"
}

Binary file not shown.

View File

@@ -45,17 +45,35 @@ def spoken(text):
s = s.replace(" · ", ", ").replace("&", "and") s = s.replace(" · ", ", ").replace("&", "and")
s = re.sub(r"\bLMB\b", "left click", s) s = re.sub(r"\bLMB\b", "left click", s)
s = re.sub(r"\bRMB\b", "right click", s) s = re.sub(r"\bRMB\b", "right click", s)
s = re.sub(r"\bWASD\b", "W, A, S and D", s) # (Gitea #3: it said "Wasad")
s = re.sub(r"\s+,", ",", s) s = re.sub(r"\s+,", ",", s)
return s return s
def _changed_by_new_rules(text):
"""Whether a line has something the spoken() rules added since the last
full recording (0.6.2): "WASD"."""
return re.search(r"\bWASD\b", text) is not None
def main(): def main():
redo_all = "--all" in sys.argv redo_all = "--all" in sys.argv
os.makedirs(OUT, exist_ok=True) os.makedirs(OUT, exist_ok=True)
manifest_path = os.path.join(OUT, "lines.json") manifest_path = os.path.join(OUT, "lines.json")
old = json.load(open(manifest_path)) if os.path.exists(manifest_path) else {} old = json.load(open(manifest_path)) if os.path.exists(manifest_path) else {}
# What each recording SAYS (spoken() of its text), so a change to how a
# line is spoken re-records it too. (lines.json keeps the written text's
# key: that's what the game checks against the screen.)
said_path = os.path.join(OUT, "spoken.json")
said = json.load(open(said_path)) if os.path.exists(said_path) else {}
todo = [(i, t) for i, t in lines() todo = [(i, t) for i, t in lines()
if redo_all or old.get(i) != key(t) or not os.path.exists(os.path.join(OUT, i + ".ogg"))] if redo_all or old.get(i) != key(t) or said.get(i, key(spoken(t))) != key(spoken(t))
or not os.path.exists(os.path.join(OUT, i + ".ogg"))]
if not said:
# (First run with spoken.json: lines spoken differently now than when
# they were recorded can't be told apart, so re-record the ones whose
# spoken form isn't just their text.)
todo += [(i, t) for i, t in lines() if spoken(t) != t and (i, t) not in todo and _changed_by_new_rules(t)]
keep = {i for i, _ in lines()} keep = {i for i, _ in lines()}
for f in os.listdir(OUT): # lines that no longer exist for f in os.listdir(OUT): # lines that no longer exist
if f.endswith(".ogg") and f[:-4] not in keep: if f.endswith(".ogg") and f[:-4] not in keep:
@@ -78,6 +96,7 @@ def main():
print(" %s (%.1f s)" % (i, len(audio) / 24000 / 0.92 / 1.04)) print(" %s (%.1f s)" % (i, len(audio) / 24000 / 0.92 / 1.04))
manifest = {i: key(t) for i, t in lines()} manifest = {i: key(t) for i, t in lines()}
json.dump(manifest, open(manifest_path, "w"), indent="\t", sort_keys=True) json.dump(manifest, open(manifest_path, "w"), indent="\t", sort_keys=True)
json.dump({i: key(spoken(t)) for i, t in lines()}, open(said_path, "w"), indent="\t", sort_keys=True)
print("%d lines, %d made now -> %s" % (len(manifest), len(todo), os.path.relpath(OUT, ROOT))) print("%d lines, %d made now -> %s" % (len(manifest), len(todo), os.path.relpath(OUT, ROOT)))