FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
First of all, it is a great job what you put at the disposal of the community, thank you. Now I ask you about the error title of this message, first indicating what I have to work:
Hardware -AMD A4-5300B APU with Radeon(tm) HD Graphics -RAM 12 GB -Hard Disk 500 GB
Software - Necessary -Ubuntu 18- 64 bits -git clone https://github.com/emscripten-core/emsdk.git -clang-5.0 --version clang version 5.0.1-4 (tags/RELEASE_501/final) -nodejs --version v8.10.0
Software - Project pocketsphinx -pocketsphinx.js download via zip why sphinxbase and pocketsphinx directories are empty -sphinxbase and pocketsphinx sphinxbase download via zip https://github.com/cmusphinx/sphinxbase/tree/562d0472aababa9a5fbc5b7518ea174745323e4f pocketsphinx download via zip https://github.com/cmusphinx/pocketsphinx/tree/80d8e2896c555fe037a64e870bc6370cf86f419b unpack in its corresponding sphinxbase and pocketsphinx directory and install them pocketsphinx_continuous -inmic yes, test with the default dictionary pocketsphinx_continuous -inmic yes -lm es-20k.lm.bin -dict es.dict -hmm es-es, with a Spanish language model, both tests satisfactory.
Creating pocketsphinx.js -Following the instructions in the compilation in this first example, no problem, the pocketsphinx.js file is created $ sudo cmake -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE=/home/ia2/emsdk/fastcomp/emscripten/cmake/ Modules/Platform/Emscripten.cmake .. $ sudo make
-In the following example, an error is generated HMM_BASE 3.2M cmudict-en-us.dict 6.4M en-us <Directory> 26M en-us.lm.bin 840K en-us-phone.lm.bin 67M es-20k.lm.bin 588K es.dict 9.8M es-es <Directory>
en-us 4.0K feat.params 2.9M mdef 820K means 4.0K noisedict 4.0K README 1.9M sendump 4.0K transition_matrices 820K variances
es-es 4.0K feat.params 1.3M mdef 508K means 6.0M mixture_weights 4.0K noisedict 1.5M sendump 4.0K transition_matrices 508K variances
Example 1 $ sudo cmake -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE=/home/ia2/emsdk/fastcomp/emscripten/ cmake/Modules/Platform/Emscripten.cmake -DHMM_BASE=HMM_BASE -DHMM_FOLDERS=es-es
Example 2 $ sudo cmake -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE=/home/ia2/emsdk/fastcomp/emscripten/ cmake/Modules/Platform/Emscripten.cmake -DHMM_BASE=HMM_BASE -DHMM_FOLDERS=en-us
In both cases, when running sudo make, the following error is generated
warning: undefined symbol: popen FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
Could you tell me your opinion of the case presented to me? Thanks
OK, so there are a lot of issues:
- Do not manually download pocketsphinx and sphinxbase, they are packaged as submodules, it is explained in the README.
- Download pocketsphinx.js using a git clone. This way you can more easily update.
- Do not sudo, this is dangerous, and it is not useful.
- Only package the files that are necessary. From what I read, you are trying to package Spanish and English acoustic models, language models, dictionary, sometimes with duplicates. That's why your build runs out of memory. You can allocate more memory to the build, look into CMakeLists.txt, but you might as well package more carefully.
- And I would advise not to package model files inside pocketsphinx.js but to use the more flexible approach of lazy loading. It is also described in the README.
Lazy loading is better (make sure to set -mmap no in the recognizer configuration), but if you insist on embedding full-sized acoustic models, you can pass extra options to the Node.js instance used by Emscripten to increase its memory size, like this:
export NODE_OPTIONS=--max_old_space_size=5000