# Makes and checks every word the narrator models (and the four names). # A take is kept only when Whisper hears the right word; TH words must also measure as a quiet, # spread hiss (-34 to -18 dB below the vowel). Then chkwords.cjs runs the game's own listener on # every take: F and TH words must come out "soft", S words "sharp", V words "voice". import soundfile as sf, numpy as np, pick from pick import * pick.FB.update({"fifi":"fˈifi","vinny":"vˈɪni","sunny":"sˈʌni","fifi's":"fˈifiz","vinny's":"vˈɪniz","sunny's":"sˈʌniz"}) SAME={"six":{"six"},"sun":{"sun","son"},"fifi's":{"feefies","fifis"},"vinny":{"vinny","vinnie"},"vinny's":{"vinnys","vinnies"},"sunny's":{"sunnys","sunnies"}} def take(w,speeds,tag,pos=None): ps=ph(w); acc=SAME.get(w,{norm(w)}) for maker in (cand_final,cand_mid): for sp in speeds: a=maker(ps,sp); f,e,z=frames(a); pk=e.max(); s=np.where(e>0.02*pk)[0][0]; a=a[max(0,s-2)*f:] if norm(asr(a).replace("6","six").replace("3","three")) not in acc: continue if pos: lv=th_level(a,pos) if lv is None or not -34<=lv<=-18: continue sf.write(f"words/{tag}{w}.wav",a,SR); print("OK",tag+w,maker.__name__,sp); return print("FAIL",tag+w) import os; os.makedirs("words",exist_ok=True) TH={"thumb":"initial","three":"initial","think":"initial","thunder":"initial","thunder's":"initial","bath":"final","teeth":"final","mouth":"final"} PLAIN=["fish","fan","feet","fox","fork","five","van","vase","violin","volcano","sun","sock","soap","soup","six","sandwich"] for w,pos in TH.items(): take(w,[.88,.84,.92,.8],"w_",pos); take(w,[.76,.72,.8,.84],"slow_",pos) for w in PLAIN: take(w,[.88,.84,.92,.8],"w_"); take(w,[.76,.72,.8,.84],"slow_") for w in ["thunder","fifi","fifi's","vinny's","sunny","sunny's"]: take(w,[.92,.96,.88],"n_",TH.get(w)) # quicker takes for running speech for w in ["fifi","fifi's","vinny","vinny's","sunny","sunny's"]: take(w,[.88,.84,.92,.8],"w_")