add support for premoves in speech synthesis
This commit is contained in:
parent
1b5e83f83f
commit
93408042b6
|
@ -200,6 +200,7 @@ export default class RoundController {
|
|||
this.cancelMove();
|
||||
this.chessground.selectSquare(null);
|
||||
if (!this.jump(ply)) this.redraw();
|
||||
if (this.speech) this.speech.jump(round.plyStep(this.data, ply));
|
||||
};
|
||||
|
||||
isPlaying = () => game.isPlayerPlaying(this.data);
|
||||
|
@ -228,7 +229,6 @@ export default class RoundController {
|
|||
else sound.move();
|
||||
if (/[+#]/.test(s.san)) sound.check();
|
||||
}
|
||||
if (this.speech) this.speech.jump(s);
|
||||
this.autoScroll();
|
||||
if (this.keyboardMove) this.keyboardMove.update(s);
|
||||
return true;
|
||||
|
@ -446,7 +446,7 @@ export default class RoundController {
|
|||
this.onChange();
|
||||
if (this.keyboardMove) this.keyboardMove.update(step);
|
||||
if (this.music) this.music.jump(o);
|
||||
if (this.speech) this.speech.jump(step);
|
||||
if (this.speech) this.speech.jump(step, true);
|
||||
};
|
||||
|
||||
private playPredrop = () => {
|
||||
|
|
|
@ -28,17 +28,19 @@ window.lichess.RoundSpeech = function() {
|
|||
|
||||
const volumeStorage = window.lichess.storage.make('sound-volume');
|
||||
|
||||
function say(text: string) {
|
||||
function say(text: string, queue: boolean = false) {
|
||||
// console.log(`%c${text} ${queue}`, 'color: red');
|
||||
const msg = new SpeechSynthesisUtterance(text);
|
||||
msg.rate = 1.2;
|
||||
msg.volume = parseFloat(volumeStorage.get());
|
||||
synth.cancel();
|
||||
if (!queue) synth.cancel();
|
||||
synth.speak(msg);
|
||||
}
|
||||
|
||||
return {
|
||||
jump(s: Step) {
|
||||
say(s.san ? renderSan(s.san) : 'Game starts');
|
||||
jump(s: Step, queue: boolean = false) {
|
||||
if (!s) return;
|
||||
say(s.san ? renderSan(s.san) : 'Game starts', queue);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue