syl22-00 / pocketsphinx.js

Speech recognition in JavaScript and WebAssembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webapp/live.html not working? (wasm streaming compile failed)

zen85 opened this issue · comments

commented

I downloaded from here and uploaded it to my webspace.
when i try to open the demo files i get errors and all the buttons are greyed out.

the console gives me that:
unbenannt

maybe a new problem through the changes in the chrome policy?

The first warning is about audio playback and is not related to the rest. It is harmless.

The rest seems to be that pocketsphinx.wasm is not correctly served by your server. You can look at your network logs in the browser's web development tool.

As explained in the README, your server should serve it with the correct mime type (application/wasm). You can first check locally with the provided server.py.

commented

indeed it says 404... eventhough i did not change anything from the original files...

anyway i think i found out the problem: it is me not realising that pocketsphinx.js can not be put on a normal hosting-webspace by just moving the files there because of web-assembly issues? sorry if i sound naive on that...

There is nothing specific to webassembly here, you just need to configure your web server so that all files return 200.
If you wan to move your files around, syntax is documented in the doc, for instance here: https://github.com/syl22-00/pocketsphinx.js#31-principles

commented

ohyeah. that worked.
in recognizer.js i changed to this:
var pocketsphinxWASM = (event.data && 'pocketsphinx.wasm' in event.data) ? event.data['pocketsphinx.wasm'] : 'pocketsphinx.wasm';

thanks.

There is a programmatic way to set the location of your wasm file, when you send the first message to the recognizer object:

    recognizer.postMessage({'pocketsphinx.js': 'path/to/pocketsphinx.js', 'pocketsphinx.wasm': 'path/to/pocketsphinx.wasm'});

In your case:

    recognizer.postMessage({'pocketsphinx.wasm': 'pocketsphinx.wasm'});

It's in the README.

commented

thank you so much.
I am experimenting around and i am learning so so much. I read that part before in the readme and with what i know now i would have probably interpreted it right right-away... but people like you, people who answer such stupid questions make that awesome experience way less frustrating.

commented

The first warning is about audio playback and is not related to the rest. It is harmless.

I spent a little time troubleshooting this when safari and firefox were working for me but not Chrome.
I don't think the Chrome's Web Audio autoplay policy warning is harmless here. In certain circumstances, it will prevent the demo from working. Specifically, if you hit refresh on the live demo page so that there are no clicks prior to the audioContext = new AudioContext() call, then you get this warning and recording is busted. Perhaps this is what is referred to in the README? "Note that we observed the recorded audio to be silent on some configurations we have tried."

Changing startRecording to this fixed it for me on chrome:

      var startRecording = function() {
        audioContext.resume().then(() => {
            var id = document.getElementById('grammars').value;
            if (recorder && recorder.start(id)) displayRecording(true);
        });
      };

Thanks @dpakatheman , do you think you could make a pull request for that?

Just wanted to add my 2 cents worth since this is still open. I spent a fair amount of time yesterday encountering the same difficulty, due to the fact that the default for the pocketsphinx.wasm file is '/webapp/js/pocketsphinx.wasm', meaning this will only work if the webapp demo folder is uploaded as is (without changing filename) and must be placed at the root of your server, eg, must be "https://mysite.com/webapp/live.html".

Is there a reason the default cannot be changed to a relative url? eg, 'pocketsphinx.wasm'? The default for pocketsphinx.js is already a relative url: 'pocketsphinx.js', so why can't they be similar?

You mention it is "in the README", but the README can be daunting to the unfamiliar, outlining many different details of application and approaches. And there is actually no mention of it at all in the "6. Live demo" section where it seems it would be appropriate. It would be very helpful for beginners (even beginners with a fair amount of experience with software development) if one would be able to simply upload the app to their server and see a working example immediately without first having to tweak it. It is just a better and less discouraging experience for newcomers if they don't have start troubleshooting right out of the gate before they can even see the app working.

Or if you don't want to change the default, at least mention under the "6. Live demo" section the required path needed for it to work without tweaking, and if the user wants to change the path, the tweaks necessary.