How to use the speech-rule-engine.setupEngine function in speech-rule-engine

To help you get started, we’ve selected a few speech-rule-engine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mathjax / MathJax-node / lib / mj-page.js View on Github external
serverState = STATE.BUSY;
  var result = {}, $$ = window.Array, HUB = MathJax.Hub;

  //
  //  Get the math data and callback and set the content
  //
  var item = queue.shift();
  data = item[0]; callback = item[1];
  content.innerHTML = data.html;  //  %%% disable <script> tags?
  html.setAttribute("xmlns:"+data.xmlns,"http://www.w3.org/1998/Math/MathML");

  //
  //  Initialize speech engine
  //
  if (data.speakText)
    speech.setupEngine({semantics:true, domain:data.speakRuleset, style:data.speakStyle});

  //
  //  Set up MathJax
  //
  ConfigureTypeset();

  //
  //  Set up a timeout timer to restart MathJax if it runs too long,
  //  Then push the functions to set the renderer, perform the typesetting,
  //  and process the results.
  //
  timer = setTimeout(RestartMathJax,data.timeout);
  HUB.Queue(
    $$(SetRenderer,data.renderer),
    $$("Typeset",HUB),
    $$(TypesetDone),
github pkra / mathjax-node-sre / lib / main.js View on Github external
const preprocessor = function (data, callback) {
    // setup SRE
    const speechConfig = {
        semantics: true,
        domain: data.speakRuleset || 'mathspeak',
        style: data.speakStyle || 'default',
        semantic: data.semantic,
        minSTree: data.minSTree,
        speakText: true,
        speech: 'deep'
    };
    if (data.speakText === false) speechConfig.speakText = false
    sre.setupEngine(speechConfig);
    // if MathML, enrich and continue
    if (data.format === "MathML") {
        data.speakText = sre.toSpeech(data.math);
        data.math = sre.toEnriched(data.math).toString();
        data.math = data.math.replace(/alttext="(.*?)"/,'alttext="' + data.speakText + '"');
        callback(data);
    } else {
        // convert to MathML, enrich and continue
        const newdata = {
            math: data.math,
            format: data.format,
            mml: true
        };
        mathjax.typeset(newdata, function (result) {
            if (result.error) throw result.error;
            data.speakText = sre.toSpeech(result.mml);