diff --git a/config/generate_voices.py b/config/generate_voices.py index 45fe7d4..61c2c35 100644 --- a/config/generate_voices.py +++ b/config/generate_voices.py @@ -20,6 +20,16 @@ SCAN_DIRS = [ "/voices", ] +# Load existing voices.json so manually added fields (temperature, top_k, +# top_p, chunk_size overrides, etc.) survive a container restart. +_existing = {} +if os.path.exists(output_file): + try: + with open(output_file, encoding="utf-8") as _f: + _existing = json.load(_f) + except (json.JSONDecodeError, OSError): + pass + voices = {} @@ -95,6 +105,13 @@ for scan_dir in SCAN_DIRS: with open(txt, encoding="utf-8") as f: entry["ref_text"] = f.read().strip() + # Preserve any user-added fields from the previous voices.json + # (temperature, top_k, top_p, chunk_size overrides, etc.) + if voice_id in _existing: + for key, val in _existing[voice_id].items(): + if key not in entry: + entry[key] = val + voices[voice_id] = entry with open(output_file, "w", encoding="utf-8") as f: