@@ -636,6 +712,7 @@ function initLetters() {
card.innerHTML = `
${item.letter}
${item.sound}
+
`;
card.onclick = () => selectLetter(index, card);
grid.appendChild(card);
@@ -875,6 +952,54 @@ function showFeedback(elementId, message, type) {
feedback.style.display = 'none';
}, 3000);
}
+
+// Speech synthesis function
+function speakLetter(letter, button) {
+ // Check if speech synthesis is supported
+ if ('speechSynthesis' in window) {
+ // Cancel any ongoing speech
+ window.speechSynthesis.cancel();
+
+ // Create a new speech utterance
+ const utterance = new SpeechSynthesisUtterance(letter);
+
+ // Set language to Russian
+ utterance.lang = 'ru-RU';
+
+ // Set rate and pitch for child-friendly speech
+ utterance.rate = 0.8; // Slower speed
+ utterance.pitch = 1.2; // Higher pitch for children
+
+ // Add visual feedback
+ if (button) {
+ button.classList.add('speaking');
+ utterance.onend = () => {
+ button.classList.remove('speaking');
+ };
+ utterance.onerror = () => {
+ button.classList.remove('speaking');
+ };
+ }
+
+ // Speak the letter
+ window.speechSynthesis.speak(utterance);
+ } else {
+ // Fallback alert if speech synthesis is not supported
+ alert('Озвучка не поддерживается в этом браузере');
+ }
+}
+
+// Speak the current letter in sound game
+function speakCurrentSoundLetter() {
+ const letter = letters[currentSoundLetterIndex];
+ speakLetter(letter.letter, null);
+}
+
+// Speak the current mirror letter
+function speakMirrorLetter() {
+ const letter = mirrorLetters[currentMirrorIndex];
+ speakLetter(letter.letter, null);
+}