add: ajout de la fonction d'instruction vocale
This commit is contained in:
12
client/js/guideVoice.js
Normal file
12
client/js/guideVoice.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
/*
|
||||||
|
guideVoice.js
|
||||||
|
|
||||||
|
vocalise les instructions recue du serveur via la synthese vocal du navigateur
|
||||||
|
*/
|
||||||
|
|
||||||
|
export function speakInstruction(texte) {
|
||||||
|
speechSynthesis.cancel();
|
||||||
|
const enonce = new SpeechSynthesisUtterance(texte);
|
||||||
|
enonce.lang = "fr-FR";
|
||||||
|
speechSynthesis.speak(enonce);
|
||||||
|
}
|
||||||
27
server/guideInstruction.js
Normal file
27
server/guideInstruction.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
guideInstruction.js
|
||||||
|
|
||||||
|
sert a envoyer au client guide les instructions
|
||||||
|
*/
|
||||||
|
|
||||||
|
const INSTRUCTION_GUIDE = "instruction";
|
||||||
|
const INSTRUCTION_INTERVAL_MS = 5000;
|
||||||
|
|
||||||
|
|
||||||
|
function startInstructionLoop(wSS, socket, partnerSocket, pairState, getInstructionTexte) {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
if (pairState.gameOver) {
|
||||||
|
clearInterval(interval);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const guideSocket = socket.data.role === "guide" ? socket : partnerSocket;
|
||||||
|
|
||||||
|
const texte = getInstructionText();
|
||||||
|
guideSocket.emit(INSTRUCTION_GUIDE, { texte });
|
||||||
|
}, INSTRUCTION_INTERVAL_MS);
|
||||||
|
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { startInstructionLoop };
|
||||||
Reference in New Issue
Block a user