@@ -1737,18 +1737,30 @@ function initNamePronounce() {
17371737 }
17381738 }
17391739 const text = heroName ?. dataset . name || heroName ?. textContent || "Bikram Gole" ;
1740- const utterance = new SpeechSynthesisUtterance ( text ) ;
1741- utterance . lang = "en-US" ;
1742- utterance . rate = 1.06 ;
1743- utterance . pitch = 0.96 ;
1744- utterance . volume = 1 ;
17451740 const voice = pickVoice ( ) ;
1746- if ( voice ) utterance . voice = voice ;
1747- utterance . onstart = ( ) => setSpeakingState ( true ) ;
1748- utterance . onend = ( ) => setSpeakingState ( false ) ;
1749- utterance . onerror = ( ) => setSpeakingState ( false ) ;
1741+ const buildUtterance = ( ) => {
1742+ const utterance = new SpeechSynthesisUtterance ( text ) ;
1743+ utterance . lang = voice ?. lang || "en-US" ;
1744+ utterance . rate = 1.06 ;
1745+ utterance . pitch = 0.96 ;
1746+ utterance . volume = 1 ;
1747+ if ( voice ) utterance . voice = voice ;
1748+ utterance . onstart = ( ) => setSpeakingState ( true ) ;
1749+ utterance . onend = ( ) => setSpeakingState ( false ) ;
1750+ utterance . onerror = ( ) => setSpeakingState ( false ) ;
1751+ return utterance ;
1752+ } ;
1753+
1754+ const utterance = buildUtterance ( ) ;
17501755 currentUtterance = utterance ;
17511756 synth . speak ( utterance ) ;
1757+
1758+ window . setTimeout ( ( ) => {
1759+ if ( synth . speaking || synth . pending ) return ;
1760+ const retry = buildUtterance ( ) ;
1761+ currentUtterance = retry ;
1762+ synth . speak ( retry ) ;
1763+ } , 240 ) ;
17521764 } ;
17531765
17541766 nameSpeakBtn . addEventListener ( "click" , ( ) => {
0 commit comments