Skip to content

Commit

Permalink
reshuffle js documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dhdaines committed Apr 17, 2022
1 parent b17cac4 commit 995445d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 28 deletions.
28 changes: 1 addition & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,33 +82,7 @@ application, which you can launch with `server.py`, and access at
[http://localhost:8000](http://localhost:8000/). It seems to work
fine with recent versions of Chrome, Firefox, and Edge.

By default the library is compiled with `-sMODULARIZE=1`,
meaning that `require('soundswallower.js')` in Node.js will return a
factory function, which, when called, returns a promise that is
resolved after the WASM is loaded and the compiled code is ready to be
invoked, e.g.:

const ssjs = await require("js/soundswallower.js");
let config = new ssjs.Config();
let recognizer = new ssjs.Recognizer(config);
// etc, etc...

For web applications, this function will be available as `Module` in
the global namespace after loading `soundswallower.js`, from a Web
Worker, for instance, and you can also call this asynchronously to get
the instance, for example:

(async () => {
importScripts("js/soundswallower.js");
const ssjs = await Module();
let config = new ssjs.Config();
// etc, etc...
})();

There may be a better way to do this, but I am not yet knowledgeable
enough in JavaScript to say what it is.

The JavaScript API will probably change soon.
For more details on JavaScript, see [the js README](/js/README.md).

Creating binary distributions for Python
========================================
Expand Down
37 changes: 36 additions & 1 deletion js/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,42 @@
SoundSwallower JavaScript
=========================

NOTE: This is untested, not known to work.
SoundSwallower can be compiled to JavaScript and run in Node.js or a
browser (recent versions of Chrome, Firefox, and Edge all seem to
work).

By default the library is compiled with `-sMODULARIZE=1`,
meaning that `require('soundswallower.js')` in Node.js will return a
factory function, which, when called, returns a promise that is
resolved after the WASM is loaded and the compiled code is ready to be
invoked, e.g.:

const ssjs = await require("js/soundswallower.js");
let config = new ssjs.Config();
let recognizer = new ssjs.Recognizer(config);
// etc, etc...

For web applications, this function will be available as `Module` in
the global namespace after loading `soundswallower.js`, from a Web
Worker, for instance, and you can also call this asynchronously to get
the instance, for example:

(async () => {
importScripts("js/soundswallower.js");
const ssjs = await Module();
let config = new ssjs.Config();
// etc, etc...
})();

There may be a better way to do this, but I am not yet knowledgeable
enough in JavaScript to say what it is.

The JavaScript API will probably change soon, so it is, sadly, not
documented here.

The rest of this file is the documentation inherited from
[pocketsphinx.js](http://syl22-00.github.io/pocketsphinx.js/) and will
be subject to change.

Audio Recorder
==============
Expand Down

0 comments on commit 995445d

Please sign in to comment.