4 ms·
I'd love it if you forked my code and managed to fit a full numbers station into 1024KB.
by edent 1y ago
I'd love it if you forked my code and managed to fit a full numbers station into 1024KB.
- genewitch 1y agomy kid wanted it to say point between the groupings, which is the speech engine, so this may sound different depending on your browser: <!DOCTYPE html><html><body><button onclick="f()">Start</button><script> function f(){with(window){ a=new AudioContext;b=a.createBuffer(1,c=2*a.sampleRate,a.sampleRate);d=b.getChannelData(0); for(i=0;i<c;i++)d[i]=(Math.random()*2-1)*.4; e=a.createBufferSource();e.buffer=b;e.loop=1;g=a.createGain();g.gain.value=.05; e.connect(g).connect(a.destination);e.start(); const l=n=>((n.match(/[A-Z]/g)||[]).length==1&&(n[0].match(/[A-Z]/g)||[]).length==1); setInterval(()=>{s=Object.getOwnPropertyNames(globalThis).filter(l).sort(()=>.5-Math.random())[0]; if(Math.random()>.3){ n=String(Math.ceil(Math.random()*1e4).toString().padStart(4,'0')); s=n[0]+'. '+n[1]+'. point. '+n[2]+'. '+n[3]+'.'; } m=new SpeechSynthesisUtterance;m.text=s; v=speechSynthesis.getVoices();m.lang=v[(Math.random()*v.length)|0].lang; m.rate=Math.random();m.pitch=Math.random()*2;speechSynthesis.speak(m);},866); //m.rate=1.7;m.pitch=2;speechSynthesis.speak(m);},866); }}</script></body></html> the comment at the end can be switched with the preceeding line so it sounds like he wanted it to (high pitched and fast, please) <1kb and i got something stuck in my craw about noise so here's one with more accurate noise: <!DOCTYPE html><html><body><button onclick="f()">Start</button><script> function f(){with(window){ a=new AudioContext; g=a.createGain();g.gain.value=.05; h=a.createScriptProcessor(256,1,1);p=0; h.onaudioprocess=e=>{ b=e.outputBuffer.getChannelData(0); for(i=0;i<b.length;i++)b[i]=p+=(Math.random()*2-1)/10; }; h.connect(g).connect(a.destination); const l=n=>((n.match(/[A-Z]/g)||[]).length==1&&(n[0].match(/[A-Z]/g)||[]).length==1); setInterval(()=>{ s=Object.getOwnPropertyNames(globalThis).filter(l).sort(()=>.5-Math.random())[0]; if(Math.random()>.3){ n=String(Math.ceil(Math.random()*1e4).toString().padStart(4,'0')); s=n[0]+'. '+n[1]+'. point. '+n[2]+'. '+n[3]+'.'; } m=new SpeechSynthesisUtterance;m.text=s; v=speechSynthesis.getVoices();m.lang=v[(Math.random()*v.length)|0].lang; m.rate=Math.random();m.pitch=Math.random()*2;speechSynthesis.speak(m); },866); }}</script></body></html> apologies to the HN servers for using 2kb to display these i don't know javascript so apologies if i messed anything up (because it will eventually pop and click which is extremely accurate to numbers station reception but also crashes the page - audio stops.)
- computerthings 1y ago[dead]