Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MacOs #13

Open
YuryKonvpalto opened this issue Aug 31, 2024 · 15 comments
Open

MacOs #13

YuryKonvpalto opened this issue Aug 31, 2024 · 15 comments

Comments

@YuryKonvpalto
Copy link

Hi msqr1.
I have tested simple app with mic on Android phone - it loads well and works.
On the other hand, I tried to run app on iphone (tried both Safari and Chrome) and it seems something is blocking the model to be downloaded to iphone or couldnt be started. Its stucks on (model = await module.createModel(......)
So the same code works fine with android (Galaxy phone with chrome).

Seems like iphone's private file system works somehow different, or maybe closed at all for downloads,

Do you have ny ideas gow to circumvent it?

@msqr1
Copy link
Owner

msqr1 commented Sep 1, 2024

What version of Chrome/Safari are you using?

@YuryKonvpalto
Copy link
Author

Chrome - 128.0
Safari - 17.6.1

@msqr1
Copy link
Owner

msqr1 commented Sep 20, 2024

I'm using createWritable to write in OPFS, having like 75% browser support (bad, idk why I did this).
I am working to use SyncAccessHandle in a worker instead that can do the same thing, but with 92% browser support and higher performance, only works in a worker though

@YuryKonvpalto
Copy link
Author

Yes, maybe that was the reason it didnt work. Anyway - a greate work, Msqr1, I like your variant of Vosk very much, thank you for sharing your creation!

msqr1 added a commit that referenced this issue Sep 24, 2024
@msqr1
Copy link
Owner

msqr1 commented Sep 24, 2024

I used SyncAccessHandle in a separate worker, which works but will create an extra worker for OPFS. I tried my best to integrate with the WASM workers from Emscripten, but it's literally impossible.

Could you verify that this is fixed in the latest commit before I tag a new version? @YuryKonvpalto

@msqr1
Copy link
Owner

msqr1 commented Sep 25, 2024

I don't have any Apple Device :(

@YuryKonvpalto
Copy link
Author

Hi Msqr1! Sorry for a delay with replay, - have had some busy days.
Very intersning to check if it will do, - I'll try new version tonight and will ypu give a feedback on results.

@YuryKonvpalto
Copy link
Author

I have checked it on iphone SE2020 and iphone 14 - even your exaple with mic doesnt work. I think its related to the Safari and iphone itself, - how they are managing browser filesystem. I have a chrome on iphone, but it fails either (iphone puts some restrictions on external browsers too).
In iphone you even cant see consol.log or put messages from console to textarea of html. Only if you have a mac (which I dont) you can see console logs.

I can tell you also, that I've tried vosk-browser - it works on iphone, because probably it loads models to cache.

@msqr1
Copy link
Owner

msqr1 commented Sep 27, 2024

Vosk browser uses IndexedDB to store models, which has better support than OPFS, but slower read/write.

Could you tell me how you test HTML on an iPhone? How do you make Safari render a local HTML file?

I read some docs that said Safari has a "web inspector" setting that enable DevTools, maybe you could try that.

@YuryKonvpalto
Copy link
Author

изображение

This is how it lokks like on the desktop computer (Windows)

@YuryKonvpalto
Copy link
Author

There are a inscriptoion in the textfield - "model is loaded". It appears as soon as model is loaded to the comp.

On iphone there is an inscription "model tries to load itself" - it appears before await module.createModel("./....) - Look the code below:

module = await loadVosklet()

htmlTextArea.innerHTML = 'model tries to load itself';

let modelRu = await module.createModel("./vosk-model-small-ru-0.4.tar.gz", "model", "ru")

recognizer = await module.createRecognizer(modelRu, 16000)

if (modelRu) {
    htmlTextArea.innerHTML = 'model is loaded';
}

So, if modelRu succesfully has been loaded, it appears "model is loaded" inthe textfield. And its really happens on the desktop.
On iphone it stucks on "model tries to load itself".

For testing I use ngrok.
The ngrok tunnel works well on desktop - I checked it.
Dont know if it works on android though.

@msqr1
Copy link
Owner

msqr1 commented Oct 8, 2024

Could you check once more? I switched to use Cache API instead of OPFS. @YuryKonvpalto

@msqr1
Copy link
Owner

msqr1 commented Oct 10, 2024

Can you confirm please 🙏? I'm waiting on your feedback to release a new version! @YuryKonvpalto

@YuryKonvpalto
Copy link
Author

Hi msqr1,

it works very well on Desktop (end even maybe a bit faster, atleast thats like it seems).
I have tested it on iphone, it stucks here:

it prints - "test" - so before loading a model it looks fine,
but never prints "model tries to load itself"

Look at code below.
I'll check it more closer tonight (do some test), but Apple made it very hard to debug code without desktop-Mac.

 htmlTextArea.innerHTML = 'test';
module = await loadVosklet()

htmlTextArea.innerHTML = 'model tries to load itself';

@msqr1
Copy link
Owner

msqr1 commented Oct 10, 2024

Thank you for staying with me after all of this. So now it doesn't get past loadVosklet?

I tested, and it worked on a Mac and Android, a Windows, on Firefox, Edge, and Chrome and additionally on Safari for the Mac. Literally everything except iOS.

Also, I ported Kaldi now with openBLAS (original approach) instead of the reference one, which increased recognition performance by around 20% over the old version. @YuryKonvpalto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants