diff --git a/assets/js/main.js b/assets/js/main.js index 66835ff..835a5ee 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -187,8 +187,20 @@ document.addEventListener('DOMContentLoaded', () => { const utterance = new SpeechSynthesisUtterance(text); utterance.lang = locale === 'ar' ? 'ar-SA' : 'en-US'; const voices = window.speechSynthesis.getVoices(); - const preferredVoice = voices.find((voice) => voice.lang.toLowerCase().startsWith(locale === 'ar' ? 'ar' : 'en')); - if (preferredVoice) utterance.voice = preferredVoice; + const langPrefix = locale === 'ar' ? 'ar' : 'en'; + const langVoices = voices.filter(v => v.lang.toLowerCase().startsWith(langPrefix)); + + if (langVoices.length > 0) { + // Try to find a high-quality (Google/Microsoft Natural) voice + const bestVoice = langVoices.find(v => + v.name.includes('Google') || + v.name.includes('Natural') || + v.name.includes('Premium') || + v.name.includes('Online') + ) || langVoices.find(v => v.name.includes('Microsoft')) || langVoices[0]; + + utterance.voice = bestVoice; + } utterance.onend = () => { if (videoPlayer) videoPlayer.volume = 1.0; }; utterance.onerror = () => { if (videoPlayer) videoPlayer.volume = 1.0; }; diff --git a/display.php b/display.php index 72664b3..979ea49 100644 --- a/display.php +++ b/display.php @@ -58,7 +58,7 @@ qh_page_start(
-
+
@@ -82,14 +82,14 @@ qh_page_start(
-
-
-
-
+
+
+
+
-