Tried closure compiler, but it doesn't reduce the size as much as expected, and it breaks many things. Tried -Oz, but it only reduces 200kb.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -6,4 +6,5 @@ libarchive
|
|||||||
.vscode
|
.vscode
|
||||||
clapack-wasm
|
clapack-wasm
|
||||||
openfst
|
openfst
|
||||||
emsdk
|
emsdk
|
||||||
|
devel
|
||||||
@@ -38,7 +38,7 @@ Browser-recognizer needs the Emscripten WASMFS' OPFS to store its model, IDBFS w
|
|||||||
| ```Promise<Recognizer> makeRecognizer(model: Model, sampleRate: float)``` | Make 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> makeRecognizer(model: Model, sampleRate: float)``` | Make 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 |
|
||||||
| ```revokeURLs()``` | Revoke the Blob URLs of pthread worker and worklet processor |
|
| ```revokeURLs()``` | Revoke the Blob URLs of pthread worker and worklet processor |
|
||||||
| ```cleanUp()``` | A convenient function that call ```revokeURLs()``` and ```delete()``` on all objects and . You should put this at the end of your program! |
|
| ```cleanUp()``` | A convenience function that call ```revokeURLs()``` and ```delete()``` on all objects and . You should put this at the end of your program! |
|
||||||
|
|
||||||
## ```Recognizer``` object
|
## ```Recognizer``` object
|
||||||
| Function signature | Description |
|
| Function signature | Description |
|
||||||
|
|||||||
@@ -28,10 +28,13 @@ bool genericModel::checkModel() {
|
|||||||
}
|
}
|
||||||
void genericModel::afterFetch() {
|
void genericModel::afterFetch() {
|
||||||
thrd.setTask1([this](){
|
thrd.setTask1([this](){
|
||||||
if(!extractModel()) {
|
if(!extractModel() && fs::remove("/opfs/m0dEl.tzst",tank)) {
|
||||||
fireEv("_continue", "Unable to extract model and delete .tzst file", index);
|
fs::current_path("/opfs");
|
||||||
|
fs::remove_all(storepath);
|
||||||
|
fireEv("_continue", "Unable to extract model", index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
fs::remove("/opfs/m0dEl.tzst",tank);
|
||||||
std::ofstream idFile("id");
|
std::ofstream idFile("id");
|
||||||
if(!idFile.is_open()) {
|
if(!idFile.is_open()) {
|
||||||
fs::current_path("/opfs");
|
fs::current_path("/opfs");
|
||||||
@@ -41,17 +44,13 @@ void genericModel::afterFetch() {
|
|||||||
}
|
}
|
||||||
idFile << id;
|
idFile << id;
|
||||||
idFile.close();
|
idFile.close();
|
||||||
char a[3] {};
|
// I wanna give up on this thing so bad...
|
||||||
int fd = open("./conf/model.conf", O_RDONLY);
|
|
||||||
read(fd, a, 3);
|
|
||||||
emscripten_console_log(a);
|
|
||||||
close(fd);
|
|
||||||
std::ifstream is("./conf/model.conf");
|
std::ifstream is("./conf/model.conf");
|
||||||
emscripten_console_logf("%d", is.good());
|
emscripten_console_logf("%d", is.good());
|
||||||
emscripten_console_logf("%d", is.bad());
|
emscripten_console_logf("%d", is.bad());
|
||||||
emscripten_console_logf("%d", is.eof());
|
emscripten_console_logf("%d", is.eof());
|
||||||
emscripten_console_logf("%d", is.fail());
|
emscripten_console_logf("%d", is.fail());
|
||||||
|
is.close();
|
||||||
//load(false);
|
//load(false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -68,9 +67,9 @@ bool genericModel::extractModel() {
|
|||||||
// Strip first component, keep relative path
|
// Strip first component, keep relative path
|
||||||
path = "." + path.substr(path.find("/"));
|
path = "." + path.substr(path.find("/"));
|
||||||
archive_entry_set_pathname(entry, path.c_str());
|
archive_entry_set_pathname(entry, path.c_str());
|
||||||
|
archive_read_extract(src, entry, ARCHIVE_EXTRACT_UNLINK | ARCHIVE_EXTRACT_NO_AUTODIR);
|
||||||
if(archive_errno(src) != 0) return false;
|
if(archive_errno(src) != 0) return false;
|
||||||
archive_read_extract(src, entry, ARCHIVE_EXTRACT_UNLINK);
|
|
||||||
}
|
}
|
||||||
archive_read_free(src);
|
archive_read_free(src);
|
||||||
return fs::remove("/opfs/m0dEl.tzst",tank);
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1 +0,0 @@
|
|||||||
// A copy and pass processor
|
|
||||||
Reference in New Issue
Block a user