<commit_before>import { Step } from '../interfaces';

const roles: { [letter: string]: string } = { P: 'pawn', R: 'rook', N: 'knight', B: 'bishop', Q: 'queen', K: 'king' };

export function renderSan(san: San) {
  let move: string;
  if (san.includes('O-O-O')) move = 'long castle';
  else if (san.includes('O-O')) move = 'short castle';
  else move = san.replace(/[\+#]/, '').split('').map(c => {
    if (c == 'x') return 'takes';
    if (c == '+') return 'check';
    if (c == '#') return 'checkmate';
    if (c == '=') return 'promotion';
    if (c == '@') return 'at';
    const code = c.charCodeAt(0);
    if (code > 48 && code < 58) return c; // 1-8
    if (code > 96 && code < 105) return c + ' ';
    return roles[c] || c;
  }).join(' ');
  if (san.includes('+')) move += ' check';
  if (san.includes('#')) move += ' checkmate';
  return move;
}

window.lichess.RoundSpeech = function() {

  const synth = window.speechSynthesis;

  const volumeStorage = window.lichess.storage.make('sound-volume');

  function say(text: string) {
    const msg = new SpeechSynthesisUtterance(text);
    msg.rate = 1.2;
    msg.volume = parseFloat(volumeStorage.get());
    synth.cancel();
    synth.speak(msg);
  }

  return {
    jump(s: Step) {
      say(s.san ? renderSan(s.san) : 'Game starts');
    }
  };
}<commit_msg>speech: "A" sounds better than "a"<commit_after>import { Step } from '../interfaces';

const roles: { [letter: string]: string } = { P: 'pawn', R: 'rook', N: 'knight', B: 'bishop', Q: 'queen', K: 'king' };

export function renderSan(san: San) {
  let move: string;
  if (san.includes('O-O-O')) move = 'long castle';
  else if (san.includes('O-O')) move = 'short castle';
  else move = san.replace(/[\+#]/, '').split('').map(c => {
    if (c == 'x') return 'takes';
    if (c == '+') return 'check';
    if (c == '#') return 'checkmate';
    if (c == '=') return 'promotion';
    if (c == '@') return 'at';
    const code = c.charCodeAt(0);
    if (code > 48 && code < 58) return c; // 1-8
    if (code > 96 && code < 105) return c.toUpperCase();
    return roles[c] || c;
  }).join(' ');
  if (san.includes('+')) move += ' check';
  if (san.includes('#')) move += ' checkmate';
  return move;
}

window.lichess.RoundSpeech = function() {

  const synth = window.speechSynthesis;

  const volumeStorage = window.lichess.storage.make('sound-volume');

  function say(text: string) {
    const msg = new SpeechSynthesisUtterance(text);
    msg.rate = 1.2;
    msg.volume = parseFloat(volumeStorage.get());
    synth.cancel();
    synth.speak(msg);
  }

  return {
    jump(s: Step) {
      say(s.san ? renderSan(s.san) : 'Game starts');
    }
  };
}
{'fraction_non_alphanumeric': 0.21441982726248593, 'fraction_numerical': 0.010514457378895982, 'mean_word_length': 3.1366459627329193, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3689092', 'n_tokens_mistral': 999, 'n_tokens_neox': 954, 'n_words': 253}