How to use the speech-rule-engine.toEnriched 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.

github pkra / mathjax-node-sre / lib / main.js View on Github external
// 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);
            data.math = sre.toEnriched(result.mml).toString();
            data.math = data.math.replace(/alttext="(.*?)"/,'alttext="' + data.speakText + '"');
            data.format = 'MathML';
            callback(data);
github pkra / mathjax-node-sre / lib / main.js View on Github external
mathjax.typeset(newdata, function (result) {
            if (result.error) throw result.error;
            data.speakText = sre.toSpeech(result.mml);
            data.math = sre.toEnriched(result.mml).toString();
            data.math = data.math.replace(/alttext="(.*?)"/,'alttext="' + data.speakText + '"');
            data.format = 'MathML';
            callback(data);
        });
    }

speech-rule-engine

A standalone speech rule engine for XML structures, based on the original engine from ChromeVox.

Apache-2.0
Latest version published 9 days ago

Package Health Score

78 / 100
Full package analysis