syl22-00 / pocketsphinx.js

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

Compile pocketsphinx.js in CMake (cmake-gui) #28

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi,

I'm having trouble compiling pocketsphinx.js with CMake for Windows x64. I set MinGW Makefiles (mingw32-make already installed) and I specified toolchain file for cross-compiling. No error in CMake, but pocketsphinx.js file is not generated. EMSCRIPTEN and HMM_EMBED is false.

Thanks in advance.

syl22-00 commented 9 years ago

I do not have a Windows machine to try out so it is hard for me to guess what is going wrong. EMSCRIPTEN is set to 1, right, not false? You did run make after cmake, right? A few people seem to have succeded, such as here: https://github.com/syl22-00/pocketsphinx.js/issues/6

ghost commented 9 years ago

Thanks. I got success in building pocketsphinx.js, but I get this error in Google Chrome: debug

syl22-00 commented 9 years ago

I guess that means the generated JS file is not valid, does it look like a real JavaScript file?

ghost commented 9 years ago

Yes, but this doesn't include hmm, .dmp or .dic. I am using template.html of pocketsphinx.js-lib. Is it possible to use this just loading hmm, dictionary, language model without grammars (remove feedWord and feedGrammar), as speech-to-text?

syl22-00 commented 9 years ago

To load the other JS files, such as HMM or dictionary, you can use the load command in recognizer.js: https://github.com/syl22-00/pocketsphinx.js#h-loading-files-such-as-acoustic-models-packaged-outside-pocketsphinxjs

And, as you said, if you use a statistical language model and a dictionary file, you should not call feedWords or feedGrammar)

ghost commented 9 years ago

Can I load hmm, .dic and .dmp external files (no *.js, but files in source extension)?

Like this:

...
    var initRecognizer = function () {
        var data = [["-hmm", "pocketsphinx/en-us/hmm/"]];
        data.push(["-dict", "pocketsphinx/en-us/lm/cmusphinx.dic"]);
        data.push(["-lm", "pocketsphinx/en-us/lm/cmusphinx.dmp"]);
        postRecognizerJob({
            command: "initialize",
            data: data
        },
            function () {
                if (recorder) recorder.consumers = [recognizer];
                else recognizerReady();
        });
    };
...

If so, why do I get this error?

INFO: C:\Users\Danilo\Desktop\Arquivos\pocketsphinx.js\sphinxbase\src\libsphinxbase\util\cmd_ln.c(697): Parsing command line:
pocketsphinx.js:1 \
pocketsphinx.js:1   -bestpath no \
pocketsphinx.js:1   -dict pocketsphinx/en-us/lm/cmusphinx.dic \
pocketsphinx.js:1   -hmm pocketsphinx/en-us/hmm/ \
pocketsphinx.js:1   -lm pocketsphinx/en-us/lm/cmusphinx.dmp \
pocketsphinx.js:1   -remove_noise no 
pocketsphinx.js:1 
pocketsphinx.js:1 Current configuration:
pocketsphinx.js:1 [NAME]        [DEFLT]     [VALUE]
pocketsphinx.js:1 -adcdev               
pocketsphinx.js:1 -agc      none        none
pocketsphinx.js:1 -agcthresh    2.0     2.000000e+00
pocketsphinx.js:1 -allphone         
pocketsphinx.js:1 -allphone_ci  no      no
pocketsphinx.js:1 -alpha        0.97        9.700000e-01
pocketsphinx.js:1 -argfile          
pocketsphinx.js:1 -ascale       20.0        2.000000e+01
pocketsphinx.js:1 -aw       1       1
pocketsphinx.js:1 -backtrace    no      no
pocketsphinx.js:1 -beam     1e-48       1.000000e-48
pocketsphinx.js:1 -bestpath yes     no
pocketsphinx.js:1 -bestpathlw   9.5     9.500000e+00
pocketsphinx.js:1 -bghist       no      no
pocketsphinx.js:1 -ceplen       13      13
pocketsphinx.js:1 -cmn      current     current
pocketsphinx.js:1 -cmninit  8.0     8.0
pocketsphinx.js:1 -compallsen   no      no
pocketsphinx.js:1 -debug                0
pocketsphinx.js:1 -dict             pocketsphinx/en-us/lm/cmusphinx.dic
pocketsphinx.js:1 -dictcase no      no
pocketsphinx.js:1 -dither       no      no
pocketsphinx.js:1 -doublebw no      no
pocketsphinx.js:1 -ds       1       1
pocketsphinx.js:1 -fdict                
pocketsphinx.js:1 -feat     1s_c_d_dd   1s_c_d_dd
pocketsphinx.js:1 -featparams           
pocketsphinx.js:1 -fillprob 1e-8        1.000000e-08
pocketsphinx.js:1 -frate        100     100
pocketsphinx.js:1 -fsg              
pocketsphinx.js:1 -fsgusealtpron    yes     yes
pocketsphinx.js:1 -fsgusefiller yes     yes
pocketsphinx.js:1 -fwdflat  yes     yes
pocketsphinx.js:1 -fwdflatbeam  1e-64       1.000000e-64
pocketsphinx.js:1 -fwdflatefwid 4       4
pocketsphinx.js:1 -fwdflatlw    8.5     8.500000e+00
pocketsphinx.js:1 -fwdflatsfwin 25      25
pocketsphinx.js:1 -fwdflatwbeam 7e-29       7.000000e-29
pocketsphinx.js:1 -fwdtree  yes     yes
pocketsphinx.js:1 -hmm              pocketsphinx/en-us/hmm/
pocketsphinx.js:1 -infile               
pocketsphinx.js:1 -input_endian little      little
pocketsphinx.js:1 -jsgf             
pocketsphinx.js:1 -kdmaxbbi -1      -1
pocketsphinx.js:1 -kdmaxdepth   0       0
pocketsphinx.js:1 -kdtree               
pocketsphinx.js:1 -keyphrase            
pocketsphinx.js:1 -kws              
pocketsphinx.js:1 -kws_plp  1e-1        1.000000e-01
pocketsphinx.js:1 -kws_threshold    1       1.000000e+00
pocketsphinx.js:1 -latsize  5000        5000
pocketsphinx.js:1 -lda              
pocketsphinx.js:1 -ldadim       0       0
pocketsphinx.js:1 -lextreedump  0       0
pocketsphinx.js:1 -lifter       0       0
pocketsphinx.js:1 -lm               pocketsphinx/en-us/lm/cmusphinx.dmp
pocketsphinx.js:1 -lmctl                
pocketsphinx.js:1 -lmname               
pocketsphinx.js:1 -logbase  1.0001      1.000100e+00
pocketsphinx.js:1 -logfn                
pocketsphinx.js:1 -logspec  no      no
pocketsphinx.js:1 -lowerf       133.33334   1.333333e+02
pocketsphinx.js:1 -lpbeam       1e-40       1.000000e-40
pocketsphinx.js:1 -lponlybeam   7e-29       7.000000e-29
pocketsphinx.js:1 -lw       6.5     6.500000e+00
pocketsphinx.js:1 -maxhmmpf 10000       10000
pocketsphinx.js:1 -maxnewoov    20      20
pocketsphinx.js:1 -maxwpf       -1      -1
pocketsphinx.js:1 -mdef             
pocketsphinx.js:1 -mean             
pocketsphinx.js:1 -mfclogdir            
pocketsphinx.js:1 -min_endfr    0       0
pocketsphinx.js:1 -mixw             
pocketsphinx.js:1 -mixwfloor    0.0000001   1.000000e-07
pocketsphinx.js:1 -mllr             
pocketsphinx.js:1 -mmap     yes     yes
pocketsphinx.js:1 -ncep     13      13
pocketsphinx.js:1 -nfft     512     512
pocketsphinx.js:1 -nfilt        40      40
pocketsphinx.js:1 -nwpen        1.0     1.000000e+00
pocketsphinx.js:1 -pbeam        1e-48       1.000000e-48
pocketsphinx.js:1 -pip      1.0     1.000000e+00
pocketsphinx.js:1 -pl_beam  1e-10       1.000000e-10
pocketsphinx.js:1 -pl_pbeam 1e-5        1.000000e-05
pocketsphinx.js:1 -pl_window    0       0
pocketsphinx.js:1 -rawlogdir            
pocketsphinx.js:1 -remove_dc    no      no
pocketsphinx.js:1 -remove_noise yes     no
pocketsphinx.js:1 -remove_silence   yes     yes
pocketsphinx.js:1 -round_filters    yes     yes
pocketsphinx.js:1 -samprate 16000       1.600000e+04
pocketsphinx.js:1 -seed     -1      -1
pocketsphinx.js:1 -sendump          
pocketsphinx.js:1 -senlogdir            
pocketsphinx.js:1 -senmgau          
pocketsphinx.js:1 -silprob  0.005       5.000000e-03
pocketsphinx.js:1 -smoothspec   no      no
pocketsphinx.js:1 -svspec               
pocketsphinx.js:1 -time     no      no
pocketsphinx.js:1 -tmat             
pocketsphinx.js:1 -tmatfloor    0.0001      1.000000e-04
pocketsphinx.js:1 -topn     4       4
pocketsphinx.js:1 -topn_beam    0       0
pocketsphinx.js:1 -toprule          
pocketsphinx.js:1 -transform    legacy      legacy
pocketsphinx.js:1 -unit_area    yes     yes
pocketsphinx.js:1 -upperf       6855.4976   6.855498e+03
pocketsphinx.js:1 -usewdphones  no      no
pocketsphinx.js:1 -uw       1.0     1.000000e+00
pocketsphinx.js:1 -vad_postspeech   50      50
pocketsphinx.js:1 -vad_prespeech    10      10
pocketsphinx.js:1 -vad_threshold    2.0     2.000000e+00
pocketsphinx.js:1 -var              
pocketsphinx.js:1 -varfloor 0.0001      1.000000e-04
pocketsphinx.js:1 -varnorm  no      no
pocketsphinx.js:1 -verbose  no      no
pocketsphinx.js:1 -warp_params          
pocketsphinx.js:1 -warp_type    inverse_linear  inverse_linear
pocketsphinx.js:1 -wbeam        7e-29       7.000000e-29
pocketsphinx.js:1 -wip      0.65        6.500000e-01
pocketsphinx.js:1 -wlen     0.025625    2.562500e-02
pocketsphinx.js:1 
pocketsphinx.js:1 INFO: C:\Users\Danilo\Desktop\Arquivos\pocketsphinx.js\sphinxbase\src\libsphinxbase\feat\feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='current', VARNORM='no', AGC='none'
pocketsphinx.js:1 INFO: C:\Users\Danilo\Desktop\Arquivos\pocketsphinx.js\sphinxbase\src\libsphinxbase\feat\cmn.c(143): mean[0]= 12.00, mean[1..12]= 0.0
pocketsphinx.js:1 ERROR: "C:\Users\Danilo\Desktop\Arquivos\pocketsphinx.js\pocketsphinx\src\libpocketsphinx\acmod.c", line 90: Folder 'pocketsphinx/en-us/hmm/' does not contain acoustic model definition 'mdef'
syl22-00 commented 9 years ago

So you have to load these files before you initialize the recognizer with the command line arguments you provided. So make sure:

syl22-00 commented 9 years ago

To be more specific, look at the first lines, you shoule have something like

Module['FS_createPath']('/folder', 'file', true, true);
ghost commented 9 years ago

Thank you for help and support. It's working for me. Thank you really.

shanter93 commented 8 years ago

When i'm trying to compile pocketsphinx with cmake gui an error occurs which says "CMake Error: CMake can not determine linker language for target: pocketsphinx" Please help. Thanks in advance.

syl22-00 commented 8 years ago

Please provide more information wit the steps you took up to that point. My best guess is that the path to emscripten toolchain was not correctly set.

shanter93 commented 8 years ago

Steps i followed. Im using windows 7 64 bit 1.I have downloaded pocketsphinx zip file from https://github.com/syl22-00/pocketsphinx.js and extracted it to a local drive. 2.I have created a build folder inside the base directory 3.Now i opened my cmake gui and specified the target and build directories. (i have my empscripten and MINGW32 already installed). 4.Now i clicked on configure and selected the MINGW makefiles as generator and specified the path for empscripten.cmake(tool for cross-compiling) 5.When i clicked on generate button the following error occurs "CMake Error at CMakeLists.txt:83 (add_library): Cannot find source file:

D:/Work/syl22-00-pocketsphinx.js-7a6a61f/pocketsphinx/src/libpocketsphinx/acmod.c

Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx

CMake Error: CMake can not determine linker language for target: pocketsphinx CMake Error: Cannot determine link language for target "pocketsphinx". Generating done

syl22-00 commented 8 years ago

It seems like you do not have pocketsphinx (and probably sphinxbase) code. It is typically added via submodules as explained in the docs. If you do not want to clone pocketsphinx.js repository, you'll have to add the pocketsphinx and sphinxbase folders manually.

shanter93 commented 8 years ago

Can you give a brief tutorial on how to add those folders..?

But previously i have also executed the following commands before doing all the above mentioned steps.

git submodule init git submodue update

but nothing happend for this code..

ddugovic commented 8 years ago

I assume the .zip file doesn't contain a .git directory. Try the following: git add origin https://github.com/syl22-00/pocketsphinx.js.git && git pull

syl22-00 commented 8 years ago

Since the archive does not include the .git folder, you can't add an origin to it.

So you have two choices:

shanter93 commented 8 years ago

Thank you so much . It was really helpful. This solved the issue.

vigneshkumar17 commented 6 years ago

hi @syl22-00 , I tried to your demo, its helpful. But i'm trying to use my Dictionary and language model, instead of gram file in live.html.

Actually i downloaded the sub-modules "Pocketsphix" and "sphinxbase" and compiled it. Using "pocketsphinx_continuous.exe" i tried live speech with my dict and lm, its working fine in command promt.

Now my question is how can i make it work in "Pocketsphinx.js", (ie, without using gram file in live.html, i want to use my dict and lm).

So can you help me with this problem. Thanks in advance.

syl22-00 commented 6 years ago

It is quite straightforward, you lazy-load your model and dictionary files and then initialize the recognizer with the -lm, -dict, or -hmm parameters as you'd do in the command line. All is explained in the README file.

vigneshkumar17 commented 6 years ago

Thanks for the help @syl22-00 , i will try this lazy-load solution.

vigneshkumar17 commented 6 years ago

Hi @syl22-00

i tried the lazy load as you told, but i'm not sure how to use it in your live.html, i tried it, but i couldn't achieve my goal. So can you help by guiding me in step by step process,how to use lazyload to load my dict,lm without the grammar words. it will be so helpful for me.

Thanks in advance.

1Caxz commented 2 years ago

I got this error when compiling using the new version emscripten and CMake. It's like embed not working because set argument. any solution? Screen Shot 2022-04-13 at 11 33 45