msqr1 / Vosklet

A speech recognizer that can run on the browser, inspired by vosk-browser
MIT License
33 stars 1 forks source link

Load model locally #17

Closed AhmedSawx closed 3 weeks ago

AhmedSawx commented 1 month ago

Hi, I'm making an app that uses Tauri, and I want to bundle the model with the application (since I want it to be offline). Are there ways to load the model locally?

msqr1 commented 1 month ago

Vosklet is built for the web using WASM. I am not sure if it works in an offline environment like Tauri.

AhmedSawx commented 1 month ago

Well, Tauri uses the system's browser to render the app, so I guess you can call it a 'web' app. But it does run WASM.

Here, I put a test to see if WebAssembly works or not: webassembly test code

Here's the result: webassembly log

So yes, it does support WASM. My question is whether there's a way to load the model instead of letting the user download it. if not, are there any other ways to achieve that?

msqr1 commented 1 month ago

In that case (if it's literally just a PWA-like thing), you can download a model via a call to createModel with your selected URL, path, and id.

This is the norm. I don't recall the user having to download the model themselves. A call to createModel with fetch and cache the model for you. The next time you visit (assuming this is browser-like) it should load from the Cache and save bandwidth!

AhmedSawx commented 1 month ago

Okay. i did what you said.

But i got a problem, i'm getting this error: 10-15 20:31:05.080 7532 7532 E Tauri/Console: File: http://tauri.localhost/js/Vosklet.js - Line 1 - Msg: Uncaught (in promise) DataCloneError: Failed to execute 'postMessage' on 'Worker': SharedArrayBuffer transfer requires self.crossOriginIsolated.

i looked around and found out that CORS policy are blocking tauri's localhost. they said i should use it's http plugin. how can i edit vosklet.js to make it use tauri's http plugin?

msqr1 commented 1 month ago

Can you somehow use that plugin to inject the COOP AND COEP headers into your app using that HTTP client?

mehryar100 commented 3 weeks ago

hi msqr1 , I am trying to add new language models to vosklet . How can I do that. BTW I am engaged in a linguistic project and need more assistance . Please contact at: mehryar100@yahoo.de to explain more about my project .

msqr1 commented 3 weeks ago

We can talk about that over in #18. It seemed off topic here.