diffusionstudio / vits-web

Web api for using VITS based models in the browser!
144 stars 10 forks source link

Get rid of XMLHttpRequest() in piper.js #6

Open guest271314 opened 2 months ago

guest271314 commented 2 months ago

I've bundled onyx-runtimewe.js and piper.js, created a couple standalone versions for the browser, now I'm working on running the code in node, deno, bun, txiki.js. piper.js has multiple occurrences of XMLHttpRequest(). Get rid of them.

guest271314 commented 2 months ago

@k9p5 What is the source code of piper.js?

guest271314 commented 2 months ago

XMLHttpRequest() usage is not the only issue with piper.js.

There's also references to location.pathname that don't exist in a node environment.

We're going to need the source code for piper.js to proceed, compile to an actual .wasm file.

k9p5 commented 2 months ago

Piper.js is the javascript emscripten output

guest271314 commented 2 months ago

Yes. What are the build steps is the question?

I think I found the origin of the build steps and your code here https://github.com/rhasspy/piper/issues/352#issuecomment-1920886683, then following links here https://github.com/ken107/piper-browser-extension/issues/2#issuecomment-2034567892, and here https://github.com/rhasspy/piper/discussions/504#discussioncomment-9482437.

It would be very helpful to publish the source of your code, including the specific Emscripten build steps you used, and where you got the steps from here, so we don't have to search through issues, discussions, blame.

I'm getting all sorts of errors trying to reproduce the steps, for the purpose of compiling for 'shell' environment, so we don't get window and location.pathname references in the output.

k9p5 commented 2 months ago

Here they are: https://github.com/diffusion-studio/piper-wasm

guest271314 commented 2 months ago

Those build steps throw errors here

fatal: could not create leading directories of '/wasm/modules/emsdk': Permission denied
./build.sh: line 4: cd: /wasm/modules/emsdk: No such file or directory
./build.sh: line 5: ./emsdk: No such file or directory
./build.sh: line 6: ./emsdk: No such file or directory
./build.sh: line 7: ./emsdk_env.sh: No such file or directory
sed: can't read ./upstream/emscripten/cache/sysroot/include/wchar.h: No such file or directory
fatal: could not create leading directories of '/wasm/modules/espeak-ng': Permission denied
./build.sh: line 13: cd: /wasm/modules/espeak-ng: No such file or directory
./build.sh: line 14: ./autogen.sh: No such file or directory
./build.sh: line 15: ./configure: No such file or directory
make: *** No targets specified and no makefile found.  Stop.
fatal: could not create leading directories of '/wasm/modules/piper-phonemize': Permission denied
./build.sh: line 20: cd: /wasm/modules/piper-phonemize: No such file or directory
./build.sh: line 21: emmake: command not found
./build.sh: line 22: emmake: command not found
sed: can't read /wasm/modules/piper-phonemize/build/e/src/espeak_ng_external-build/CMakeFiles/Makefile2: No such file or directory
sed: can't read /wasm/modules/piper-phonemize/build/e/src/espeak_ng_external/src/speechPlayer/src/speechWaveGenerator.cpp: No such file or directory
./build.sh: line 25: emmake: command not found
guest271314 commented 2 months ago

I think I've manually gotten rid of XMLHttpRequest() in piper.js. Now the issue is onyxruntime-web and onyxruntime-node

bun install onxyruntime-node 
bun build node_modules/onnxruntime-node/dist/index.js --outfile=ort-bundle.js
error: Uncaught (in promise) Error: no available backend found. ERR: [wasm] NotSupported: Classic workers are not supported., [cpu] Error: previous call to 'initWasm()' failed.
    at Jr (file:///home/user/vits-web-extension/onyx-runtimeweb.js:357:1724)
guest271314 commented 2 months ago

This is going to take some work. I'm in to onyxruntime-web and onyxruntime-node now.

node --experimental-default-type=module index.js

Error: no available backend found. ERR: [wasm] TypeError: Worker is not a constructor, [cpu] Error: previous call to 'initWasm()' failed.
    at Jr (file:///home/user/vits-web-extension/onyx-runtimeweb.js:357:1724)
    at async u.create (file:///home/user/vits-web-extension/onyx-runtimeweb.js:357:17987)
    at async tts (file:///home/user/vits-web-extension/index.js:103:19)
    at async file:///home/user/vits-web-extension/index.js:195:18

Node.js v23.0.0-nightly2024070366b76e24e2