fix: preserve user-added voice fields across container restarts
generate_voices.py previously overwrote voices.json completely on every start, discarding any manually added temperature/top_k/top_p fields. Now loads existing voices.json first and merges user-added fields into freshly generated entries, so per-voice sampling params survive restarts. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
8cdd81c5e5
commit
4ef2f893a7
@ -20,6 +20,16 @@ SCAN_DIRS = [
|
|||||||
"/voices",
|
"/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 = {}
|
voices = {}
|
||||||
|
|
||||||
|
|
||||||
@ -95,6 +105,13 @@ for scan_dir in SCAN_DIRS:
|
|||||||
with open(txt, encoding="utf-8") as f:
|
with open(txt, encoding="utf-8") as f:
|
||||||
entry["ref_text"] = f.read().strip()
|
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
|
voices[voice_id] = entry
|
||||||
|
|
||||||
with open(output_file, "w", encoding="utf-8") as f:
|
with open(output_file, "w", encoding="utf-8") as f:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user