pocketsphinx.js icon indicating copy to clipboard operation
pocketsphinx.js copied to clipboard

Wasm decoding failed

Open jjenzz opened this issue 6 years ago • 5 comments

I am trying to get this up and running and I'm getting the following error:

CompileError: AsyncCompile: Wasm decoding failed: expected magic word 00 61 73 6d, found 3c 21 44 4f @+0

The only code I have atm is:

this.recognizer = new Worker('js/recognizer.js');
this.recognizer.onmessage = this.handleReady; // this method is empty atm
this.recognizer.postMessage({});

All files from the webapp/js directory are in my public js directory.

Any idea where I am going wrong?

jjenzz avatar Mar 01 '18 15:03 jjenzz

I believe that means pocketsphinx.wasm was not found. You can set the location in your postMessage call: this.recognizer.postMessage({'pocketsphinx.wasm': 'path/to/pocketsphinx.wasm'});.

syl22-00 avatar Mar 01 '18 19:03 syl22-00

@syl22-00 I'm not sure that is the issue because the following suggests it found something in the wasm file that it wasn't expecting:

expected magic word 00 61 73 6d, found 3c 21 44 4f @+0

Furthermore:

image

image

jjenzz avatar Mar 02 '18 10:03 jjenzz

This is indeed strange, is it a file that you compiled yourself? It does not have the correct header and is only 1.2KB big. The file in the repo is 467kB big.

syl22-00 avatar Mar 07 '18 21:03 syl22-00

Got this same error for the opus-media-recorder library. (this is the only result on the internet for the given "expected magic word..." error message!)

For me, the problem was that I was using the following:

app.use(require("connect-history-api-fallback")({
	rewrites: [
		{
			from: /^(.(?!\.(html|js|css|png|jpg)))+$/, // paths with these extensions will NOT be redirected to "index.html""
			to(context) {
				return "/index.html";
			},
		},
	],
}));

Notice that it's rewriting any url's that don't end in the special resource-extensions (html, js, etc.) with the url for the homepage. The problem is that I forgot to add .wasm to that list, meaning that when the browser requested the .wasm files, it was receiving the index.html file instead.

Adding .wasm to that list resolved the issue.

Venryx avatar Sep 08 '19 03:09 Venryx

3c 21 44 4f @+0 in ascii is <!DO whihc is the header of a HTML file. So the file you're trying to load is not found in the path given. You'll have to statically deploy the relevant files first in order for the HTTP request to be made.

jackbilestech avatar Feb 24 '20 20:02 jackbilestech