Update examples and docs
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,11 +1,9 @@
|
|||||||
vosk
|
vosk
|
||||||
kaldi
|
kaldi
|
||||||
.vscode
|
.vscode
|
||||||
Models
|
index.html
|
||||||
index2.html
|
|
||||||
clapack-wasm
|
clapack-wasm
|
||||||
openfst
|
openfst
|
||||||
emsdk
|
emsdk
|
||||||
index.html
|
|
||||||
test.js
|
test.js
|
||||||
test.wasm
|
test.wasm
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
| ```Promise<Recognizer> createRecognizer(model: Model, sampleRate: float)```<br><br>```Promise<Recognizer> createRecognizerWithSpkModel(model: Model, spkModel: spkModel, sampleRate: float)```<br><br>```Promise<Recognizer> createRecognizerWithGrm(model: Model, grammar: string, sampleRate: float)``` | Create a ```Recognizer``` |
|
| ```Promise<Recognizer> createRecognizer(model: Model, sampleRate: float)```<br><br>```Promise<Recognizer> createRecognizerWithSpkModel(model: Model, spkModel: spkModel, sampleRate: float)```<br><br>```Promise<Recognizer> createRecognizerWithGrm(model: Model, grammar: string, sampleRate: float)``` | Create a ```Recognizer``` |
|
||||||
| ```setLogLevel(lvl: int)``` | Set log level for Kaldi messages (default: ```0```: Info) <br>```-2```: Error<br>```-1```: Warning<br>```1```: Verbose<br>```2```: More verbose<br>```3```: Debug |
|
| ```setLogLevel(lvl: int)``` | Set log level for Kaldi messages (default: ```0```: Info) <br>```-2```: Error<br>```-1```: Warning<br>```1```: Verbose<br>```2```: More verbose<br>```3```: Debug |
|
||||||
| ```Promise<AudioWorkletNode> 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```. |
|
| ```Promise<AudioWorkletNode> 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<void> 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 |
|
| ```EpMode``` | Enum for endpointer modes | See Vosk's description |
|
||||||
|
|
||||||
## ```Model``` object
|
## ```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:
|
SharedArrayBuffer is necessary to share data between workers, so these response headers must be set:
|
||||||
- ```Cross-Origin-Embedder-Policy``` ⟶ ```require-corp```
|
- ```Cross-Origin-Embedder-Policy``` ⟶ ```require-corp```
|
||||||
- ```Cross-Origin-Opener-Policy``` ⟶ ```same-origin```
|
- ```Cross-Origin-Opener-Policy``` ⟶ ```same-origin```
|
||||||
<br>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)
|
## 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:```
|
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:```
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
// Make sure sample rate matches that in the training data
|
// Make sure sample rate matches that in the training data
|
||||||
let ctx = new AudioContext({sampleRate : 16000})
|
let ctx = new AudioContext({sampleRate : 16000})
|
||||||
let module = await loadVosklet()
|
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)
|
let recognizer = await module.createRecognizer(model, 16000)
|
||||||
|
|
||||||
// Listen for result and partial result
|
// Listen for result and partial result
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
// Load Vosklet module, model and recognizer
|
// Load Vosklet module, model and recognizer
|
||||||
let module = await loadVosklet()
|
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)
|
let recognizer = await module.createRecognizer(model, 16000)
|
||||||
|
|
||||||
// Listen for result and partial result
|
// Listen for result and partial result
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
// Load Vosklet module, model and recognizer
|
// Load Vosklet module, model and recognizer
|
||||||
let module = await loadVosklet()
|
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)
|
let recognizer = await module.createRecognizer(model, 16000)
|
||||||
|
|
||||||
// Listen for result and partial result
|
// Listen for result and partial result
|
||||||
|
|||||||
Reference in New Issue
Block a user