214 lines
8.6 KiB
Python
214 lines
8.6 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright 2026 Umbra Tools (umbratools.com)
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
"""Fix Chapter 6 (Salvage) utterance issues:
|
|
1. Split utterance 56 into 3 utterances with correct speakers
|
|
2. Fix utterance 145 - Kainda with pleading tone
|
|
3. Fix utterances 181-190 - Nanny/Kainda not Deal Hunter
|
|
4. Fix utterance 222 - Kainda not Nanny
|
|
5. Remove utterance 218 (scene break <<<>>>)
|
|
6. Fix utterance 354 - Willamina Wake with yelling tone
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import sqlite3
|
|
import sys
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
sys.path.insert(0, str(Path(__file__).parent.parent))
|
|
|
|
from umbraaudio.config import load_config
|
|
|
|
CHAPTER_ID = 6
|
|
|
|
|
|
def get_utterances(conn: sqlite3.Connection) -> list[dict[str, Any]]:
|
|
rows = conn.execute(
|
|
"SELECT id, utterance_index, text, type, speaker_name, emotion, pace, instruct "
|
|
"FROM utterances WHERE chapter_id=? ORDER BY utterance_index",
|
|
(CHAPTER_ID,),
|
|
).fetchall()
|
|
return [dict(r) for r in rows]
|
|
|
|
|
|
def print_utterances(utts: list[dict[str, Any]], start: int = 0, end: int | None = None) -> None:
|
|
for u in utts[start:end]:
|
|
print(f" utt{u['utterance_index']:03d} [{u['type']}] {u['speaker_name']}: {u['text'][:80]}...")
|
|
|
|
|
|
def fix_chapter6(db_path: Path) -> None:
|
|
conn = sqlite3.connect(str(db_path))
|
|
conn.row_factory = sqlite3.Row
|
|
|
|
print("=== Current Chapter 6 utterances (key range) ===")
|
|
utts = get_utterances(conn)
|
|
print_utterances(utts, 50, 70)
|
|
print_utterances(utts, 140, 160)
|
|
print_utterances(utts, 180, 200)
|
|
print_utterances(utts, 210, 230)
|
|
print_utterances(utts, 350, 360)
|
|
|
|
print("\n=== Applying fixes ===")
|
|
|
|
# Fix 1: Split utterance 56 into 3 utterances
|
|
# Original utt 56: "The captain is changing course, and that was a missile he is firing at the pirates.
|
|
# As Niñera helps Kainda, they feel the impacts more, and the air pressure alarm sounds.
|
|
# The computer voice announces, 'Hull breach. Please put on emergency space suits.'"
|
|
# Should be:
|
|
# - utt 56: "The captain is changing course, and that was a missile he is firing at the pirates." -> Nanny
|
|
# - utt 57: "As Niñera helps Kainda, they feel the impacts more, and the air pressure alarm sounds." -> narration
|
|
# - utt 58: "The computer voice announces, 'Hull breach. Please put on emergency space suits.'" -> Deal Hunter (AI)
|
|
|
|
print("\n1. Splitting utterance 56...")
|
|
utt56 = conn.execute(
|
|
"SELECT id, text FROM utterances WHERE chapter_id=? AND utterance_index=56",
|
|
(CHAPTER_ID,),
|
|
).fetchone()
|
|
if utt56:
|
|
original_text = utt56["text"]
|
|
print(f" Original: {original_text[:100]}...")
|
|
|
|
# Split into three parts
|
|
part1 = "The captain is changing course, and that was a missile he is firing at the pirates."
|
|
part2 = "As Niñera helps Kainda, they feel the impacts more, and the air pressure alarm sounds."
|
|
part3 = 'The computer voice announces, "Hull breach. Please put on emergency space suits."'
|
|
|
|
# Update utt 56 to be part1 (Nanny)
|
|
conn.execute(
|
|
"UPDATE utterances SET text=?, speaker_name=?, type=? WHERE id=?",
|
|
(part1, "Nanny", "dialogue", utt56["id"]),
|
|
)
|
|
|
|
# Insert part2 as narration at index 57
|
|
conn.execute(
|
|
"INSERT INTO utterances (chapter_id, utterance_index, text, type, speaker_name, status) "
|
|
"VALUES (?, 57, ?, 'narration', 'narrator', 'pending')",
|
|
(CHAPTER_ID, part2),
|
|
)
|
|
|
|
# Insert part3 as dialogue (Deal Hunter - AI voice) at index 58
|
|
conn.execute(
|
|
"INSERT INTO utterances (chapter_id, utterance_index, text, type, speaker_name, status) "
|
|
"VALUES (?, 58, ?, 'dialogue', 'Deal Hunter', 'pending')",
|
|
(CHAPTER_ID, part3),
|
|
)
|
|
|
|
# Shift all utterances >= 57 up by 2
|
|
conn.execute(
|
|
"UPDATE utterances SET utterance_index = utterance_index + 2 "
|
|
"WHERE chapter_id=? AND utterance_index >= 57",
|
|
(CHAPTER_ID,),
|
|
)
|
|
print(" Split into 3 utterances: 56 (Nanny), 57 (narration), 58 (Deal Hunter)")
|
|
|
|
# Fix 2: Utterance 145 -> now at index 147 after shift, Kainda with pleading tone
|
|
print("\n2. Fixing utterance 145 (now ~147) - Kainda pleading...")
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=?, emotion=?, instruct=? "
|
|
"WHERE chapter_id=? AND text LIKE '%Help me, please.%' "
|
|
"AND utterance_index BETWEEN 145 AND 150",
|
|
("Kainda Walters Foster Murphy", "pleading", "Speak with desperate pleading. Urgent, emotional.",
|
|
CHAPTER_ID),
|
|
)
|
|
|
|
# Fix 3: Utterances 181-190 (now shifted by 2) - Nanny/Kainda not Deal Hunter
|
|
print("\n3. Fixing utterances 181-190 (now ~183-192) - Nanny/Kainda...")
|
|
|
|
# utt 181: "Hello." -> Nanny
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=? WHERE chapter_id=? AND text='Hello.' AND utterance_index BETWEEN 180 AND 195",
|
|
("Nanny", CHAPTER_ID),
|
|
)
|
|
|
|
# utt 186: "What ship is this?" -> Kainda
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=? WHERE chapter_id=? AND text='What ship is this?' AND utterance_index BETWEEN 180 AND 195",
|
|
("Kainda Walters Foster Murphy", CHAPTER_ID),
|
|
)
|
|
|
|
# utt 188: "You are on the Deal Hunter." -> Nanny
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=? WHERE chapter_id=? AND text='You are on the Deal Hunter.' AND utterance_index BETWEEN 180 AND 195",
|
|
("Nanny", CHAPTER_ID),
|
|
)
|
|
|
|
# utt 189: "Is there a rescue ship in the area looking for me?" -> Kainda
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=? WHERE chapter_id=? AND text LIKE '%rescue ship%' AND utterance_index BETWEEN 180 AND 195",
|
|
("Kainda Walters Foster Murphy", CHAPTER_ID),
|
|
)
|
|
|
|
# utt 190: "There are no rescue ships..." -> Nanny
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=? WHERE chapter_id=? AND text LIKE '%no rescue ships%' AND utterance_index BETWEEN 180 AND 195",
|
|
("Nanny", CHAPTER_ID),
|
|
)
|
|
|
|
# Fix 4: Utterance 211 (now ~213) - already Nanny, good. But 181-210 should be Nanny
|
|
print("\n4. Ensuring Nanny consistency from 181-210...")
|
|
# The robot says at 211: "That was a missile trying to disable our engines. Hold on." - already Nanny
|
|
# The robot says at 181 (Hello), 188 (You are on...), 190 (There are no rescue...), 211 (missile)
|
|
# Also need to fix 183-184, 186-187 if they are Deal Hunter
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name='Nanny' WHERE chapter_id=? AND utterance_index BETWEEN 181 AND 210 "
|
|
"AND speaker_name='Deal Hunter' AND type='dialogue'",
|
|
(CHAPTER_ID,),
|
|
)
|
|
|
|
# Fix 5: Remove utterance 218 (scene break <<<>>>) - now at ~220
|
|
print("\n5. Removing scene break utterance (<<<>>>)...")
|
|
conn.execute(
|
|
"DELETE FROM utterances WHERE chapter_id=? AND text='<<<>>>' AND type='scene_break'",
|
|
(CHAPTER_ID,),
|
|
)
|
|
|
|
# Fix 6: Utterance 222 (now shifted) - should be Kainda not Nanny
|
|
print("\n6. Fixing utterance 222 - Kainda not Nanny...")
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=? WHERE chapter_id=? AND text LIKE '%Why did you accelerate%'",
|
|
("Kainda Walters Foster Murphy", CHAPTER_ID),
|
|
)
|
|
|
|
# Fix 7: Utterance 354 (now shifted) - Willamina Wake with yelling
|
|
print("\n7. Fixing utterance 354 - Willamina Wake yelling...")
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name=?, emotion=?, instruct=? "
|
|
"WHERE chapter_id=? AND text LIKE '%Get the princess on board!%'",
|
|
("Willamina Wake", "yelling", "Speak with authority and command. Firm, unwavering tone. LOUD.",
|
|
CHAPTER_ID),
|
|
)
|
|
|
|
# Also fix the "The Doctor" utterances
|
|
print("\n8. Fixing 'The Doctor' utterances...")
|
|
conn.execute(
|
|
"UPDATE utterances SET speaker_name='The Doctor' WHERE chapter_id=? AND text LIKE '%robots are all wiped%'",
|
|
(CHAPTER_ID,),
|
|
)
|
|
|
|
conn.commit()
|
|
|
|
print("\n=== Verifying fixes ===")
|
|
utts = get_utterances(conn)
|
|
print_utterances(utts, 50, 70)
|
|
print_utterances(utts, 145, 160)
|
|
print_utterances(utts, 180, 200)
|
|
print_utterances(utts, 210, 230)
|
|
print_utterances(utts, 350, 365)
|
|
|
|
conn.close()
|
|
print("\n=== Done ===")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Fix Chapter 6 (Salvage) utterance issues")
|
|
parser.add_argument(
|
|
"--project", type=str, default=None, help="Project name or path"
|
|
)
|
|
args = parser.parse_args()
|
|
cfg = load_config(args.project)
|
|
fix_chapter6(cfg.db_path)
|