HarikalarKutusu / stt-wasm-test

GNU Affero General Public License v3.0
0 stars 0 forks source link

Source for stt-wasm #1

Open OmarJay1 opened 2 years ago

OmarJay1 commented 2 years ago

Hi, thanks for starting this test app for stt-wasm. Do you know where any sort of source for the stt-wasm package would be available?

I'm not exactly sure how it's built, and I notice that in this project references to it seem to be commented out.

I've tried using lib/stt_wasm.js in my own React app, and I can't get it to work anywhere outside of Coqui's sample app. There seem to be references to Node libraries that aren't available in browser Javascript, like fs and stream.

Thanks.

HarikalarKutusu commented 2 years ago

Hey @OmarJay1, this repo is a WIP, it was a quick publish to show the problems to the author of stt-wasm. With some discussion I could make it "load" only. AFAIK there is no source repo available and I had problems with TS as there are no @types either. I had to focus to another project, but will come back here for a fully working one. Perhaps asking under the STT examples repo or Coqui STT channel on gitter be more helpful (link)

OmarJay1 commented 2 years ago

Hi @HarikalarKutusu, I'm pretty sure loading stt-wasm has a CORS issue. The example STT gives contains some CORS settings in package.json.

"scripts": { "download": "download --extract --strip 1 --out lib https://github.com/coqui-ai/STT/releases/latest/download/libstt.tflite.wasm.zip", "start": "ws --cors.opener-policy same-origin --cors.embedder-policy require-corp" },

I'm not sure how to do the same thing in the Create React Act development environment, or in Apache where my release version will be served. I'm still working on it.

https://stackoverflow.com/questions/68592278/sharedarraybuffer-is-not-defined

It would still be nice to have the source to see if there's some sort of workaround that doesn't require CORS. I'll ask on STT-examples.

Thanks.

HarikalarKutusu commented 2 years ago

Yes we solved exactly that CORS issue. This repo is for that purpose. I will check if I have committed everything when I get home...

HarikalarKutusu commented 2 years ago

Check here: https://github.com/HarikalarKutusu/stt-wasm-test/blob/main/web/config-overrides.js

HarikalarKutusu commented 2 years ago

I'm not sure how to do the same thing in the Create React Act development environment

I used: https://github.com/HarikalarKutusu/stt-wasm-test/blob/6ec0e66e6b1c1029590841d953580c2e6a454d3e/web/package.json#L30 and https://github.com/HarikalarKutusu/stt-wasm-test/blob/6ec0e66e6b1c1029590841d953580c2e6a454d3e/web/package.json#L32

OmarJay1 commented 2 years ago

Hi @HarikalarKutusu, thanks for the tips on CORS. It works.

However, I think I'm going to try to make some sort of web/wasm version of STT that doesn't require CORS. It's too much of a pain to use my experience.

It looks like stt-wasm is built in part from the Node STT client, which leaves it with references to things that aren't native to browsers.

I'm looking into using Tensorflow.js and copy the Python application flow.

Thanks.

HarikalarKutusu commented 2 years ago

Good luck :) Beware thou, it took a full week for an experienced programmer to be able to compile it searching the correct flags...

It's too much of a pain

That's because we are using CRA :/

AFAIK, you cannot remove CORS in new browsers (unless you play with browser flags).

OmarJay1 commented 1 year ago

Just a note on CORS "Cross-Origin-Embedder-Policy": "require-corp",

The following won't work with that setting. Not such a big deal except that if you're displaying remote site resources, there could be copyright issues if you cache them and serve them from your own server.

`

`

I'm working on some form of SSR & maybe service workers to deal with CORS. Service workers could also be useful for caching large Model and Scoring files.