diff --git a/src/App.jsx b/src/App.jsx index 5551e46..e2fa58e 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1164,14 +1164,22 @@ const App = () => { const speakOriginalWord = (word, strongsNum) => { if (!window.speechSynthesis) return; - window.speechSynthesis.cancel(); + if (window.speechSynthesis.speaking) window.speechSynthesis.cancel(); const lang = strongsNum?.startsWith('H') ? 'he-IL' : 'el-GR'; - const utt = new SpeechSynthesisUtterance(word + ' '); - utt.lang = lang; - // prefer a matching voice if available const voices = window.speechSynthesis.getVoices(); const match = voices.find((v) => v.lang.startsWith(lang.split('-')[0])); + const utt = new SpeechSynthesisUtterance(word + '.'); + utt.lang = lang; + utt.rate = 0.85; if (match) utt.voice = match; + // Chain a silent tail so the audio session fades rather than clicks shut + utt.onend = () => { + const tail = new SpeechSynthesisUtterance(' '); + tail.volume = 0; + tail.lang = lang; + if (match) tail.voice = match; + window.speechSynthesis.speak(tail); + }; window.speechSynthesis.speak(utt); }; @@ -3930,11 +3938,34 @@ const restoreRemoteProject = async (id) => {