@@ -1633,9 +1633,17 @@ function initNamePronounce() {
16331633
16341634 const pickVoice = ( ) => {
16351635 if ( ! cachedVoices . length ) return null ;
1636+ const normalized = cachedVoices . map ( ( voice ) => ( {
1637+ voice,
1638+ lang : voice . lang ?. toLowerCase ( ) || "" ,
1639+ name : voice . name ?. toLowerCase ( ) || "" ,
1640+ } ) ) ;
16361641 return (
1637- cachedVoices . find ( ( voice ) => voice . lang ?. toLowerCase ( ) === "en-us" ) ||
1638- cachedVoices . find ( ( voice ) => voice . lang ?. toLowerCase ( ) . startsWith ( "en" ) ) ||
1642+ normalized . find ( ( item ) => item . lang === "en-in" || item . name . includes ( "india" ) ) ?. voice ||
1643+ normalized . find ( ( item ) => item . lang === "hi-in" || item . name . includes ( "hindi" ) ) ?. voice ||
1644+ normalized . find ( ( item ) => item . lang === "en-gb" ) ?. voice ||
1645+ normalized . find ( ( item ) => item . lang === "en-us" ) ?. voice ||
1646+ normalized . find ( ( item ) => item . lang . startsWith ( "en" ) ) ?. voice ||
16391647 null
16401648 ) ;
16411649 } ;
@@ -1665,8 +1673,8 @@ function initNamePronounce() {
16651673 const text = heroName ?. dataset . name || heroName ?. textContent || "Bikram Gole" ;
16661674 const utterance = new SpeechSynthesisUtterance ( text ) ;
16671675 utterance . lang = "en-US" ;
1668- utterance . rate = 0.92 ;
1669- utterance . pitch = 1 ;
1676+ utterance . rate = 1.06 ;
1677+ utterance . pitch = 0.96 ;
16701678 utterance . volume = 1 ;
16711679 const voice = pickVoice ( ) ;
16721680 if ( voice ) utterance . voice = voice ;
@@ -1688,6 +1696,19 @@ function initNamePronounce() {
16881696 speakName ( ) ;
16891697 } ) ;
16901698
1699+ nameSpeakBtn . addEventListener ( "pointerdown" , ( ) => {
1700+ if ( ! cachedVoices . length ) {
1701+ syncVoices ( ) ;
1702+ }
1703+ if ( synth . paused ) {
1704+ try {
1705+ synth . resume ( ) ;
1706+ } catch ( error ) {
1707+ // ignore
1708+ }
1709+ }
1710+ } ) ;
1711+
16911712 window . addEventListener ( "pagehide" , stopSpeech ) ;
16921713 document . addEventListener ( "visibilitychange" , ( ) => {
16931714 if ( document . hidden ) stopSpeech ( ) ;
0 commit comments