UNPKG

watson-speech

Version:

IBM Watson Speech to Text and Text to Speech SDK for web browsers.

947 lines (248 loc) 13.5 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: TimingStream</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Class: TimingStream</h1> <section> <header> <h2>TimingStream</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="TimingStream"><span class="type-signature"></span>new TimingStream<span class="signature">(opts<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4> <div class="description"> <p>Slows results down to no faster than real time.</p> <p>Useful when running recognizeFile because the text can otherwise appear before the words are spoken</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>opts</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last"> <h6>Properties</h6> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th>Default</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>emitAtt</code></td> <td class="type"> <span class="param-type">*</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> TimingStream.START </td> <td class="description last"><p>set to TimingStream.END to only emit text that has been completely spoken.</p></td> </tr> <tr> <td class="name"><code>delay</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="default"> 0 </td> <td class="description last"><p>Additional delay (in seconds) to apply before emitting words, useful for precise syncing to audio tracks. May be negative</p></td> </tr> </tbody> </table> </td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="speech-to-text_timing-stream.js.html">speech-to-text/timing-stream.js</a>, <a href="speech-to-text_timing-stream.js.html#line18">line 18</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="checkForEnd"><span class="type-signature"></span>checkForEnd<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>Triggers the 'close' and 'end' events if both pre-conditions are true:</p> <ul> <li>the previous stream must have already emitted it's 'end' event</li> <li>there must be no next tick scheduled, indicating that there are no results buffered for later delivery</li> </ul> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="speech-to-text_timing-stream.js.html">speech-to-text/timing-stream.js</a>, <a href="speech-to-text_timing-stream.js.html#line198">line 198</a> </li></ul></dd> </dl> <h4 class="name" id="getCurrentResult"><span class="type-signature"></span>getCurrentResult<span class="signature">(results, cutoff)</span><span class="type-signature"> &rarr; {Object|undefined}</span></h4> <div class="description"> <p>Returns one of:</p> <ul> <li>undefined if the next result is completely later than the current cutoff</li> <li>a cropped clone of the next result if it's later than the current cutoff &amp;&amp; in objectMode</li> <li>the original next result object (removing it from the array) if it's completely earlier than the current cutoff (or we're in string mode with emitAt set to start)</li> </ul> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>results</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"></td> </tr> <tr> <td class="name"><code>cutoff</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="speech-to-text_timing-stream.js.html">speech-to-text/timing-stream.js</a>, <a href="speech-to-text_timing-stream.js.html#line120">line 120</a> </li></ul></dd> </dl> <h5>Returns:</h5> <dl> <dt> Type </dt> <dd> <span class="param-type">Object</span> | <span class="param-type">undefined</span> </dd> </dl> <h4 class="name" id="handleResult"><span class="type-signature"></span>handleResult<span class="signature">(result)</span><span class="type-signature"></span></h4> <div class="description"> <p>Creates a new result with all transcriptions formatted</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>result</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="speech-to-text_timing-stream.js.html">speech-to-text/timing-stream.js</a>, <a href="speech-to-text_timing-stream.js.html#line220">line 220</a> </li></ul></dd> </dl> <h4 class="name" id="scheduleNextTick"><span class="type-signature"></span>scheduleNextTick<span class="signature">(cutoff)</span><span class="type-signature"></span></h4> <div class="description"> <p>Schedules next tick if possible. Requires previous stream to emit recognize objects (objectMode or readableObjectMode)</p> <p>triggers the 'close' and 'end' events if the buffer is empty and no further results are expected</p> </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>cutoff</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="description last"></td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="speech-to-text_timing-stream.js.html">speech-to-text/timing-stream.js</a>, <a href="speech-to-text_timing-stream.js.html#line170">line 170</a> </li></ul></dd> </dl> <h4 class="name" id="tick"><span class="type-signature"></span>tick<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> <p>Tick emits any buffered words that have a timestamp before the current time, then calls scheduleNextTick()</p> </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="speech-to-text_timing-stream.js.html">speech-to-text/timing-stream.js</a>, <a href="speech-to-text_timing-stream.js.html#line137">line 137</a> </li></ul></dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-watson-speech.html">watson-speech</a></li><li><a href="module-watson-speech_speech-to-text.html">watson-speech/speech-to-text</a></li><li><a href="module-watson-speech_speech-to-text_get-models.html">watson-speech/speech-to-text/get-models</a></li><li><a href="module-watson-speech_speech-to-text_recognize-file.html">watson-speech/speech-to-text/recognize-file</a></li><li><a href="module-watson-speech_speech-to-text_recognize-microphone.html">watson-speech/speech-to-text/recognize-microphone</a></li><li><a href="module-watson-speech_text-to-speech.html">watson-speech/text-to-speech</a></li><li><a href="module-watson-speech_text-to-speech_get-voices.html">watson-speech/text-to-speech/get-voices</a></li><li><a href="module-watson-speech_text-to-speech_synthesize.html">watson-speech/text-to-speech/synthesize</a></li></ul><h3>Classes</h3><ul><li><a href="FilePlayer.html">FilePlayer</a></li><li><a href="FormatStream.html">FormatStream</a></li><li><a href="RecognizeStream.html">RecognizeStream</a></li><li><a href="TimingStream.html">TimingStream</a></li><li><a href="WebAudioL16Stream.html">WebAudioL16Stream</a></li><li><a href="WritableElementStream.html">WritableElementStream</a></li></ul><h3>Events</h3><ul><li><a href="RecognizeStream.html#event:close">close</a></li><li><a href="RecognizeStream.html#event:connection-close">connection-close</a></li><li><a href="RecognizeStream.html#event:data">data</a></li><li><a href="RecognizeStream.html#event:error">error</a></li><li><a href="RecognizeStream.html#event:receive-json">receive-json</a></li><li><a href="RecognizeStream.html#event:results">results</a></li><li><a href="RecognizeStream.html#event:send-json">send-json</a></li></ul><h3>Global</h3><ul><li><a href="global.html#getContentTypeFromFile">getContentTypeFromFile</a></li><li><a href="global.html#noTimestamps">noTimestamps</a></li><li><a href="global.html#playFile">playFile</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.2</a> on Thu Oct 06 2016 15:51:39 GMT+0000 (UTC) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>