Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jesterswilde/0486da9046823fb98ae73d56445d405f to your computer and use it in GitHub Desktop.
Save jesterswilde/0486da9046823fb98ae73d56445d405f to your computer and use it in GitHub Desktop.
OGS speaka move
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