{"size": 486, "ext": "js", "max_stars_repo_path": "modules/tts.js", "max_stars_repo_name": "jman294/talkback", "max_stars_repo_stars_event_min_datetime": "2017-04-19T12:54:57.000Z", "max_stars_repo_stars_event_max_datetime": "2020-01-17T10:05:38.000Z", "max_issues_repo_path": "modules/tts.js", "max_issues_repo_name": "jman294/talkback", "max_issues_repo_issues_event_min_datetime": "2017-06-01T20:28:30.000Z", "max_issues_repo_issues_event_max_datetime": "2018-01-12T13:52:31.000Z", "max_forks_repo_path": "modules/tts.js", "max_forks_repo_name": "jman294/talkback", "max_forks_repo_forks_event_min_datetime": "2017-05-15T19:54:47.000Z", "max_forks_repo_forks_event_max_datetime": "2017-12-18T16:28:35.000Z"}
{"max_stars_count": 4, "max_issues_count": 3, "max_forks_count": 3, "avg_line_length": 17.3571428571, "max_line_length": 50, "alphanum_fraction": 0.5555555556}
const exec = require('child_process').exec

const tts = (function () {
  const ttsCmd = 'espeak '

  const languages = {
    en: "en-US",
    es: "es"
  }

  function speak (text, language, callback) {
    let cmd = ttsCmd.concat('"'+text+'"')
    if (language !== undefined) {
      cmd = cmd.concat(' -v '+languages[language])
    }
    exec(cmd, function (err) {
      if (err) throw err
      if (callback) callback()
    })
  }

  return {
    speak
  }
})()

module.exports = tts
