← Files EvO QPH 03ARCHIVED FILE

assets/avatar-widget.html

3.18 KB · Nov 30, 2026 · 07:43 UTC

↓ Download file

<!doctype html>
<html lang="cs">
<head>
<meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
<style>
:root{color-scheme:dark;font:14px system-ui,sans-serif}body{margin:0;padding:18px;background:#0d1210;color:#edf4e4}main{max-width:720px;margin:auto;text-align:center}.avatar{width:min(220px,58vw);height:min(220px,58vw);margin:auto;border-radius:50%;overflow:hidden;border:1px solid #9fbe67;background:#151c17}.avatar img,.avatar video{width:100%;height:100%;object-fit:cover}.avatar video{display:none}.avatar.speaking img{display:none}.avatar.speaking video{display:block}.caption{margin:16px auto;padding:13px 16px;min-height:48px;text-align:left;white-space:pre-wrap;border-left:3px solid #cbe782;border-radius:8px;background:#17221b;line-height:1.55}.controls{display:flex;gap:10px;align-items:center;justify-content:center;flex-wrap:wrap}button,input{font:inherit}button{border:1px solid #536a45;border-radius:7px;background:#1a281e;color:#e9f2df;padding:8px 12px;cursor:pointer}button:hover{border-color:#cbe782}label{color:#aabb9d;font-size:12px}input{accent-color:#cbe782}
</style>
</head>
<body><main aria-label="EvO QPH avatarový výsledek">
  <div id="avatar" class="avatar"><video id="motion" muted playsinline loop preload="metadata" poster="./avatar_idle.jpg"></video><img id="idle" src="./avatar_idle.jpg" alt="EvO QPH"></div>
  <div id="caption" class="caption" aria-live="polite"></div>
  <div class="controls"><label>Hlasitost <input id="volume" type="range" min="0" max="1" step=".01" value=".8"></label><button id="replay" type="button">Přehrát znovu</button></div>
</main>
<script>
(() => {
  const $=s=>document.querySelector(s), avatar=$('#avatar'), video=$('#motion'), img=$('#idle'), caption=$('#caption'), audio=new Audio();
  const state={text:'',lang:'cs',volume:.8};
  const root=(typeof window!=='undefined'&&window.openai)||null;
  video.src='./avatar_speaking_loop.mp4'; video.playbackRate=.6;
  $('#volume').addEventListener('input',e=>{state.volume=Number(e.target.value);audio.volume=state.volume});
  function idle(){avatar.classList.remove('speaking');video.pause();try{video.currentTime=0}catch(_){}}
  function say(text,language){state.text=String(text||'');state.lang=language||'cs';caption.textContent=state.text;audio.pause();audio.src='';
    if('speechSynthesis' in window && state.text){const u=new SpeechSynthesisUtterance(state.text);u.lang=state.lang==='en'?'en-US':'cs-CZ';u.rate=1;u.volume=state.volume;u.onstart=()=>{avatar.classList.add('speaking');video.play().catch(()=>{})};u.onend=idle;speechSynthesis.cancel();speechSynthesis.speak(u)}
    else {avatar.classList.add('speaking');video.play().catch(()=>{});setTimeout(idle,Math.max(1800,state.text.split(/\s+/).length*280))}
  }
  function render(output){if(!output)return;const data=output.structuredContent||output;const text=data.speech_text||data.text||'';say(text,data.language);if(data.status)caption.textContent=`${data.status}\n${text}`}
  if(root?.toolOutput)render(root.toolOutput);
  window.addEventListener('message',e=>{if(e.data?.type==='ui/notifications/tool-result')render(e.data.result)});
  $('#replay').addEventListener('click',()=>say(state.text,state.lang));
})();
</script></body></html>

SHA-256: 50230a408b9a969a21344803d0030408709abb38b6c5353c72399796e402664b