Update 2025-04-13_17:31:30
This commit is contained in:
14
static/sound.js
Normal file
14
static/sound.js
Normal file
@ -0,0 +1,14 @@
|
||||
export function playSound(name) {
|
||||
const text = name === "correct" ? "Correct" : name === "wrong" ? "Wrong" : name;
|
||||
const utterance = new SpeechSynthesisUtterance(text);
|
||||
utterance.lang = "en-US";
|
||||
|
||||
const voices = speechSynthesis.getVoices();
|
||||
const robotVoice = voices.find(v =>
|
||||
v.name.toLowerCase().includes("google") || v.name.toLowerCase().includes("robot")
|
||||
);
|
||||
|
||||
if (robotVoice) utterance.voice = robotVoice;
|
||||
speechSynthesis.speak(utterance);
|
||||
}
|
||||
|
Reference in New Issue
Block a user