"""Finish the four outstanding TangoFlux skill sounds, preserving actual planning seeds.""" from concurrent.futures import ThreadPoolExecutor from pathlib import Path import json import numpy as np import requests from scipy.io import wavfile import generate_enemy_sfx as audio ROOT=Path(__file__).resolve().parents[1] DESIGN=ROOT/'Doc/Design/Sound/BattleSkills/Partners' audio.OUT=ROOT/'Tools/output/partner_skill_sfx' audio.BUNDLE=ROOT/'AIClient/Assets/Bundles/Sound/SFX/BattleSkills' LENGTHS={'Sfx_Heal':.55,'Sfx_Slow':.5,'Sfx_Lightning':.38,'Sfx_EnemyHit':.26} def generate(item):return audio.generate((item['seed'],(item['id'],item['prompt'],LENGTHS[item['id']])),seed_base=0) if __name__=='__main__': status=requests.get(audio.BASE+'/api/status',timeout=15).json() if not status.get('ready') or status.get('error'):raise RuntimeError('TangoFlux not ready: '+str(status)) for folder in (DESIGN,audio.OUT,audio.BUNDLE):folder.mkdir(parents=True,exist_ok=True) path=ROOT/'Doc/Design/Sound/BattleSkills/manifest.json';manifest=json.loads(path.read_text(encoding='utf-8')) with ThreadPoolExecutor(max_workers=2) as pool:items=list(pool.map(generate,[item for item in manifest['items'] if item['id'] in LENGTHS])) receipt='Doc/Design/Sound/BattleSkills/Partners/generation.json' (ROOT/receipt).write_text(json.dumps(dict(status='generated',service=audio.BASE,guide=manifest['guide'],items=items),indent=2),encoding='utf-8') rows={item['id']:item for item in items} for item in manifest['items']: if item['id'] in rows: row=rows[item['id']];item['production']=dict(output=row['output'],sha256=row['outputSha256'],receipt=receipt,scope='formal_partner_skills',actualRequest='Actual seed matches the planning seed; full request in receipt.') manifest['status']='generated';path.write_text(json.dumps(manifest,ensure_ascii=False,indent=2)+'\n',encoding='utf-8') preview=[] for item in manifest['items']: _,data=wavfile.read(ROOT/item['production']['output']);preview.extend((data,np.zeros((13230,2),dtype=np.int16))) wavfile.write(DESIGN/'preview_all_nine.wav',44100,np.concatenate(preview))