Website/node_modules/speech-rule-engine/README.html

211 lines
7 KiB
HTML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>README.html</title>
</head>
<body>
<h1 id="speech-rule-engine">speech-rule-engine</h1>
<p>NodeJS version of the ChromeVox speech rule engine. Forked from ChromeVox release 1.31.0</p>
<p>There are two ways of using this engine. Either as a package via npm or by building it as a standalone tool. The former is the easiest way to use the speech rule engine via its Api and is the preferred option if you just want to include it in your project. The latter is useful if you want to use the speech rule engine in batch mode or interactivley to add your own code.</p>
<h2 id="node-module">Node Module</h2>
<p>Install as a node module using npm:</p>
<pre><code> npm install speech-rule-engine</code></pre>
<p>Then import into a running node or a source file using require:</p>
<pre><code> require(&#39;speech-rule-engine&#39;);
</code></pre>
<h3 id="api">API</h3>
<p>Current API functions are</p>
<pre><code> processExpression(mathml); </code></pre>
<p>Takes a string containing a MathML expression and returns the corresponding speech string.</p>
<pre><code> processFile(input, output);</code></pre>
<p>Takes an input file containing a MathML expression and writes the corresponding speech string to the output file.</p>
<pre><code> setupEngine(options);</code></pre>
<p>Takes an object of option/value pairs to parameterise the Speech Rule Engine. Valid options are:</p>
<table>
<thead>
<tr class="header">
<th align="left">Option</th>
<th align="left">Value</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left"><em>domain</em></td>
<td align="left">Domain or subject area of speech rules (e.g., mathspeak, physics).</td>
</tr>
<tr class="even">
<td align="left"><em>style</em></td>
<td align="left">Style of speech rules (e.g., brief).</td>
</tr>
<tr class="odd">
<td align="left"><em>semantics</em></td>
<td align="left">Boolean flag to swich on semantic interpretation.</td>
</tr>
</tbody>
</table>
<p>Observe that some speech rule domains only make sense with semantics switched on or off and that not every domain implements every style. See also the description of the command line parameters in the next section for more details.</p>
<h2 id="standalone-engine">Standalone Engine</h2>
<p>Node dependencies you have to install:</p>
<pre><code> closure
closurecompiler
closure-library
xmldom
xpath
commander</code></pre>
<p>Using npm run</p>
<pre><code> npm install closure closurecompiler closure-library xmldom xpath commander</code></pre>
<p>In version 1.43 of the closure library there is a mistake in the file</p>
<pre><code>closure-library/closure/bin/build/jscompiler.py </code></pre>
<p>You might need to change</p>
<pre><code># Attempt 32-bit mode if we&#39;re &lt;= Java 1.7
if java_version &gt;= 1.7:
args += [&#39;-d32&#39;]</code></pre>
<p>to</p>
<pre><code># Attempt 32-bit mode if we&#39;re &lt;= Java 1.7
if java_version &lt;= 1.7:
args += [&#39;-d32&#39;]</code></pre>
<h3 id="build">Build</h3>
<p>Depending on your setup you might need to adapt the NODEJS and NODE_MODULES variable in the Makefile. Then simply run</p>
<pre><code>make</code></pre>
<h3 id="run-on-command-line">Run on command line</h3>
<pre><code>bin/sre -i infile -o outfile</code></pre>
<p>As an example run</p>
<pre><code>bin/sre -i samples/sample1.xml -o sample1.txt</code></pre>
<h3 id="run-interactively">Run interactively</h3>
<p>Import into a running node process</p>
<pre><code>require(&#39;./lib/sre4node.js&#39;);</code></pre>
<p>Note, that this will import the full functionality of the speech rule engine in the sre namespace and of the closure library in the goog namespace.</p>
<h3 id="command-line-options">Command Line Options</h3>
<p>The following is a list of command line options for the speech rule engine.</p>
<table>
<thead>
<tr class="header">
<th align="left">Short</th>
<th align="left">Long</th>
<th align="left">Meaning</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="left">-i</td>
<td align="left">--input [name]</td>
<td align="left">Input file [name]</td>
</tr>
<tr class="even">
<td align="left">-o</td>
<td align="left">--output [name]</td>
<td align="left">Output file [name].</td>
</tr>
<tr class="odd">
<td align="left"></td>
<td align="left"></td>
<td align="left">If not given output is printed to stdout.</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left"></td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
</tr>
<tr class="odd">
<td align="left">-d</td>
<td align="left">--domain [name]</td>
<td align="left">Domain or subject area [name].</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
<td align="left">This refers to a particular subject type of speech rules or subject area rules are defined for (e.g., mathspeak, physics).</td>
</tr>
<tr class="odd">
<td align="left"></td>
<td align="left"></td>
<td align="left">If no domain parameter is provided, domain default is used.</td>
</tr>
<tr class="even">
<td align="left">-t</td>
<td align="left">--style [name]</td>
<td align="left">Speech style [name].</td>
</tr>
<tr class="odd">
<td align="left"></td>
<td align="left"></td>
<td align="left">Selects a particular speech style (e.g., brief).</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
<td align="left">If no style parameter is provided, style default is used.</td>
</tr>
<tr class="odd">
<td align="left">-s</td>
<td align="left">--semantics</td>
<td align="left">Switch on semantics interpretation.</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
<td align="left">Note, that some speech rule domains only make sense with semantics switched on or off.</td>
</tr>
<tr class="odd">
<td align="left">-e</td>
<td align="left">--enumerate</td>
<td align="left">Enumerates all available domains and styles.</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
<td align="left">Note that not every style is implemented in every domain.</td>
</tr>
<tr class="odd">
<td align="left"></td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">-v</td>
<td align="left">--verbose</td>
<td align="left">Verbose mode. Print additional information, useful for debugging.</td>
</tr>
<tr class="odd">
<td align="left">-l</td>
<td align="left">--log [name]</td>
<td align="left">Log file [name]. Verbose output is redirected to this file.</td>
</tr>
<tr class="even">
<td align="left"></td>
<td align="left"></td>
<td align="left">If not given verbose output is printed to stdout.</td>
</tr>
<tr class="odd">
<td align="left"></td>
<td align="left"></td>
</tr>
<tr class="even">
<td align="left">-h</td>
<td align="left">--help</td>
<td align="left">output usage information</td>
</tr>
<tr class="odd">
<td align="left">-V</td>
<td align="left">--version</td>
<td align="left">output the version number</td>
</tr>
</tbody>
</table>
</body>
</html>