import React from'react';import{createRoot}from'react-dom/client';import{HashRouter}from'react-router-dom';import App from'./AppV2.jsx';import'./styles.css';
const voices=[['Algieba','Fluide'],['Leda','Jeune'],['Sulafat','Chaleureuse'],['Puck','Dynamique'],['Achird','Amicale'],['Aoede','Légère'],['Kore','Posée']];let currentAudio=null;
async function geminiSpeak(utterance){const text=utterance?.text||'';if(!text)return;const voice=localStorage.getItem('rohy_voice')||'Algieba',level=localStorage.getItem('rohy_level')||'A1';if(currentAudio){currentAudio.pause();URL.revokeObjectURL(currentAudio.src)}try{const response=await fetch('http://127.0.0.1:8787/api/speech',{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify({text,voice,level})});if(!response.ok){const data=await response.json();throw new Error(data.error||'Voix indisponible')}const url=URL.createObjectURL(await response.blob());currentAudio=new Audio(url);currentAudio.onended=()=>URL.revokeObjectURL(url);await currentAudio.play()}catch(error){alert(`La voix Gemini n’est pas disponible : ${error.message}`)}}
if(window.speechSynthesis){window.speechSynthesis.cancel=()=>currentAudio?.pause();window.speechSynthesis.speak=geminiSpeak}
createRoot(document.getElementById('root')).render(<React.StrictMode><HashRouter><App/></HashRouter></React.StrictMode>);
