import { Say } from 'say';

let voiceEnabled = false;
const say = new Say();

export const setVoiceEnabled = (enabled: boolean) => {
  voiceEnabled = enabled;
};

const speak = (text: string) => {
  if (voiceEnabled) {
    say.speak(text);
  }
};

const stop = () => {
  say.stop();
};

export const narrator = {
  speak,
  stop,
};
