Tap the mic and just talk. I’ll listen, respond, and speak back to you naturally.
Tap to speak
var vaL=false,vaS=false,vaR=null,vaSyn=window.speechSynthesis,vaM=’voice’,vaH=[],vaV=null,vaI=”;
var vaW=document.getElementById(‘vaWave’);for(var i=0;i<24;i++){var b=document.createElement('div');b.className='va-wave-bar';vaW.appendChild(b)}var vaBars=vaW.querySelectorAll('.va-wave-bar');
function vaLoadV(){var v=vaSyn.getVoices();var p=['Samantha','Karen','Daniel','Google UK English Female','Google US English'];for(var n of p){var f=v.find(function(x){return x.name.includes(n)});if(f){vaV=f;return}}vaV=v.find(function(x){return x.lang.startsWith('en')})||v[0]}vaSyn.onvoiceschanged=vaLoadV;vaLoadV();
var SR=window.SpeechRecognition||window.webkitSpeechRecognition;
if(SR){vaR=new SR();vaR.continuous=false;vaR.interimResults=true;vaR.lang='en-US';vaR.onresult=function(e){var f='',im='';for(var i=e.resultIndex;i<e.results.length;i++){var t=e.results[i][0].transcript;if(e.results[i].isFinal)f+=t;else im+=t}vaI=im;vaUpdStatus(im?'"'+im+'"':'Listening…');if(f.trim()){vaStop();vaHandle(f.trim(),true)}};vaR.onerror=function(e){if(e.error==='no-speech')vaUpdStatus('No speech detected');else if(e.error!=='aborted')vaUpdStatus('Mic error');vaStop()};vaR.onend=function(){if(vaL){vaStop();if(vaI.trim()){vaHandle(vaI.trim(),true);vaI=''}}}}
else{vaSetMode('text')}
function vaSetMode(m){vaM=m;document.querySelectorAll('.va-mode-btn').forEach(function(b){b.classList.toggle('active',b.dataset.mode===m)});var a=document.getElementById('vaInput');a.classList.toggle('va-voice-mode',m==='voice');a.classList.toggle('va-text-mode',m==='text');if(m==='text'&&vaL)vaStop();if(m==='text')document.getElementById('vaTextInput').focus()}
function vaToggle(){if(vaS){vaSyn.cancel();vaS=false;vaUpdOrb('idle')}vaL?vaStop():vaStart()}
function vaStart(){if(!vaR){vaUpdStatus('Voice not supported');return}vaL=true;vaI='';try{vaR.start()}catch(e){vaR.stop();setTimeout(function(){try{vaR.start()}catch(e2){vaUpdStatus('Mic busy')}},200)}vaUpdOrb('listening');vaUpdStatus('Listening…');vaAnim(true)}
function vaStop(){vaL=false;if(vaR)try{vaR.stop()}catch(e){}vaUpdOrb('idle');vaUpdStatus('Tap to speak');vaAnim(false)}
function vaUpdOrb(s){var o=document.getElementById('vaOrb'),r=document.getElementById('vaRing'),mi=document.getElementById('vaMicIcon'),si=document.getElementById('vaStopIcon'),mm=document.getElementById('vaMicMini');o.classList.remove('listening','speaking');r.classList.remove('active');if(s==='listening'){o.classList.add('listening');r.classList.add('active');mi.style.display='none';si.style.display='block';mm.classList.add('listening')}else if(s==='speaking'){o.classList.add('speaking');mi.style.display='block';si.style.display='none';mm.classList.remove('listening')}else{mi.style.display='block';si.style.display='none';mm.classList.remove('listening')}}
function vaUpdStatus(t){document.getElementById('vaStatus').textContent=t}
var vaWI=null;function vaAnim(a){var w=document.getElementById('vaWave');w.classList.toggle('active',a);w.classList.toggle('listening',a&&vaL);if(a){vaWI=setInterval(function(){vaBars.forEach(function(b){b.style.height=(4+Math.random()*22)+'px'})},100)}else{clearInterval(vaWI);vaBars.forEach(function(b){b.style.height='4px'})}}
function vaHideWelcome(){document.getElementById('vaWelcome').classList.add('hidden')}
function vaAddMsg(t,role,isV){vaHideWelcome();var c=document.getElementById('vaMessages'),d=document.createElement('div');d.className='va-msg '+role;var av=document.createElement('div');av.className='va-avatar';av.textContent=role==='ai'?'S':'Y';var co=document.createElement('div');co.className='va-bubble';if(isV){var tg=document.createElement('div');tg.style.cssText='font-size:11px;color:#8e8e8e;margin-bottom:4px';tg.textContent='Voice';co.appendChild(tg)}var p=document.createElement('div');p.textContent=t;co.appendChild(p);d.appendChild(av);d.appendChild(co);c.appendChild(d);vaScrollBottom()}
function vaAddTyping(){vaHideWelcome();var c=document.getElementById('vaMessages'),d=document.createElement('div');d.className='va-msg ai';d.id='vaTyping';var av=document.createElement('div');av.className='va-avatar';av.textContent='S';var co=document.createElement('div');co.className='va-bubble';co.innerHTML='
‘;d.appendChild(av);d.appendChild(co);c.appendChild(d);vaScrollBottom()}
function vaRemoveTyping(){var e=document.getElementById(‘vaTyping’);if(e)e.remove()}
function vaScrollBottom(){var c=document.getElementById(‘vaChat’);requestAnimationFrame(function(){c.scrollTop=c.scrollHeight})}
var vaResps=[‘Hey Steven! I\’m on it.’,’Got it. Want me to dig deeper?’,’Good call. Let me know if you want to adjust.’,’Absolutely. Anything else?’,’Here\’s what I found.’,’Done. Tell me if the tone feels right.’,’Smart question. Here\’s my take.’,’Let me run through the options.’];
function vaGetResp(u){var l=u.toLowerCase();if(l.indexOf(‘schedule’)>=0||l.indexOf(‘calendar’)>=0)return’Looks like you have a pretty open day, Steven. No meetings on the books. Perfect time to knock out some strategic stuff. Want me to block off focus time?’;if(l.indexOf(’email’)>=0||l.indexOf(‘inbox’)>=0)return’I will check your inbox right now. Give me a sec to pull up anything that needs your attention today.’;if(l.indexOf(‘idea’)>=0||l.indexOf(‘content’)>=0||l.indexOf(‘post’)>=0)return’How about a behind-the-scenes reel of the course at golden hour? People eat that stuff up. I can draft a caption and plan the whole post if you want.’;if(l.indexOf(‘focus’)>=0||l.indexOf(‘priorities’)>=0||l.indexOf(‘week’)>=0)return’Top three this week: website updates live, partnership prep, and the social content calendar. Want me to break any of those down?’;return vaResps[Math.floor(Math.random()*vaResps.length)]}
function vaHandle(t,isV){vaAddMsg(t,’user’,isV);vaH.push({role:’user’,content:t});vaAddTyping();setTimeout(function(){vaRemoveTyping();var res=vaGetResp(t);vaH.push({role:’assistant’,content:res});vaAddMsg(res,’ai’,false);if(vaM===’voice’||isV)vaSpeak(res)},800+Math.random()*1200)}
function vaSpeak(t){vaSyn.cancel();var u=new SpeechSynthesisUtterance(t);if(vaV)u.voice=vaV;u.rate=1.05;u.pitch=1;u.onstart=function(){vaS=true;vaUpdOrb(‘speaking’);vaUpdStatus(‘Speaking…’);vaAnim(true)};u.onend=function(){vaS=false;vaUpdOrb(‘idle’);vaUpdStatus(‘Tap to speak’);vaAnim(false)};vaSyn.speak(u)}
function vaSendText(){var i=document.getElementById(‘vaTextInput’);var t=i.value.trim();if(!t)return;i.value=”;vaHandle(t,false)}
function vaQuick(t){vaHandle(t,vaM===’voice’)}