Skip to content

Commit

Permalink
docs: correct js docs slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Jan 26, 2023
1 parent 2d7cbe3 commit 27badee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 25 deletions.
20 changes: 0 additions & 20 deletions docs/source/soundswallower.js.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ returns in the usual manner. If this means nothing to you, please
consult
https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous.

By default, a narrow-bandwidth English acoustic model is loaded and
made available. If you want to use a different one, just put it where
your web server can find it, then pass the relative URL to the
directory containing the model files using the `hmm` configuration
parameter and the URL of the dictionary using the `dict` parameter.
Here is an example, presuming that you have downloaded and unpacked
the Brazilian Portuguese model and dictionary from
https://sourceforge.net/projects/cmusphinx/files/Acoustic%20and%20Language%20Models/Portuguese/
and placed them under ``/model`` in your web server root:

.. code-block:: javascript
import createModule from "soundswallower";
// Avoid loading the default model
const soundswallower = { defaultModel: null };
await createModule(soundswallower);
const decoder = new soundswallower.Decoder({hmm: "/model/cmusphinx-pt-br-5.2",
dict: "/model/br-pt.dic"});
await decoder.initialize();
For the moment, to use SoundSwallower with Webpack, an incantation is
required in your `webpack.config.js`. Sorry, I don't make the rules:

Expand Down
12 changes: 7 additions & 5 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,12 @@ import createModule from "soundswallower"; // or whatever name you like
const soundswallower = await createModule();
```

Because it needs access to the compiled WebAssembly code, all of the actual API is
contained within this object that you get back from `createModule`. Now you can
try to initialize a recognizer and recognize some speech.
Because it needs access to the compiled WebAssembly code, all of the actual API
is contained within this object that you get back from `createModule`. Now you
can try to initialize a recognizer and recognize some speech. This is
asynchronous, because it does a bunch of file loading and such, but the rest of
the API isn't, because Javascript promises are not actually coroutines and thus
will block your program even if they appear to be "asynchronous".

```js
let decoder = new soundswallower.Decoder({
Expand Down Expand Up @@ -135,8 +138,7 @@ decoder.stop();
```

The text result can be obtained with `get_text()` or in a more detailed format
with time alignments using `get_alignment()`. These are not asynchronous
methods, as they do not depend on or change the state of the decoder:
with time alignments using `get_alignment()`.

```js
console.log(decoder.get_text());
Expand Down

0 comments on commit 27badee

Please sign in to comment.