Documentation fix
This commit is contained in:
8
API.md
8
API.md
@@ -12,7 +12,7 @@
|
|||||||
## ```Module``` object
|
## ```Module``` object
|
||||||
| Function/Object | Description |
|
| Function/Object | Description |
|
||||||
|---|---|
|
|---|---|
|
||||||
| ```Promise<Model> createModel(path: string, url: string, id: string)```<br><br>```Promise<SpkModel> 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:<br>- **path** contains valid model files and **id** is the same, there will not be a fetch from **url**.<br>- **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<Model> createModel(url: string, path: string, id: string)```<br><br>```Promise<SpkModel> 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:<br>- **path** contains valid model files and **id** is the same, there will not be a fetch from **url**.<br>- **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<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```, it will use **model**'s thread if it's the first user of **model**, else it will use a new thread. |
|
| ```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```, 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) <br>```-2```: Error<br>```-1```: Warning<br>```1```: Verbose<br>```2```: More verbose<br>```3```: Debug |
|
| ```setLogLevel(lvl: int)``` | Set Vosk's log level (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 0 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 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*.
|
If you can't set them, you may use a hacky workaround at *src/addCOI.js*.
|
||||||
|
|
||||||
# Compilation
|
# Compilation
|
||||||
|
- Requires ```autotools```'s commands in PATH
|
||||||
- Changing any option to non-default values requires recompilation
|
- 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 &&
|
git clone --depth=1 https://github.com/msqr1/Vosklet &&
|
||||||
cd Vosklet/src &&
|
cd Vosklet/src &&
|
||||||
[Options] ./make
|
[Options] ./make
|
||||||
|
# Example: MAX_MEMORY=350mb MAX_THREADS=2 ./make
|
||||||
```
|
```
|
||||||
| Option | Description | Default value |
|
| 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) |
|
| 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)``` |
|
| JOBS | Set the number of jobs (threads) when building | ```$(nproc)``` |
|
||||||
| EMSDK | Set EMSDK's path (will install EMSDK in root folder if unset) | ```../emsdk``` |
|
| EMSDK | Set EMSDK's path (will install EMSDK in root folder if unset) | ```../emsdk``` |
|
||||||
|
|||||||
@@ -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!
|
- 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
|
- Designed with basic/nothrow exception safety
|
||||||
- See the *examples* folder for examples on using the API.
|
- 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
|
- See the *devel* folder for the newest build (not guaranteed to work) and the JS build script
|
||||||
|
|
||||||
# Compared to vosk-browser
|
# Compared to vosk-browser
|
||||||
@@ -16,6 +17,7 @@
|
|||||||
|
|
||||||
# Basic usage (microphone recognition)
|
# Basic usage (microphone recognition)
|
||||||
- Result are logged to the console.
|
- Result are logged to the console.
|
||||||
|
- Copied from *examples/fromMic.html*
|
||||||
```
|
```
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
@@ -52,9 +54,11 @@
|
|||||||
transferer.port.onmessage = ev => {
|
transferer.port.onmessage = ev => {
|
||||||
recognizer.acceptWaveform(ev.data)
|
recognizer.acceptWaveform(ev.data)
|
||||||
}
|
}
|
||||||
|
// Connect to microphone
|
||||||
micNode.connect(transferer)
|
micNode.connect(transferer)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<!-- Start and create audio context only as a result of user's action -->
|
||||||
<button onclick="start()">Start</button>
|
<button onclick="start()">Start</button>
|
||||||
</head>
|
</head>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="Vosklet.js" async defer></script>
|
<script src="https://cdn.jsdelivr.net/gh/msqr1/Vosklet@1.0.0/Vosklet.js" async defer></script>
|
||||||
<script>
|
<script>
|
||||||
async function start() {
|
async function start() {
|
||||||
// Make sure sample rate matches that in the training data
|
// Make sure sample rate matches that in the training data
|
||||||
@@ -27,14 +26,17 @@
|
|||||||
recognizer.addEventListener("partialResult", ev => {
|
recognizer.addEventListener("partialResult", ev => {
|
||||||
console.log("Partial result: ", ev.detail)
|
console.log("Partial result: ", ev.detail)
|
||||||
})
|
})
|
||||||
// Create a transferer node to get audio data
|
// Create a transferer node to get audio data on the main thread
|
||||||
let transferer = await module.createTransferer(ctx, 128 * 150)
|
let transferer = await module.createTransferer(ctx, 128 * 150)
|
||||||
|
// Recognize data on arrival
|
||||||
transferer.port.onmessage = ev => {
|
transferer.port.onmessage = ev => {
|
||||||
recognizer.acceptWaveform(ev.data)
|
recognizer.acceptWaveform(ev.data)
|
||||||
}
|
}
|
||||||
|
// Connect to microphone
|
||||||
micNode.connect(transferer)
|
micNode.connect(transferer)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<!-- Start and create audio context only as a result of user's action -->
|
||||||
<button onclick="start()">Start</button>
|
<button onclick="start()">Start</button>
|
||||||
</head>
|
</head>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<script src="Vosklet.js" async defer></script>
|
<script src="https://cdn.jsdelivr.net/gh/msqr1/Vosklet@1.0.0/Vosklet.js" async defer></script>
|
||||||
<script>
|
<script>
|
||||||
async function start() {
|
async function start() {
|
||||||
// Make sure sample rate matches that in the training data
|
// Make sure sample rate matches that in the training data
|
||||||
@@ -22,5 +22,6 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
<!-- Start and create audio context only as a result of user's action -->
|
||||||
<button onclick="start()">Start</button>
|
<button onclick="start()">Start</button>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
I have no idea how to do this. HELP!
|
||||||
1
src/make
1
src/make
@@ -4,7 +4,6 @@ MAX_THREADS=${MAX_THREADS:-1}
|
|||||||
EMSDK=${EMSDK:-../emsdk}
|
EMSDK=${EMSDK:-../emsdk}
|
||||||
JOBS=${JOBS:-$(nproc)}
|
JOBS=${JOBS:-$(nproc)}
|
||||||
|
|
||||||
sudo apt install shtool libtool autogen autotools-dev pkg-config make &&
|
|
||||||
if [ $EMSDK != ../emsdk && ! -d $EMSDK ]; then
|
if [ $EMSDK != ../emsdk && ! -d $EMSDK ]; then
|
||||||
echo "Invalid emsdk path"
|
echo "Invalid emsdk path"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Reference in New Issue
Block a user