Skip to content

Commit 70c34bd

Browse files
committed
integrated speech api
1 parent 8bb4bac commit 70c34bd

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/components/LetterAnimation.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,12 @@ const letterMap: LetterMap = {
134134
instructions: ["Draw a straight line up.", "Curve from top to middle.", "Draw a diagonal down."]
135135
},
136136
S: {
137-
paths: [{ d: "M140,50 Q70,30 70,100 Q70,170 140,150", animationDelay: "0s" }],
138-
instructions: ["Curve from top right to bottom left."]
137+
paths: [
138+
{ d: "M140,50 C140,30 60,30 60,70", animationDelay: "0s" },
139+
{ d: "M60,70 C60,110 140,110 140,150", animationDelay: "1s" },
140+
{ d: "M140,150 C140,170 60,170 60,130", animationDelay: "2s" }
141+
],
142+
instructions: ["Start at the top right, curve to the left.", "Curve to the right.", "Curve to the left to finish."]
139143
},
140144
T: {
141145
paths: [

src/pages/varnmala/speak.astro

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,10 @@ import BackButton from "@/components/ui/backButton.astro";
4040
<label>Font Colour:</label>
4141
<input type="color" id="colorPicker" value="#000000" />
4242
</div>
43-
44-
<div class="control-group">
45-
<button id="speakBtn" title="Speak Letter">Speak</button>
46-
</div>
4743
</div>
4844
<Help
4945
title="English Playground"
50-
description="Press any letter from the keyboard to display it. Use the controls to customize the background, font, and color. Click 'Speak' to hear the letter."
46+
description="Press any letter from the keyboard to display it. Use the controls to customize the background, font, and color."
5147
/>
5248
</Fragment>
5349
<BackButton />
@@ -66,7 +62,6 @@ import BackButton from "@/components/ui/backButton.astro";
6662
const fontSelector = document.getElementById("fontSelector") as HTMLSelectElement;
6763
const colorPicker = document.getElementById("colorPicker") as HTMLInputElement;
6864
const toggleBg = document.getElementById("toggleBg") as HTMLButtonElement;
69-
const speakBtn = document.getElementById("speakBtn") as HTMLButtonElement;
7065

7166
const synth = window.speechSynthesis;
7267
let lastKey: string | null = null; // Store the last key pressed
@@ -106,20 +101,14 @@ import BackButton from "@/components/ui/backButton.astro";
106101
setTimeout(() => {
107102
letterDiv.style.animation = "";
108103
}, 300);
104+
speak(letter); // Speak the letter immediately after drawing
109105
}
110106

111107
bgSelector?.addEventListener("change", updateBackground);
112108
fontSelector?.addEventListener("change", updateFont);
113109
colorPicker?.addEventListener("change", updateColor);
114110
toggleBg?.addEventListener("click", toggleBackground);
115111

116-
speakBtn?.addEventListener("click", () => {
117-
const textToSpeak = letterDiv.textContent;
118-
if (textToSpeak) {
119-
speak(textToSpeak);
120-
}
121-
});
122-
123112
document.addEventListener(
124113
"keydown",
125114
(e) => {

0 commit comments

Comments
 (0)