From 410bff9be124fbe39f7cfa9c5fa47bccc81d6f62 Mon Sep 17 00:00:00 2001 From: msqr1 Date: Sun, 2 Jun 2024 02:53:30 -0700 Subject: [PATCH] Remove libarchive, implement untar manually. Use vosk-browser models --- API.md | 11 +++++--- README.md | 14 +++++++--- Vosklet.js | 2 +- examples/Vosklet.js | 2 +- examples/fromMic.html | 9 +++++-- examples/fromWav.html | 7 +++-- src/genericModel.cc | 63 ++++++++++++++----------------------------- src/genericModel.h | 11 +------- src/link.cc | 7 ----- src/link.h | 6 ----- src/make | 18 +++---------- src/util.cc | 47 ++++++++++++++++++++++++++++++++ src/util.h | 15 +++++++++++ test | 8 +++--- 14 files changed, 122 insertions(+), 98 deletions(-) delete mode 100644 src/link.cc delete mode 100644 src/link.h create mode 100644 src/util.cc create mode 100644 src/util.h diff --git a/API.md b/API.md index 3a749cf..843dad7 100644 --- a/API.md +++ b/API.md @@ -12,7 +12,7 @@ ## ```Module``` object | Function/Object | Description | |---|---| -| ```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 and reusable across recognizers.| +| ```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 ```.tar.gz```/```.tgz``` format. Tar format must be USTAR. 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 and reusable across recognizers. | | ```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 reuse the thread from ```model``` if it's the first user of ```model```, else it will use a new thread. | | ```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```. | @@ -54,11 +54,14 @@ Pthread worker construction must be from a blob (see [Emscripten issue](https:// - ```worker-src``` must include ```blob:``` ## Model headers -Fetched models must arrive uncompressed. Set your ```Content-Encoding``` response header appropriately so browers can decompress them. +Model response from ```fetch()``` must be an uncompressed model. Set your ```Content-Encoding``` response header and ```Accept-Encoding``` request header appropriately so browers can decompress. + # Compilation -- Requires ```autotools```'s commands in PATH +- Requires all Autotools commands in PATH, ```make```, and ```pkg-config```. Install with ```apt```, for example: + + ```sudo apt install autotools-dev autoconf libtool make pkg-config``` - 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. Doing this will also re-make the final JS +- To remake a specific target, erase its directory in the repo root and run ```./make``` again. Doing this will also remake the final JS ```shell git clone --depth=1 https://github.com/msqr1/Vosklet && cd Vosklet/src && diff --git a/README.md b/README.md index cc8a581..d3ddac0 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ - Support multiple models - Has models' storage path management - Has models' ID management (for model updates) -- Has smaller JS size (>3.1MB vs 1.4MB gzipped) +- Has smaller JS size (>3.1MB vs 1.2MB gzipped) - Has all related files (pthread worker, audio worklet processor,...) merged - Has faster processing time - Has shorter from-scratch build time @@ -20,13 +20,15 @@ - Result are logged to the console. - Copied from *examples/fromMic.html* ```html + - + + +