From 44ffe3b7a739748b27a921c4111b236f81394ae0 Mon Sep 17 00:00:00 2001 From: msqr1 Date: Wed, 4 Sep 2024 23:23:14 -0700 Subject: [PATCH] Update examples and docs --- .gitignore | 4 +--- Documentation.md | 5 +++-- Examples/fromFile.html | 2 +- Examples/fromMic.html | 2 +- README.md | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index b75970c..e068bd6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,9 @@ vosk kaldi .vscode -Models -index2.html +index.html clapack-wasm openfst emsdk -index.html test.js test.wasm \ No newline at end of file diff --git a/Documentation.md b/Documentation.md index 880e358..85a5fff 100644 --- a/Documentation.md +++ b/Documentation.md @@ -12,7 +12,7 @@ | ```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``` | | ```setLogLevel(lvl: int)``` | Set log level for Kaldi messages (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 no output. The the higher the size, the lesser the audio breaks up, but the higher the latency. Recomended value is around ```128 * 150```. | -| ```cleanUp()``` | A convenience function that call ```delete()``` on all objects and revoke all URLs. **Put this at the end of your code!** | +| ```Promise cleanUp()``` | A convenience function that call ```delete()``` on all objects and revoke all URLs. **Put this at the end of your code!** | | ```EpMode``` | Enum for endpointer modes | See Vosk's description | ## ```Model``` object @@ -49,7 +49,8 @@ Vosklet is available only in [secure contexts](https://developer.mozilla.org/en- SharedArrayBuffer is necessary to share data between workers, so these response headers must be set: - ```Cross-Origin-Embedder-Policy``` ⟶ ```require-corp``` - ```Cross-Origin-Opener-Policy``` ⟶ ```same-origin``` -
If you can't set them, you may use a hacky workaround in *AddCOI.js* + +If you can't set them, you may use a hacky workaround in [AddCOI.js](AddCOI.js) ## Content Security Policy (CSP) For those who are using CSP, Vosklet's Wasm worker construction will be from a ```Blob``` which require the CSP ```worker-src``` to include ```blob:``` diff --git a/Examples/fromFile.html b/Examples/fromFile.html index 9f97d83..7165f38 100644 --- a/Examples/fromFile.html +++ b/Examples/fromFile.html @@ -7,7 +7,7 @@ // Make sure sample rate matches that in the training data let ctx = new AudioContext({sampleRate : 16000}) let module = await loadVosklet() - let model = await module.createModel("https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz","model","ID") + let model = await module.createModel("https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz","English","vosk-model-small-en-us-0.15") let recognizer = await module.createRecognizer(model, 16000) // Listen for result and partial result diff --git a/Examples/fromMic.html b/Examples/fromMic.html index ca66f63..e829643 100644 --- a/Examples/fromMic.html +++ b/Examples/fromMic.html @@ -20,7 +20,7 @@ // Load Vosklet module, model and recognizer let module = await loadVosklet() - let model = await module.createModel("https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz","model","ID") + let model = await module.createModel("https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz","English","vosk-model-small-en-us-0.15") let recognizer = await module.createRecognizer(model, 16000) // Listen for result and partial result diff --git a/README.md b/README.md index 7a981cc..2e0ba43 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ // Load Vosklet module, model and recognizer let module = await loadVosklet() - let model = await module.createModel("https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz","model","ID") + let model = await module.createModel("https://ccoreilly.github.io/vosk-browser/models/vosk-model-small-en-us-0.15.tar.gz","English","vosk-model-small-en-us-0.15") let recognizer = await module.createRecognizer(model, 16000) // Listen for result and partial result