diff --git a/README.md b/README.md index dfe7d19..3b10a73 100644 --- a/README.md +++ b/README.md @@ -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 ======================================== diff --git a/js/README.md b/js/README.md index 42e3da0..89fc304 100644 --- a/js/README.md +++ b/js/README.md @@ -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 ==============