Remove model after load to save space

This commit is contained in:
msqr1
2024-03-31 21:18:56 -07:00
parent 0cdc293bdd
commit c23340ee1f
6 changed files with 9 additions and 23 deletions

View File

@@ -21,7 +21,7 @@ void genericModel::extractAndLoad(int tarStart, int tarSize) {
break;
}
path = archive_entry_pathname(entry);
path = storepath + path.generic_string().substr(path.generic_string().find("/"));
path = storepath + path.string().substr(path.string().find("/"));
if(!path.has_extension()) {
fs::create_directory(path);
continue;
@@ -39,12 +39,12 @@ void genericModel::extractAndLoad(int tarStart, int tarSize) {
}
}
free(reinterpret_cast<void*>(tarStart));
fs::remove(storepath + "/README");
archive_read_free(src);
if(normalMdl) mdl = vosk_model_new(storepath.c_str());
else vosk_spk_model_new(storepath.c_str());
if(normalMdl ? std::get<0>(mdl) == nullptr : std::get<1>(mdl) == nullptr) fireEv(index, "Unable to load model for recognition");
else fireEv(index, "0");
fs::remove_all(storepath);
};
std::thread t{[this](){
func();

View File

@@ -6,6 +6,7 @@
#include <fcntl.h>
#include <vosk_api.h>
#include <emscripten/console.h>
#include <archive.h>
#include <archive_entry.h>
namespace fs = std::filesystem;