25 lines
979 B
Python
25 lines
979 B
Python
"""Idempotent VoiceStudio patch: CMP's warm pass already owns the active cache."""
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
|
|
def patch_router(path):
|
|
path = Path(path)
|
|
source = path.read_text()
|
|
old = ' prune_cache_dir(cache_dir) # bound disk before this job adds its chapters'
|
|
new = ''' # CMP has already rendered the chapters on all GPUs. Pruning here
|
|
# deletes this job's inputs and silently repeats synthesis on GPU 0.
|
|
# Aletheia removes delivered audio through its acknowledgement cleaner.
|
|
if not os.environ.get("CMP_AUDIOBOOK_GPUS"):
|
|
prune_cache_dir(cache_dir) # bound disk before this job adds its chapters'''
|
|
if new in source:
|
|
return
|
|
if source.count(old) != 1:
|
|
raise RuntimeError('Unexpected VoiceStudio router; patch requires review')
|
|
path.with_suffix('.py.before-cmp-cache-fix').write_text(source)
|
|
path.write_text(source.replace(old, new))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
patch_router(sys.argv[1])
|