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:
msqr1
2024-02-05 23:12:41 -08:00
parent 0ad8f60672
commit 31ee35e1f7
4 changed files with 12 additions and 13 deletions

3
.gitignore vendored
View File

@@ -6,4 +6,5 @@ libarchive
.vscode
clapack-wasm
openfst
emsdk
emsdk
devel

View File

@@ -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.
| ```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 |
| ```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
| Function signature | Description |

View File

@@ -28,10 +28,13 @@ bool genericModel::checkModel() {
}
void genericModel::afterFetch() {
thrd.setTask1([this](){
if(!extractModel()) {
fireEv("_continue", "Unable to extract model and delete .tzst file", index);
if(!extractModel() && fs::remove("/opfs/m0dEl.tzst",tank)) {
fs::current_path("/opfs");
fs::remove_all(storepath);
fireEv("_continue", "Unable to extract model", index);
return;
}
fs::remove("/opfs/m0dEl.tzst",tank);
std::ofstream idFile("id");
if(!idFile.is_open()) {
fs::current_path("/opfs");
@@ -41,17 +44,13 @@ void genericModel::afterFetch() {
}
idFile << id;
idFile.close();
char a[3] {};
int fd = open("./conf/model.conf", O_RDONLY);
read(fd, a, 3);
emscripten_console_log(a);
close(fd);
// I wanna give up on this thing so bad...
std::ifstream is("./conf/model.conf");
emscripten_console_logf("%d", is.good());
emscripten_console_logf("%d", is.bad());
emscripten_console_logf("%d", is.eof());
emscripten_console_logf("%d", is.fail());
is.close();
//load(false);
});
}
@@ -68,9 +67,9 @@ bool genericModel::extractModel() {
// Strip first component, keep relative path
path = "." + path.substr(path.find("/"));
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;
archive_read_extract(src, entry, ARCHIVE_EXTRACT_UNLINK);
}
archive_read_free(src);
return fs::remove("/opfs/m0dEl.tzst",tank);
return true;
}

View File

@@ -1 +0,0 @@
// A copy and pass processor