Use WASM workers for even smaller size
This commit is contained in:
2
API.md
2
API.md
@@ -71,6 +71,6 @@ cd Vosklet/src &&
|
|||||||
| Option | Description | Default value |
|
| Option | Description | Default value |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| INITIAL_MEMORY | Set inital memory, valid suffixes: kb, mb, gb, tb or none (bytes) | ```300mb``` as [recommended](https://alphacephei.com/vosk/models). This memory will grow if usage exceeds this value, but this may [affect performance](https://github.com/WebAssembly/design/issues/1271). |
|
| INITIAL_MEMORY | Set inital memory, valid suffixes: kb, mb, gb, tb or none (bytes) | ```300mb``` as [recommended](https://alphacephei.com/vosk/models). This memory will grow if usage exceeds this value, but this may [affect performance](https://github.com/WebAssembly/design/issues/1271). |
|
||||||
| MAX_THREADS | Set the max number of threads (>=1), this should be equal to the number of model and speaker model that is used in the program | ```1``` (1 recognizer, 1 model, no speaker model) |
|
| MAX_THREADS | Set the max number of threads (>=1), this should be equal to the number of recognizers used in the program | ```1``` |
|
||||||
| 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``` |
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Binary file not shown.
20
README.md
20
README.md
@@ -1,19 +1,13 @@
|
|||||||
# Overview
|
# Overview
|
||||||
- A lightweight 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 lightweight, up to date speech recognizer in the browser with total gzipped size of **under a megabyte**
|
||||||
- Designed with basic/nothrow exception safety
|
- Built from scratch, inspired by [vosk-browser](https://github.com/ccoreilly/vosk-browser)
|
||||||
- See the *examples* folder for examples on using the API.
|
|
||||||
- See *API.md* for the API reference
|
|
||||||
- See *test* for a developer build script for just the JS
|
|
||||||
|
|
||||||
# Compared to vosk-browser
|
# Vosklet ...
|
||||||
|
- Is regularly maintained
|
||||||
- Support multiple models
|
- Support multiple models
|
||||||
- Has models' storage path management
|
- Include model storage management
|
||||||
- Has models' ID management (for model updates)
|
- Include model ID management (for updates)
|
||||||
- Has smaller JS size (>3.1MB vs 900KB gzipped)
|
- Wraps all Vosk's functionaly
|
||||||
- Has all related files (pthread worker, audio worklet processor,...) merged
|
|
||||||
- Has faster processing time
|
|
||||||
- Has shorter from-scratch build time
|
|
||||||
- Has more Vosk functions exposed
|
|
||||||
|
|
||||||
# Basic usage (microphone recognition in English)
|
# Basic usage (microphone recognition in English)
|
||||||
- Result are logged to the console.
|
- Result are logged to the console.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
BIN
Vosklet.wasm
BIN
Vosklet.wasm
Binary file not shown.
@@ -1,5 +1,5 @@
|
|||||||
#include "Recognizer.h"
|
#include "Recognizer.h"
|
||||||
#include "emscripten/atomic.h"
|
|
||||||
Recognizer::Recognizer(int index, float sampleRate, CommonModel* model) :
|
Recognizer::Recognizer(int index, float sampleRate, CommonModel* model) :
|
||||||
index{index},
|
index{index},
|
||||||
rec{vosk_recognizer_new(std::get<VoskModel*>(model->mdl), sampleRate)}
|
rec{vosk_recognizer_new(std::get<VoskModel*>(model->mdl), sampleRate)}
|
||||||
|
|||||||
64
src/Util.cc
64
src/Util.cc
@@ -1,10 +1,21 @@
|
|||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
#include <emscripten/em_asm.h>
|
#include <emscripten/em_js.h>
|
||||||
ThreadPool globalPool;
|
#include <emscripten/wasm_worker.h>
|
||||||
void fireEv(int index, const char* content, const char* type) {
|
|
||||||
MAIN_THREAD_EM_ASM({
|
WorkerPool globalPool;
|
||||||
objs[$0].dispatchEvent(new CustomEvent($2 === 0 ? "0" : UTF8ToString($2), { "detail" : UTF8ToString($1) }));
|
EM_JS(void, _fireEv, (int index, int content, int type), {
|
||||||
}, index, content, type);
|
objs[index].dispatchEvent(new CustomEvent(type === 0 ? "0" : UTF8ToString(type), { "detail" : UTF8ToString(content) }));
|
||||||
|
})
|
||||||
|
void fireEv(int index, const char* _content, const char* _type) {
|
||||||
|
int content = reinterpret_cast<int>(_content);
|
||||||
|
int type = reinterpret_cast<int>(_type);
|
||||||
|
switch(emscripten_wasm_worker_self_id()) {
|
||||||
|
case 0: [[unlikely]]
|
||||||
|
_fireEv(index, content, type);
|
||||||
|
break;
|
||||||
|
case 1: [[likely]]
|
||||||
|
emscripten_wasm_worker_post_function_viii(0, _fireEv, index, content, type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
int untar(unsigned char* tar, int tarSize, const std::string& storepath) {
|
int untar(unsigned char* tar, int tarSize, const std::string& storepath) {
|
||||||
if(std::memcmp(tar + 257, "ustar", 5)) return IncorrectFormat;
|
if(std::memcmp(tar + 257, "ustar", 5)) return IncorrectFormat;
|
||||||
@@ -46,40 +57,41 @@ int untar(unsigned char* tar, int tarSize, const std::string& storepath) {
|
|||||||
}
|
}
|
||||||
return Successful;
|
return Successful;
|
||||||
}
|
}
|
||||||
void Thread::startup(ThreadPool* pool) {
|
void Worker::startup(int _self, int _pool) {
|
||||||
while(!pool->done) {
|
Worker& self = *reinterpret_cast<Worker*>(_self);
|
||||||
|
WorkerPool& pool = *reinterpret_cast<WorkerPool*>(_pool);
|
||||||
|
while(!pool.done) {
|
||||||
// Wait until unlocked
|
// Wait until unlocked
|
||||||
emscripten_atomic_wait_u32(&pool->qLock, true, -1);
|
emscripten_atomic_wait_u32(&pool.qLock, true, -1);
|
||||||
if(pool->done) break;
|
if(pool.done) break;
|
||||||
// If there is no task then everyone has to wait until there is more
|
// If there is no task then everyone has to wait until there is more
|
||||||
if(pool->taskQ.empty()) {
|
if(pool.taskQ.empty()) {
|
||||||
emscripten_atomic_store_u32(&pool->qLock, true);
|
emscripten_atomic_store_u32(&pool.qLock, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// If this locks, the returned (loaded) value will be false, and we move on
|
// If this locks, the returned (loaded) value will be false, and we move on
|
||||||
if(emscripten_atomic_cas_u32(&pool->qLock, false, true)) continue;
|
if(emscripten_atomic_cas_u32(&pool.qLock, false, true)) continue;
|
||||||
fn = pool->taskQ.front();
|
self.fn = pool.taskQ.front();
|
||||||
pool->taskQ.pop();
|
pool.taskQ.pop();
|
||||||
// Unlock
|
// Unlock
|
||||||
emscripten_atomic_store_u32(&pool->qLock, false);
|
emscripten_atomic_store_u32(&pool.qLock, false);
|
||||||
emscripten_atomic_notify(&pool->qLock, 1);
|
emscripten_atomic_notify(&pool.qLock, 1);
|
||||||
fn();
|
self.fn();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ThreadPool::ThreadPool() {
|
WorkerPool::WorkerPool() {
|
||||||
for(Thread& thrd : threads) {
|
for(int i = 0; i < workers.size(); i++) {
|
||||||
thrd.handle = std::thread{&Thread::startup, &thrd, this};
|
workers[i].handle = emscripten_create_wasm_worker(&stacks[i * workerStack], workerStack);
|
||||||
|
emscripten_wasm_worker_post_function_vii(workers[i].handle, Worker::startup, reinterpret_cast<int>(&workers[i]), reinterpret_cast<int>(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ThreadPool::~ThreadPool() {
|
WorkerPool::~WorkerPool() {
|
||||||
done = true;
|
done = true;
|
||||||
emscripten_atomic_store_u32(&qLock, false);
|
emscripten_atomic_store_u32(&qLock, false);
|
||||||
emscripten_atomic_notify(&qLock, -1);
|
emscripten_atomic_notify(&qLock, -1);
|
||||||
for(Thread& thrd : threads) {
|
emscripten_terminate_all_wasm_workers();
|
||||||
thrd.handle.detach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void ThreadPool::exec(std::function<void()> fn) {
|
void WorkerPool::exec(std::function<void()> fn) {
|
||||||
taskQ.emplace(fn);
|
taskQ.emplace(fn);
|
||||||
emscripten_atomic_store_u32(&qLock, false);
|
emscripten_atomic_store_u32(&qLock, false);
|
||||||
emscripten_atomic_notify(&qLock, 1);
|
emscripten_atomic_notify(&qLock, 1);
|
||||||
|
|||||||
33
src/Util.h
33
src/Util.h
@@ -1,10 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <thread>
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
#include <emscripten/atomic.h>
|
#include <emscripten/atomic.h>
|
||||||
#include <emscripten/console.h>
|
#include <emscripten/console.h>
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
@@ -22,26 +21,28 @@ enum UntarStatus {
|
|||||||
FailedWrite,
|
FailedWrite,
|
||||||
FailedClose
|
FailedClose
|
||||||
};
|
};
|
||||||
struct ThreadPool;
|
struct WorkerPool;
|
||||||
struct Thread {
|
struct Worker {
|
||||||
std::thread handle;
|
int handle;
|
||||||
std::function<void()> fn;
|
std::function<void()> fn;
|
||||||
void startup(ThreadPool* pool);
|
static void startup(int _self, int _pool);
|
||||||
};
|
};
|
||||||
struct ThreadPool {
|
#ifndef MAX_WORKERS
|
||||||
|
#define MAX_WORKERS 1
|
||||||
|
#endif
|
||||||
|
static constexpr int workerStack{65536};
|
||||||
|
static std::array<std::byte, MAX_WORKERS * workerStack> stacks;
|
||||||
|
struct WorkerPool {
|
||||||
bool qLock{true}; // True is locked, false is unlocked
|
bool qLock{true}; // True is locked, false is unlocked
|
||||||
bool done{};
|
bool done{};
|
||||||
std::queue<std::function<void()>> taskQ;
|
std::queue<std::function<void()>> taskQ;
|
||||||
#ifndef MAX_THREADS
|
std::array<Worker, MAX_WORKERS> workers;
|
||||||
#define MAX_THREADS 1
|
#undef MAX_WORKERS
|
||||||
#endif
|
WorkerPool();
|
||||||
std::array<Thread, MAX_THREADS> threads;
|
~WorkerPool();
|
||||||
#undef MAX_THREADS
|
|
||||||
ThreadPool();
|
|
||||||
~ThreadPool();
|
|
||||||
void exec(std::function<void()> fn);
|
void exec(std::function<void()> fn);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ThreadPool globalPool;
|
extern WorkerPool globalPool;
|
||||||
void fireEv(int index, const char* content, const char* type = nullptr);
|
void fireEv(int index, const char* _content, const char* _type = nullptr);
|
||||||
int untar(unsigned char* tar, int tarSize, const std::string& storepath);
|
int untar(unsigned char* tar, int tarSize, const std::string& storepath);
|
||||||
@@ -147,7 +147,4 @@ Module.createRecognizerWithSpkModel = (model, sampleRate, spkModel) => {
|
|||||||
|
|
||||||
Module.createRecognizerWithGrm = (model, sampleRate, grammar) => {
|
Module.createRecognizerWithGrm = (model, sampleRate, grammar) => {
|
||||||
return Recognizer.create(model.obj, sampleRate, 3, grammar, null)
|
return Recognizer.create(model.obj, sampleRate, 3, grammar, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
// See Emscripten issue #21937
|
|
||||||
if (!ENVIRONMENT_IS_PTHREAD) Module['mainScriptUrlOrBlob'] = new Blob([`importScripts('${_scriptName}')`], { type : "text/javascript" })
|
|
||||||
4
src/make
4
src/make
@@ -73,12 +73,12 @@ if [ ! -d "$VOSK" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$SRC" &&
|
cd "$SRC" &&
|
||||||
em++ Util.cc CommonModel.cc Recognizer.cc Bindings.cc -O3 -Wno-pthreads-mem-growth -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 -fno-rtti -DMAX_THREADS="$MAX_THREADS" -sWASMFS -sWASM_BIGINT -sMODULARIZE -sEMBIND_STD_STRING_IS_UTF8 -sPTHREAD_POOL_DELAY_LOAD -sTEXTDECODER=2 -sPTHREAD_POOL_SIZE_STRICT=2 -sINITIAL_MEMORY="$INITIAL_MEMORY" -sALLOW_MEMORY_GROWTH -sPTHREAD_POOL_SIZE="$MAX_THREADS" -sPOLYFILL=0 -sEXIT_RUNTIME=0 -sINVOKE_RUN=0 -sSUPPORT_LONGJMP=0 -sALLOW_BLOCKING_ON_MAIN_THREAD=0 -sEXPORTED_FUNCTIONS=_malloc -sEXPORT_NAME=loadVosklet -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=UTF8ToString,stringToUTF8OnStack -sENVIRONMENT=web,worker -I. -I"$VOSK"/src -L"$KALDI"/src -l:online2/kaldi-online2.a -l:decoder/kaldi-decoder.a -l:ivector/kaldi-ivector.a -l:gmm/kaldi-gmm.a -l:tree/kaldi-tree.a -l:feat/kaldi-feat.a -l:cudamatrix/kaldi-cudamatrix.a -l:lat/kaldi-lat.a -l:lm/kaldi-lm.a -l:rnnlm/kaldi-rnnlm.a -l:hmm/kaldi-hmm.a -l:nnet3/kaldi-nnet3.a -l:transform/kaldi-transform.a -l:matrix/kaldi-matrix.a -l:fstext/kaldi-fstext.a -l:util/kaldi-util.a -l:base/kaldi-base.a -L"$OPENFST"/lib -l:libfst.a -l:libfstngram.a -L"$CLAPACK_WASM" -l:CBLAS/lib/cblas.a -l:CLAPACK-3.2.1/lapack.a -l:CLAPACK-3.2.1/libcblaswr.a -l:f2c_BLAS-3.8.0/blas.a -l:libf2c/libf2c.a -L"$VOSK"/src -l:vosk.a -lembind -pthread -flto -msimd128 -mreference-types -mnontrapping-fptoint -mextended-const -msign-ext -mmutable-globals --pre-js Wrapper.js -o ../Vosklet.js &&
|
em++ Util.cc CommonModel.cc Recognizer.cc Bindings.cc -O3 -Wall -Werror -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 -fno-rtti -DMAX_WORKERS="$MAX_THREADS" -sWASMFS -sWASM_BIGINT -sMODULARIZE -sTEXTDECODER=2 -sWASM_WORKERS=2 -sEVAL_CTORS=2 -sINITIAL_MEMORY="$INITIAL_MEMORY" -sALLOW_MEMORY_GROWTH -sPOLYFILL=0 -sEXIT_RUNTIME=0 -sINVOKE_RUN=0 -sSUPPORT_LONGJMP=0 -sEXPORTED_FUNCTIONS=_malloc -sEXPORT_NAME=loadVosklet -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=UTF8ToString,stringToUTF8OnStack -sENVIRONMENT=web,worker -I. -I"$VOSK"/src -L"$KALDI"/src -l:online2/kaldi-online2.a -l:decoder/kaldi-decoder.a -l:ivector/kaldi-ivector.a -l:gmm/kaldi-gmm.a -l:tree/kaldi-tree.a -l:feat/kaldi-feat.a -l:cudamatrix/kaldi-cudamatrix.a -l:lat/kaldi-lat.a -l:lm/kaldi-lm.a -l:rnnlm/kaldi-rnnlm.a -l:hmm/kaldi-hmm.a -l:nnet3/kaldi-nnet3.a -l:transform/kaldi-transform.a -l:matrix/kaldi-matrix.a -l:fstext/kaldi-fstext.a -l:util/kaldi-util.a -l:base/kaldi-base.a -L"$OPENFST"/lib -l:libfst.a -l:libfstngram.a -L"$CLAPACK_WASM" -l:CBLAS/lib/cblas.a -l:CLAPACK-3.2.1/lapack.a -l:CLAPACK-3.2.1/libcblaswr.a -l:f2c_BLAS-3.8.0/blas.a -l:libf2c/libf2c.a -L"$VOSK"/src -l:vosk.a -lembind -flto -msimd128 -mreference-types -mnontrapping-fptoint -mextended-const -msign-ext -mmutable-globals --pre-js Wrapper.js -o ../Vosklet.js
|
||||||
cd .. &&
|
cd .. &&
|
||||||
rm -f Vosklet.worker.js
|
rm -f Vosklet.worker.js
|
||||||
|
|
||||||
cp Vosklet.js Examples/Vosklet.js &&
|
cp Vosklet.js Examples/Vosklet.js &&
|
||||||
cp Vosklet.wasm Example/Vosklet.wasm &&
|
cp Vosklet.wasm Examples/Vosklet.wasm &&
|
||||||
|
|
||||||
# Can't serve files from raw.githubusercontent with Content-Encoding: gzip header so the browser won't decompress automatically. Manually decompressing instead.
|
# Can't serve files from raw.githubusercontent with Content-Encoding: gzip header so the browser won't decompress automatically. Manually decompressing instead.
|
||||||
sed -i 's/res.body/new Response(res.body.pipeThrough(new DecompressionStream("gzip"))).body/' Examples/Vosklet.js &&
|
sed -i 's/res.body/new Response(res.body.pipeThrough(new DecompressionStream("gzip"))).body/' Examples/Vosklet.js &&
|
||||||
|
|||||||
6
test
6
test
@@ -39,11 +39,9 @@ cd src &&
|
|||||||
MODE=1 && # 0: Ultra debug info, 1: Optimized release, else custom
|
MODE=1 && # 0: Ultra debug info, 1: Optimized release, else custom
|
||||||
echo "Mode = $MODE" &&
|
echo "Mode = $MODE" &&
|
||||||
if [ "$MODE" = 0 ]; then
|
if [ "$MODE" = 0 ]; then
|
||||||
em++ Util.cc CommonModel.cc Recognizer.cc Bindings.cc -O0 -Wno-pthreads-mem-growth -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 -fno-rtti -DMAX_THREADS="$MAX_THREADS" -Wall -Werror -Wno-pthreads-mem-growth -sWASMFS -sWASM_BIGINT -sMODULARIZE -sEMBIND_STD_STRING_IS_UTF8 -sPTHREAD_POOL_DELAY_LOAD -sRUNTIME_DEBUG -sALLOW_MEMORY_GROWTH -sSTACK_OVERFLOW_CHECK=2 -sTEXTDECODER=2 -sPTHREAD_POOL_SIZE_STRICT=2 -sASSERTIONS=2 -sINITIAL_MEMORY="$INITIAL_MEMORY" -sPTHREAD_POOL_SIZE="$MAX_THREADS" -sDISABLE_EXCEPTION_CATCHING=0 -sEXIT_RUNTIME=0 -sINVOKE_RUN=0 -sPOLYFILL=0 -sALLOW_BLOCKING_ON_MAIN_THREAD=0 -sEXPORTED_FUNCTIONS=_malloc -sEXPORT_NAME=loadVosklet -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=UTF8ToString,stringToUTF8OnStack -sENVIRONMENT=web,worker -I. -I"$VOSK"/src -L"$KALDI"/src -l:online2/kaldi-online2.a -l:decoder/kaldi-decoder.a -l:ivector/kaldi-ivector.a -l:gmm/kaldi-gmm.a -l:tree/kaldi-tree.a -l:feat/kaldi-feat.a -l:cudamatrix/kaldi-cudamatrix.a -l:lat/kaldi-lat.a -l:lm/kaldi-lm.a -l:rnnlm/kaldi-rnnlm.a -l:hmm/kaldi-hmm.a -l:nnet3/kaldi-nnet3.a -l:transform/kaldi-transform.a -l:matrix/kaldi-matrix.a -l:fstext/kaldi-fstext.a -l:util/kaldi-util.a -l:base/kaldi-base.a -L"$OPENFST"/lib -l:libfst.a -l:libfstngram.a -L"$CLAPACK_WASM" -l:CBLAS/lib/cblas.a -l:CLAPACK-3.2.1/lapack.a -l:CLAPACK-3.2.1/libcblaswr.a -l:f2c_BLAS-3.8.0/blas.a -l:libf2c/libf2c.a -L"$VOSK"/src -l:vosk.a -lembind -pthread -flto -fsanitize=undefined -fsanitize=address -fsanitize=leak -msimd128 -mreference-types -mnontrapping-fptoint -mextended-const -msign-ext -mmutable-globals -g3 --pre-js Wrapper.js -o ../test.js
|
em++ Util.cc CommonModel.cc Recognizer.cc Bindings.cc -O0 -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 -fno-rtti -DMAX_WORKERS="$MAX_THREADS" -sWASMFS -sWASM_BIGINT -sMODULARIZE -sTEXTDECODER=2 -sWASM_WORKERS=2 -sEVAL_CTORS=2 -sSTACK_OVERFLOW_CHECK=2 -sASSERTIONS=2 -sINITIAL_MEMORY="$INITIAL_MEMORY" -sALLOW_MEMORY_GROWTH -sRUNTIME_DEBUG -sPOLYFILL=0 -sEXIT_RUNTIME=0 -sINVOKE_RUN=0 -sDISABLE_EXCEPTION_CATCHING=0 -sEXPORTED_FUNCTIONS=_malloc -sEXPORT_NAME=loadVosklet -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=UTF8ToString -sENVIRONMENT=web,worker -I. -I"$VOSK"/src -L"$KALDI"/src -l:online2/kaldi-online2.a -l:decoder/kaldi-decoder.a -l:ivector/kaldi-ivector.a -l:gmm/kaldi-gmm.a -l:tree/kaldi-tree.a -l:feat/kaldi-feat.a -l:cudamatrix/kaldi-cudamatrix.a -l:lat/kaldi-lat.a -l:lm/kaldi-lm.a -l:rnnlm/kaldi-rnnlm.a -l:hmm/kaldi-hmm.a -l:nnet3/kaldi-nnet3.a -l:transform/kaldi-transform.a -l:matrix/kaldi-matrix.a -l:fstext/kaldi-fstext.a -l:util/kaldi-util.a -l:base/kaldi-base.a -L"$OPENFST"/lib -l:libfst.a -l:libfstngram.a -L"$CLAPACK_WASM" -l:CBLAS/lib/cblas.a -l:CLAPACK-3.2.1/lapack.a -l:CLAPACK-3.2.1/libcblaswr.a -l:f2c_BLAS-3.8.0/blas.a -l:libf2c/libf2c.a -L"$VOSK"/src -l:vosk.a -lembind -flto -msimd128 -mreference-types -mnontrapping-fptoint -mextended-const -msign-ext -mmutable-globals --pre-js Wrapper.js -o ../test.js
|
||||||
elif [ "$MODE" = 1 ]; then
|
elif [ "$MODE" = 1 ]; then
|
||||||
em++ Util.cc CommonModel.cc Recognizer.cc Bindings.cc -O3 -Wno-pthreads-mem-growth -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 -fno-rtti -DMAX_THREADS="$MAX_THREADS" -sWASMFS -sWASM_BIGINT -sMODULARIZE -sEMBIND_STD_STRING_IS_UTF8 -sPTHREAD_POOL_DELAY_LOAD -sTEXTDECODER=2 -sPTHREAD_POOL_SIZE_STRICT=2 -sINITIAL_MEMORY="$INITIAL_MEMORY" -sALLOW_MEMORY_GROWTH -sPTHREAD_POOL_SIZE="$MAX_THREADS" -sPOLYFILL=0 -sEXIT_RUNTIME=0 -sINVOKE_RUN=0 -sSUPPORT_LONGJMP=0 -sALLOW_BLOCKING_ON_MAIN_THREAD=0 -sEXPORTED_FUNCTIONS=_malloc -sEXPORT_NAME=loadVosklet -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=UTF8ToString,stringToUTF8OnStack -sENVIRONMENT=web,worker -I. -I"$VOSK"/src -L"$KALDI"/src -l:online2/kaldi-online2.a -l:decoder/kaldi-decoder.a -l:ivector/kaldi-ivector.a -l:gmm/kaldi-gmm.a -l:tree/kaldi-tree.a -l:feat/kaldi-feat.a -l:cudamatrix/kaldi-cudamatrix.a -l:lat/kaldi-lat.a -l:lm/kaldi-lm.a -l:rnnlm/kaldi-rnnlm.a -l:hmm/kaldi-hmm.a -l:nnet3/kaldi-nnet3.a -l:transform/kaldi-transform.a -l:matrix/kaldi-matrix.a -l:fstext/kaldi-fstext.a -l:util/kaldi-util.a -l:base/kaldi-base.a -L"$OPENFST"/lib -l:libfst.a -l:libfstngram.a -L"$CLAPACK_WASM" -l:CBLAS/lib/cblas.a -l:CLAPACK-3.2.1/lapack.a -l:CLAPACK-3.2.1/libcblaswr.a -l:f2c_BLAS-3.8.0/blas.a -l:libf2c/libf2c.a -L"$VOSK"/src -l:vosk.a -lembind -pthread -flto -msimd128 -mreference-types -mnontrapping-fptoint -mextended-const -msign-ext -mmutable-globals --pre-js Wrapper.js -o ../test.js
|
em++ Util.cc CommonModel.cc Recognizer.cc Bindings.cc -O3 -Wall -Werror -DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 -fno-rtti -DMAX_WORKERS="$MAX_THREADS" -sWASMFS -sWASM_BIGINT -sMODULARIZE -sTEXTDECODER=2 -sWASM_WORKERS=2 -sEVAL_CTORS=2 -sINITIAL_MEMORY="$INITIAL_MEMORY" -sALLOW_MEMORY_GROWTH -sPOLYFILL=0 -sEXIT_RUNTIME=0 -sINVOKE_RUN=0 -sSUPPORT_LONGJMP=0 -sEXPORTED_FUNCTIONS=_malloc -sEXPORT_NAME=loadVosklet -sMALLOC=emmalloc -sEXPORTED_RUNTIME_METHODS=UTF8ToString,stringToUTF8OnStack -sENVIRONMENT=web,worker -I. -I"$VOSK"/src -L"$KALDI"/src -l:online2/kaldi-online2.a -l:decoder/kaldi-decoder.a -l:ivector/kaldi-ivector.a -l:gmm/kaldi-gmm.a -l:tree/kaldi-tree.a -l:feat/kaldi-feat.a -l:cudamatrix/kaldi-cudamatrix.a -l:lat/kaldi-lat.a -l:lm/kaldi-lm.a -l:rnnlm/kaldi-rnnlm.a -l:hmm/kaldi-hmm.a -l:nnet3/kaldi-nnet3.a -l:transform/kaldi-transform.a -l:matrix/kaldi-matrix.a -l:fstext/kaldi-fstext.a -l:util/kaldi-util.a -l:base/kaldi-base.a -L"$OPENFST"/lib -l:libfst.a -l:libfstngram.a -L"$CLAPACK_WASM" -l:CBLAS/lib/cblas.a -l:CLAPACK-3.2.1/lapack.a -l:CLAPACK-3.2.1/libcblaswr.a -l:f2c_BLAS-3.8.0/blas.a -l:libf2c/libf2c.a -L"$VOSK"/src -l:vosk.a -lembind -flto -msimd128 -mreference-types -mnontrapping-fptoint -mextended-const -msign-ext -mmutable-globals --pre-js Wrapper.js -o ../test.js
|
||||||
else
|
|
||||||
:
|
|
||||||
fi
|
fi
|
||||||
sed -i 's/res.body/new Response(res.body.pipeThrough(new DecompressionStream("gzip"))).body/' ../test.js
|
sed -i 's/res.body/new Response(res.body.pipeThrough(new DecompressionStream("gzip"))).body/' ../test.js
|
||||||
rm -f ../test.worker.js
|
rm -f ../test.worker.js
|
||||||
Reference in New Issue
Block a user