Created
March 22, 2023 15:38
-
-
Save jesterswilde/0486da9046823fb98ae73d56445d405f to your computer and use it in GitHub Desktop.
OGS speaka move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function speak(text) { | |
const utterance = new SpeechSynthesisUtterance(text); | |
speechSynthesis.speak(utterance); | |
} | |
const letters = ["A", "B", "C", "D","E", "F", "G", "H", "J", "K", "L","M","N","O","P","Q","R","S", "T"] | |
socket.onAny((message,data)=>{ | |
var isMove = message.split('/')[2] === "move" | |
var color = (data.move_number % 2) == 0 ? "White to " : "Black to " | |
if(isMove){ | |
var letter = letters[data.move[0]] | |
var number = 19-data.move[1]; | |
speak(color + letter + number); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment