diff --git a/API.md b/API.md index 55e7dba..893d786 100644 --- a/API.md +++ b/API.md @@ -12,7 +12,7 @@ ## ```Module``` object | Function/Object | Description | |---|---| -| ```Promise createModel(path: string, url: string, id: string)```

```Promise createSpkModel(path: string, url: string, id: string)``` | Create a ```Model``` or ```SpkModel```, model files must be directly under the model root, and compressed model must be in .tgz format. If:
- **path** contains valid model files and **id** is the same, there will not be a fetch from **url**.
- **path** doesn't contain valid model files, or if it contains valid model files but **id** is different, there will be a fetch from **url**, and the model is stored with **id**. Models are thread-safe, reuse them as much as possible! | +| ```Promise createModel(url: string, path: string, id: string)```

```Promise createSpkModel(url: string, path: string, id: string)``` | Create a ```Model``` or ```SpkModel```, model files must be directly under the model root, and compressed model must be in .tgz format. If:
- **path** contains valid model files and **id** is the same, there will not be a fetch from **url**.
- **path** doesn't contain valid model files, or if it contains valid model files but **id** is different, there will be a fetch from **url**, and the model is stored with **id**. Models are thread-safe, reuse them as much as possible! | | ```Promise createRecognizer(model: Model, sampleRate: float)```

```Promise createRecognizerWithSpkModel(model: Model, spkModel: spkModel, sampleRate: float)```

```Promise createRecognizerWithGrm(model: Model, grammar: string, sampleRate: float)``` | Create a ```Recognizer```, it will use **model**'s thread if it's the first user of **model**, else it will use a new thread. | | ```setLogLevel(lvl: int)``` | Set Vosk's log level (default: ```0```: Info)
```-2```: Error
```-1```: Warning
```1```: Verbose
```2```: More verbose
```3```: Debug | | ```Promise createTransferer(ctx: AudioContext, bufferSize: int)``` | Create a node that transfer its inputs back to the main thread with custom buffer size (must be multiple of 128). Its port's ```onmessage``` handler can be set to get audio data. Has 1 input with 1 channel and 0 output. The the higher the size, the lesser the audio breaks up, but the higher the latency. Recomended value is around ```128 * 150```. | @@ -46,16 +46,18 @@ Vosklet require SharedArrayBuffer to share threads' data, so these response head If you can't set them, you may use a hacky workaround at *src/addCOI.js*. # Compilation +- Requires ```autotools```'s commands in PATH - Changing any option to non-default values requires recompilation -- To re-make a specific target, erase its directory in the repo root and run ```./make``` again +- To re-make a specific target, erase its directory in the repo root and run ```./make``` again. Doing this will also re-make the final JS ``` git clone --depth=1 https://github.com/msqr1/Vosklet && cd Vosklet/src && [Options] ./make +# Example: MAX_MEMORY=350mb MAX_THREADS=2 ./make ``` | Option | Description | Default value | |---|---|---| -| MAX_MEMORY | Set max memory, valid suffixes: kb, mb, gb, tb or none (bytes) | ```375mb```, 300mb as [recommended](https://alphacephei.com/vosk/models) | +| MAX_MEMORY | Set max memory, valid suffixes: kb, mb, gb, tb or none (bytes) | ```300mb``` as [recommended](https://alphacephei.com/vosk/models) | | MAX_THREADS | Set the max number of threads (>=1), this should be equal to the number of model or speaker model that is used in the program | ```1``` (1 recognizer, 1 model, 0 speaker model) | | JOBS | Set the number of jobs (threads) when building | ```$(nproc)``` | | EMSDK | Set EMSDK's path (will install EMSDK in root folder if unset) | ```../emsdk``` | diff --git a/README.md b/README.md index 2992256..905d4ea 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@ - A speech recognizer built on Vosk that can be run on the browser, inspired by [vosk-browser](https://github.com/ccoreilly/vosk-browser), but built from scratch and no code taken! - Designed with basic/nothrow exception safety - See the *examples* folder for examples on using the API. +- See *API.md* for the API reference - See the *devel* folder for the newest build (not guaranteed to work) and the JS build script # Compared to vosk-browser @@ -16,6 +17,7 @@ # Basic usage (microphone recognition) - Result are logged to the console. +- Copied from *examples/fromMic.html* ``` @@ -52,9 +54,11 @@ transferer.port.onmessage = ev => { recognizer.acceptWaveform(ev.data) } + // Connect to microphone micNode.connect(transferer) } + diff --git a/examples/fromMic.html b/examples/fromMic.html index dee48be..f09e01d 100644 --- a/examples/fromMic.html +++ b/examples/fromMic.html @@ -1,7 +1,6 @@ - - + + \ No newline at end of file diff --git a/examples/fromWav.html b/examples/fromWav.html index 3e681af..644ce23 100644 --- a/examples/fromWav.html +++ b/examples/fromWav.html @@ -1,7 +1,7 @@ - + + \ No newline at end of file diff --git a/examples/withSpkModel.html b/examples/withSpkModel.html index e69de29..eda3104 100644 --- a/examples/withSpkModel.html +++ b/examples/withSpkModel.html @@ -0,0 +1 @@ +I have no idea how to do this. HELP! \ No newline at end of file diff --git a/src/make b/src/make index 7c0be10..a256646 100755 --- a/src/make +++ b/src/make @@ -4,7 +4,6 @@ MAX_THREADS=${MAX_THREADS:-1} EMSDK=${EMSDK:-../emsdk} JOBS=${JOBS:-$(nproc)} -sudo apt install shtool libtool autogen autotools-dev pkg-config make && if [ $EMSDK != ../emsdk && ! -d $EMSDK ]; then echo "Invalid emsdk path" exit 1