syl22-00 / pocketsphinx.js

Speech recognition in JavaScript and WebAssembly
1.49k stars 261 forks source link

language model file location path? #40

Open Wavehk opened 9 years ago

Wavehk commented 9 years ago

Hi,

I have compiled the pocketsphinx.js with the am folder inside pocketsphinx.js/, after that i ran my js with pocketsphinx:

var PocketSphinx = require('./pocketsphinx.js/build/pocketsphinx.js'); var config = new PocketSphinx.Config(); config.push_back(["-fwdflat", "no"]); var recognizer = new PocketSphinx.Recognizer(config);

And after the recognition,

var output = recognizer.start(); // Starts recognition on current language model output = recognizer.process(buffer); // Processes the buffer var hyp = recognizer.getHyp(); // Gets the current recognized string (hypothesis) console.log(hyp);

Returns error ERROR: "acmod.c", line 90: Folder 'am' does not contain acoustic model definition 'mdef'

Where should i place the definition files?

Thanks Owen

syl22-00 commented 9 years ago

It should be explained there: https://github.com/syl22-00/pocketsphinx.js#i-embedding-the-files-into-one-large-javascript-file

If it does not work, please detail what you have done to package your acoustic model.

Meanwhile, the issue title is about the language model, but we are discussing the acoustic model.

Wavehk commented 9 years ago

Thanks for quick reply, I have read through the steps again, I tried again with the following build command:

cmake -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE="{path to emsdk}/emscripten/1.30.0/cmake/Modules/Platform/Emscripten.cmake" -DLM_BASE="pocketsphinx/model/en-us" -DLM_FILES="en-us" ..

Copying /Users/tat/Downloads/pocketsphinx.js/am/rm1_200 to binary dir Copying pocketsphinx/model/en-us/en-us to binary dir -- Configuring done -- Generating done -- Build files have been written to: /Users/tat/Downloads/pocketsphinx.js/build

I am building on a mac pro with 12GB ram, after a long build time and returns errorFATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory

Any idea why or how to fix? many thanks

syl22-00 commented 9 years ago

So first, you are confusing acoustic and language model:

Then, as explained in the README file, if you want to use those larger models, you should use external packaging as explained in the docs. Each file will become one JavaScript file. If you try to package all inside one JavaScript file, the node.js process exceeds its max allowed memory, which is the error message you see (it does not matter how much RAM you have, it is a node.js thing).