diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4192634 --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Python +__pycache__/ +*.pyc +*.pyd +*.so +.Python +env/ +.venv/ +pip-log.txt +pip-delete-this-arg.txt +.tox/ +.coverage +.coverage.* +.hypothesis/ +.pytest_cache/ +celerybeat-schedule +.dmypy.json +.mypy_cache/ +.pyre/ +.ipynb_checkpoints +.sage/ +.spyderproject +.spyderproject.bak +.spyderworkspace +.ropeproject +/site +/data/raw/ +/data/processed/dialogs.json # This should be generated, not committed +/audio/ + +# IDEs and Editors +.idea/ +.vscode/ +*.swp +*~ +.DS_Store + +# Build artifacts +build/ +dist/ +*.egg-info/ +.cache/ + +# Logs +*.log + +# TTS Service Specific +/tts-service/app/cache/ + +# Tools +/tools/NearInfinity.jar +/tools/weidu/ + +# Temporary directories +/tmp/ +.gemini/ diff --git a/GEMINI.md b/GEMINI.md new file mode 100644 index 0000000..93988ea --- /dev/null +++ b/GEMINI.md @@ -0,0 +1,55 @@ +# BG1EE Voiceover Project Context (v0.3) + +## 1. Project Overview + +**Project Name:** bg1-ee-voiceover +**Goal:** Create a robust dual-language (German/English) data foundation and game integration hook for *Baldur's Gate: Enhanced Edition*. + +**Current Scope (v0.3):** +* **Focus:** Data Extraction, Parsing, and Logging Hook. +* **Excluded:** Active TTS generation and HTTP API (deferred to later phases). +* **Objective:** Establish a clean, bilingual `dialogs.json` database and a working `Infinity_Log` trigger from within the game. + +## 2. Architecture (v0.3) + +The system is reduced to three core components: + +1. **Extraction (Near Infinity):** + * **Source:** `dialog.tlk` (DE & EN), `*.dlg`, `*.2da`. + * **Output:** JSON files in `data/raw/`. +2. **Parser (Python):** + * **Input:** Raw JSONs (`tlk` and `dlg`). + * **Logic:** Match IDs across languages, link dialog nodes, map speakers. + * **Output:** `data/processed/dialogs.json`. +3. **Lua Hook (Mod):** + * **Location:** `lua-hook/bg1ee_tts_hook/`. + * **Events:** `OnDialogStart`, `OnDialogNodeChange`. + * **Action:** Write ID to `Infinity_Log`. + +## 3. Technology Stack + +* **Extraction:** Near Infinity (Java Tool). +* **Processing:** Python 3.10+ (Standard Library + `json`). +* **Game Modding:** Lua (embedded in BG1EE). + +## 4. Immediate Roadmap (Phases) + +* **Phase 1: Extract (NOW):** + * Export `dialog.tlk` (DE) -> `data/raw/tlk/dialog_de.json`. + * Export `dialog.tlk` (EN) -> `data/raw/tlk/dialog_en.json`. + * Export all `*.dlg` -> `data/raw/dlg/*.json`. + * (Optional) Export `npc.2da` -> `data/mappings/npc_map.json`. +* **Phase 2: Parser (NEXT):** + * Implement Python parser to merge these inputs into `dialogs.json`. +* **Phase 3: Hook (PARALLEL):** + * Create `dialog.lua` to log dialog events. +* **Phase 4: Offline Rendering Prep (OPTIONAL):** + * Define WAV naming convention and folder structure. + +## 5. Directory Structure +* `docs/`: detailed specs (Architecture, Extraction, Project Plan). +* `data/`: + * `raw/`: Raw exports. + * `processed/`: Final `dialogs.json`. +* `scripts/`: Python ETL scripts. +* `lua-hook/`: The game modification files. \ No newline at end of file diff --git a/README.md b/README.md index 04095ed..a4316e8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # Projektstruktur & README ## 📁 Empfohlene Ordnerstruktur (Best Practice) + ```text bg1ee-tts/ ├── README.md @@ -50,6 +51,7 @@ bg1ee-tts/ # 📘 README.md ## 🎯 BG1EE Dual‑Language TTS Projekt + Dieses Repository enthĂ€lt die vollstĂ€ndige Infrastruktur, um **Baldur's Gate Enhanced Edition (Steam)** automatisch in **Deutsch** und **Englisch** zu vertonen – live wĂ€hrend des Spielens, mit Umschaltung per Hotkey. Ziel: Dialog erscheint im Spiel → ID wird abgefangen → TTS erzeugt Audio → Audio wird abgespielt. @@ -57,58 +59,70 @@ Ziel: Dialog erscheint im Spiel → ID wird abgefangen → TTS erzeugt Audio → --- ## 🚀 Features -- Extraktion aller BG1EE‑Texte (DE & EN) -- Parser fĂŒr TLK + DLG Dateien → JSON‑Datenbank -- TTS‑Backend mit mehreren Engines (Melo, Kokoro, F5‑TTS, Piper) -- Live‑Integration via Lua‑Dialoghook -- PlattformunabhĂ€ngig (Linux: Entwicklung / Windows: Spielen) + +* Extraktion aller BG1EE‑Texte (DE & EN) +* Parser fĂŒr TLK + DLG Dateien → JSON‑Datenbank +* TTS‑Backend mit mehreren Engines (Melo, Kokoro, F5‑TTS, Piper) +* Live‑Integration via Lua‑Dialoghook +* PlattformunabhĂ€ngig (Linux: Entwicklung / Windows: Spielen) --- ## đŸ§© Voraussetzungen + Du benötigst: -- **Baldur's Gate: Enhanced Edition (Steam)** -- **Java 17+** (fĂŒr Near Infinity) -- **Python 3.10+** -- **FastAPI** -- Optional: GPU‑TTS Engines + +* **Baldur's Gate: Enhanced Edition (Steam)** +* **Java 17+** (fĂŒr Near Infinity) +* **Python 3.10+** +* **FastAPI** +* Optional: GPU‑TTS Engines --- ## 🔧 Installation externer Tools + ### Near Infinity (TLK + DLG Viewer/Exporter) + Download: -https://github.com/Argent77/NearInfinity +[https://github.com/Argent77/NearInfinity](https://github.com/Argent77/NearInfinity) ``` wget https://github.com/Argent77/NearInfinity/releases/latest/download/NearInfinity.jar ``` ### WeiDU (Modding Toolkit) + Download: -https://github.com/WeiDUorg/weidu +[https://github.com/WeiDUorg/weidu](https://github.com/WeiDUorg/weidu) --- ## đŸ“„ BG1EE Dateien finden (Steam) + Linux‑Pfad: + ``` ~/.steam/steam/steamapps/common/Baldur's Gate Enhanced Edition/data/ ``` + Windows‑Pfad: + ``` C:\Program Files (x86)\Steam\steamapps\common\Baldur's Gate Enhanced Edition\data ``` Relevante Dateien: -- `lang/de_DE/dialog.tlk` -- `lang/en_US/dialog.tlk` -- `dialog.bif` -- sĂ€mtliche `.dlg` Dateien + +* `lang/de_DE/dialog.tlk` +* `lang/en_US/dialog.tlk` +* `dialog.bif` +* sĂ€mtliche `.dlg` Dateien --- ## đŸ—ïž Projektaufbau + 1. **TLK & DLG exportieren** (Near Infinity) 2. **Parser ausfĂŒhren** → erzeugt `dialogs.json` 3. **TTS‑Service starten** (`uvicorn app.main:app`) @@ -118,28 +132,31 @@ Relevante Dateien: --- ## 📚 Dokumentation -- [docs/architecture.md](docs/architecture.md) -- [docs/extraction-guide.md](docs/extraction-guide.md) -- [docs/tools-installation.md](docs/tools-installation.md) -- [lua-hook-spec.md](docs/lua-hook-spec.md) + +* [docs/architecture.md](docs/architecture.md) +* [docs/extraction-guide.md](docs/extraction-guide.md) +* [docs/tools-installation.md](docs/tools-installation.md) +* [lua-hook-spec.md](docs/lua-hook-spec.md) --- ## 📜 Rechtliches -Dieses Projekt enthĂ€lt **keine Originalspieldateien**. -Alle Extraktionen mĂŒssen lokal auf einem legal erworbenen BGEE‑Spiel erfolgen. + +Dieses Projekt enthĂ€lt **keine Originalspieldateien**. +Alle Extraktionen mĂŒssen lokal auf einem legal erworbenen BGEE‑Spiel erfolgen. Siehe: -- Baldur's Gate EE Copyright © Beamdog -- https://store.steampowered.com/app/228280 + +* Baldur's Gate EE Copyright © Beamdog +* [https://store.steampowered.com/app/228280](https://store.steampowered.com/app/228280) Quellenverlinkungen enthalten nur **offizielle** Hersteller‑Seiten. --- ## đŸ€ Mitwirken + PRs, Issues und Erweiterungen willkommen. Dies ist ein technisches Forschungs‑ und Hobbyprojekt. --- Fertig! - diff --git a/docs/architecture.md b/docs/architecture.md index df815d1..5b071e2 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,3 +1,71 @@ -# Architecture v0.2 +# Architecture v0.3 -Updated... \ No newline at end of file +## Überblick +Diese Version beschreibt ausschließlich: +- Extraktion +- Parser +- Lua-Hook +ohne konkrete TTS-Anbindung. + +--- + +# Komponenten + +## 1. Extraktion (DE/EN) +Quellen: +- dialog.tlk (DE/EN) +- .dlg Dateien +- optional .2da + +Export ĂŒber Near Infinity → JSON. + +--- + +## 2. Parser +Zentrale Aufgabe: alles zu einer zweisprachigen Dialogdatenbank zusammenfĂŒhren. + +### Input +``` +data/raw/tlk/dialog_de.json +data/raw/tlk/dialog_en.json +data/raw/dlg/*.json +``` + +### Output +``` +data/processed/dialogs.json +``` + +### Beispielstruktur +```json +{ + "id": 47119, + "speaker": "Imoen", + "text": { + "de": "Hey, wach auf!", + "en": "Hey, wake up!" + }, + "links": [ + { "type": "next", "id": 47120 } + ] +} +``` + +--- + +## 3. Lua-Hook +Interceptor fĂŒr Dialogwechsel im Spiel. + +### Events +- OnDialogStart() +- OnDialogNodeChange(nodeID) + +### Ausgabe +Nur Logging. + +--- + +## 4. Erweiterbarkeit +- Bulk Rendering +- Live TTS +- BG2EE Support diff --git a/docs/extraction-guide.md b/docs/extraction-guide.md index e434d57..f0505f7 100644 --- a/docs/extraction-guide.md +++ b/docs/extraction-guide.md @@ -1,3 +1,69 @@ -# Extraction Guide v0.2 +# Extraction Guide v0.3 -Steps... \ No newline at end of file +## Ziel +VollstĂ€ndige zweisprachige Daten fĂŒr BGEE extrahieren. + +--- + +# 1. Dateien finden (Steam) + +Linux: +``` +~/.steam/steam/steamapps/common/Baldur's Gate Enhanced Edition/ +``` + +Windows: +``` +C:\Program Files (x86)\Steam\steamapps\common\Baldur's Gate Enhanced Edition\ +``` + +--- + +# 2. Near Infinity starten +Download: +https://github.com/Argent77/NearInfinity + +Start: +``` +java -jar NearInfinity.jar +``` + +--- + +# 3. TLK exportieren + +1. `dialog.tlk` (DE) öffnen +2. Export → JSON +3. Speichern nach: +``` +data/raw/tlk/dialog_de.json +``` + +Wiederholen fĂŒr EN: +``` +data/raw/tlk/dialog_en.json +``` + +--- + +# 4. DLG exportieren +In Near Infinity: +- `.dlg` suchen +- jede Datei exportieren +- speichern in: +``` +data/raw/dlg/ +``` + +--- + +# 5. Optional: NPC Mapping +`npc.2da` → exportieren → JSON: +``` +data/mappings/npc_map.json +``` + +--- + +# Fertig +Parser kann jetzt laufen. diff --git a/docs/lua-hook-spec.md b/docs/lua-hook-spec.md index a07eca1..ec0e2f0 100644 --- a/docs/lua-hook-spec.md +++ b/docs/lua-hook-spec.md @@ -1,3 +1,48 @@ -# Lua Hook Spec v0.2 +# Lua Hook Spec v0.3 -... \ No newline at end of file +## Ziel +Minimaler Listener fĂŒr Dialoge in BGEE. + +--- + +# Dateien + +``` +lua-hook/ + bg1ee_tts_hook/ + dialog.lua + mod.ini +``` + +Installation: +- Linux: ~/.local/share/.../override/ +- Windows: Documents/Baldur's Gate - Enhanced Edition/override/ + +--- + +# Lua API + +### OnDialogStart() +Wird ausgelöst, wenn ein Dialog beginnt. + +### OnDialogNodeChange(nodeID) +Wird ausgelöst, wenn die Dialogzeile wechselt. + +--- + +# Beispiel + +```lua +function OnDialogStart() + Infinity_Log("Dialog started") +end + +function OnDialogNodeChange(node) + Infinity_Log("Node: " .. tostring(node)) +end +``` + +--- + +# Hinweis +Noch **keine** API-Calls, kein TTS, nur Logging. diff --git a/docs/project-plan.md b/docs/project-plan.md new file mode 100644 index 0000000..d13d4e8 --- /dev/null +++ b/docs/project-plan.md @@ -0,0 +1,79 @@ +# Projektplan – BG1EE Dialog-Extraktion & Hook-System (v0.3) + +## 🎯 Ziel +Solide Grundlage schaffen, um spĂ€ter Live-TTS oder Offline-TTS einzubinden – ohne jetzt schon einen TTS-Server zu benötigen. + +--- + +# Phase 1 – Extraktion (JETZT) +Zweisprachige Rohdaten aus BGEE exportieren. + +## Aufgaben +- TLK DE exportieren +- TLK EN exportieren +- Alle DLG-Dateien exportieren +- NPC-Mappings extrahieren (optional) +- Rohdaten nach `data/raw/` speichern + +## Ergebnis +``` +data/raw/tlk/dialog_de.json +data/raw/tlk/dialog_en.json +data/raw/dlg/*.json +data/mappings/npc_map.json +``` + +--- + +# Phase 2 – Parser & Datenmodell (ALS NÄCHSTES) +Parser zusammenbauen, der aus TLK & DLG eine vollstĂ€ndige Dialog-Datenbank erzeugt. + +## Aufgaben +- TLK DE/EN matchen (ID-basiert) +- DialogbĂ€ume verknĂŒpfen +- Sprecher zuordnen (optional) +- finale Struktur in `dialogs.json` schreiben +- Self-Test entwickeln + +## Ergebnis +``` +data/processed/dialogs.json +``` + +--- + +# Phase 3 – Lua-Hook (PARALLEL ODER DANACH) +Minimaler Hook, der Dialogstart und Dialogknotenwechsel erkennt. + +## Aufgaben +- `dialog.lua` schreiben +- `mod.ini` erstellen +- Hook testweise in BGEE installieren +- Log-Ausgabe sicherstellen (kein TTS!) + +## Ergebnis +BGEE schreibt z. B.: +``` +Dialog node changed: 47119 +``` + +--- + +# Phase 4 – (OPTIONAL) Offline-Rendering-Grundlage +Noch kein TTS – aber vorbereiten: + +## Aufgaben +- Namensschema fĂŒr WAV-Dateien definieren +- Ordner anlegen: `audio_de`, `audio_en` +- Prototyp-Skript `render_all.py` vorbereiten (noch ohne Engine) + +--- + +# Phase 5 – (SPÄTER) TTS-Anbindung +Erst wenn die Datenbank + Hook stabil sind. + +--- + +# Aktueller Status +Wir befinden uns am Start von **Phase 1**. + diff --git a/docs/tools-installation.md b/docs/tools-installation.md index 356fd2c..d3a7a85 100644 --- a/docs/tools-installation.md +++ b/docs/tools-installation.md @@ -1,3 +1,51 @@ -# Tools Installation v0.2 +# Tools Installation v0.3 -... \ No newline at end of file +## 1. Java fĂŒr Near Infinity + +Linux: +``` +sudo apt install openjdk-17-jre +``` + +Windows: +https://adoptium.net/ + +--- + +## 2. Near Infinity +Download: +https://github.com/Argent77/NearInfinity + +Start: +``` +java -jar NearInfinity.jar +``` + +--- + +## 3. Python +Linux: +``` +sudo apt install python3 python3-venv python3-pip +``` + +Windows: +https://python.org + +--- + +## 4. Git +``` +sudo apt install git +``` + +Optional: +``` +sudo apt install git-flow +``` + +--- + +## 5. Optional: WeiDU +Download: +https://github.com/WeiDUorg/weidu