Files
Athena-Deck/seedvc_worker.py
T

16 lines
1.6 KiB
Python

"""Thin offline wrapper around the unchanged official Seed-VC inference.main."""
import os,sys,json,time,argparse,random
from pathlib import Path
root,folder=map(Path,sys.argv[1:3]);source=root/'source'
os.environ.update(HOME=str(root),HF_HOME=str(root/'hf-home'),HF_HUB_OFFLINE='1',TRANSFORMERS_OFFLINE='1',HF_HUB_DISABLE_IMPLICIT_TOKEN='1',HF_HUB_DISABLE_TELEMETRY='1',OMP_NUM_THREADS='4',MKL_NUM_THREADS='4')
os.chdir(source);sys.path.insert(0,str(source))
import torch,numpy as np,soundfile as sf,inference
if not torch.cuda.is_available():raise RuntimeError('Seed-VC benötigt eine freie RTX3060; kein CPU-Fallback.')
torch.set_num_threads(4);torch.set_num_interop_threads(4);torch.cuda.reset_peak_memory_stats()
random.seed(20261019);np.random.seed(20261019);torch.manual_seed(20261019)
options=json.loads((folder/'options.json').read_text())
args=argparse.Namespace(source=str(folder/'source.wav'),target=str(folder/'reference.wav'),output=str(folder/'output'),diffusion_steps=50,length_adjust=1.0,inference_cfg_rate=0.7,f0_condition=True,auto_f0_adjust=options['pitch_auto'],semi_tone_shift=int(options['pitch_semitones']),checkpoint=None,config=None,fp16=False)
t=time.monotonic();inference.main(args);torch.cuda.synchronize()
p=next((folder/'output').glob('*.wav'));p.replace(folder/'result.wav');(folder/'output').rmdir();info=sf.info(folder/'result.wav')
(folder/'metrics.json').write_text(json.dumps(dict(seconds_including_load=time.monotonic()-t,peak_allocated_bytes=torch.cuda.max_memory_allocated(),peak_reserved_bytes=torch.cuda.max_memory_reserved(),gpu=torch.cuda.get_device_name(),duration=info.duration,frames=info.frames,sample_rate=info.samplerate)))