So when I'm launching "pocketsphinx_continuous -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9961.lm -dict 9961.dic -samprate 16000/8000/48000 -inmic yes -adcdev plughw:1,0", there are no problems.
But when I'm launching a script with pocketsphinx where I give some arguments to the decoder, it doesn't work.
Here is an extract of the code :
So I remove the line config.set_string('-adcdev', 'plughw:1,0').
Then I replace the line stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024)
with stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024, input_device_index=1)
But I still have some errors.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in bootstrap_inner
self.run()
File "testMic0.py", line 51, in run
decoder = Decoder(config)
File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 266, in __init
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok, thanks you.
So I could fix some erros, but I still have these ones :
INFO:pocketsphinx.c(152):Parsedmodel-specificfeatureparametersfrom/usr/local/share/pocketsphinx/model/en-us/en-us/feat.paramsCurrentconfiguration:[NAME][DEFLT][VALUE]-agcnonenone-agcthresh2.02.000000e+00-allphone-allphone_cinono-alpha0.979.700000e-01-ascale20.02.000000e+01-aw11-backtracenono-beam1e-481.000000e-48-bestpathyesyes-bestpathlw9.59.500000e+00-ceplen1313-cmncurrentcurrent-cmninit8.040,3,-1-compallsennono-debug0-dict/usr/local/share/pocketsphinx/model/en-us/9961.dic-dictcasenono-dithernono-doublebwnono-ds11-fdict-feat1s_c_d_dd1s_c_d_dd-featparams-fillprob1e-81.000000e-08-frate100100-fsg-fsgusealtpronyesyes-fsgusefilleryesyes-fwdflatyesyes-fwdflatbeam1e-641.000000e-64-fwdflatefwid44-fwdflatlw8.58.500000e+00-fwdflatsfwin2525-fwdflatwbeam7e-297.000000e-29-fwdtreeyesyes-hmm/usr/local/share/pocketsphinx/model/en-us/en-us-input_endianlittlelittle-jsgf-keyphrase-kws-kws_delay1010-kws_plp1e-11.000000e-01-kws_threshold11.000000e+00-latsize50005000-lda-ldadim00-lifter022-lm/usr/local/share/pocketsphinx/model/en-us/9961.lm-lmctl-lmname-logbase1.00011.000100e+00-logfn-logspecnono-lowerf133.333341.300000e+02-lpbeam1e-401.000000e-40-lponlybeam7e-297.000000e-29-lw6.56.500000e+00-maxhmmpf3000030000-maxwpf-1-1-mdef-mean-mfclogdir-min_endfr00-mixw-mixwfloor0.00000011.000000e-07-mllr-mmapyesyes-ncep1313-nfft512512-nfilt4025-nwpen1.01.000000e+00-pbeam1e-481.000000e-48-pip1.01.000000e+00-pl_beam1e-101.000000e-10-pl_pbeam1e-101.000000e-10-pl_pip1.01.000000e+00-pl_weight3.03.000000e+00-pl_window55-rawlogdir-remove_dcnono-remove_noiseyesyes-remove_silenceyesyes-round_filtersyesyes-samprate160001.600000e+04-seed-1-1-sendump-senlogdir-senmgau-silprob0.0055.000000e-03-smoothspecnono-svspec0-12/13-25/26-38-tmat-tmatfloor0.00011.000000e-04-topn44-topn_beam00-toprule-transformlegacydct-unit_areayesyes-upperf6855.49766.800000e+03-uw1.01.000000e+00-vad_postspeech5050-vad_prespeech2020-vad_startspeech1010-vad_threshold2.02.000000e+00-var-varfloor0.00011.000000e-04-varnormnono-verbosenono-warp_params-warp_typeinverse_linearinverse_linear-wbeam7e-297.000000e-29-wip0.656.500000e-01-wlen0.0256252.562500e-02INFO:feat.c(715):Initializingfeaturestreamtotype:'1s_c_d_dd',ceplen=13,CMN='current',VARNORM='no',AGC='none'INFO:cmn.c(143):mean[0]=12.00,mean[1..12]=0.0INFO:acmod.c(164):Usingsubvectorspecification0-12/13-25/26-38INFO:mdef.c(518):Readingmodeldefinition:/usr/local/share/pocketsphinx/model/en-us/en-us/mdefINFO:mdef.c(531):Foundbyte-ordermarkBMDF,assumingthisisabinarymdeffileINFO:bin_mdef.c(336):Readingbinarymodeldefinition:/usr/local/share/pocketsphinx/model/en-us/en-us/mdefINFO:bin_mdef.c(516):42CI-phone,137053CD-phone,3emitstate/phone,126CI-sen,5126Sen,29324Sen-SeqINFO:tmat.c(206):ReadingHMMtransitionprobabilitymatrices:/usr/local/share/pocketsphinx/model/en-us/en-us/transition_matricesINFO:acmod.c(117):AttemptingtousePTMcomputationmoduleINFO:ms_gauden.c(198):Readingmixturegaussianparameter:/usr/local/share/pocketsphinx/model/en-us/en-us/meansINFO:ms_gauden.c(292):42codebook,3feature,size:INFO:ms_gauden.c(294):128x13INFO:ms_gauden.c(294):128x13INFO:ms_gauden.c(294):128x13INFO:ms_gauden.c(198):Readingmixturegaussianparameter:/usr/local/share/pocketsphinx/model/en-us/en-us/variancesINFO:ms_gauden.c(292):42codebook,3feature,size:INFO:ms_gauden.c(294):128x13INFO:ms_gauden.c(294):128x13INFO:ms_gauden.c(294):128x13INFO:ms_gauden.c(354):222variancevaluesflooredINFO:ptm_mgau.c(476):Loadingsenonesfromdumpfile/usr/local/share/pocketsphinx/model/en-us/en-us/sendumpINFO:ptm_mgau.c(500):BEGINFILEFORMATDESCRIPTIONINFO:ptm_mgau.c(563):Rows:128,Columns:5126INFO:ptm_mgau.c(595):Usingmemory-mappedI/OforsenonesINFO:ptm_mgau.c(835):Maximumtop-N:4INFO:phone_loop_search.c(114):Statebeam-225Phoneexitbeam-225Insertionpenalty0INFO:dict.c(320):Allocating4112*20bytes(80KiB)forwordentriesINFO:dict.c(333):Readingmaindictionary:/usr/local/share/pocketsphinx/model/en-us/9961.dicINFO:dict.c(213):Allocated0KiBforstrings,0KiBforphonesINFO:dict.c(336):11wordsreadINFO:dict.c(358):Readingfillerdictionary:/usr/local/share/pocketsphinx/model/en-us/en-us/noisedictINFO:dict.c(213):Allocated0KiBforstrings,0KiBforphonesINFO:dict.c(361):5wordsreadINFO:dict2pid.c(396):BuildingPIDtablesfordictionaryINFO:dict2pid.c(406):Allocating42^3*2bytes(144KiB)forword-initialtriphonesINFO:dict2pid.c(132):Allocated21336bytes(20KiB)forword-finaltriphonesINFO:dict2pid.c(196):Allocated21336bytes(20KiB)forsingle-phonewordtriphonesINFO:ngram_model_trie.c(456):TryingtoreadLMintriebinaryformatINFO:ngram_model_trie.c(467):Headerdoesn't matchINFO: ngram_model_trie.c(189): Trying to read LM in arpa formatINFO: ngram_model_trie.c(205): LM of order 3INFO: ngram_model_trie.c(207): #1-grams: 10INFO: ngram_model_trie.c(207): #2-grams: 13INFO: ngram_model_trie.c(207): #3-grams: 12INFO: lm_trie.c(399): Training quantizerINFO: lm_trie.c(407): Building LM trieINFO: ngram_search_fwdtree.c(99): 10 unique initial diphonesINFO: ngram_search_fwdtree.c(148): 0 root, 0 non-root channels, 6 single-phone wordsINFO: ngram_search_fwdtree.c(186): Creating search treeINFO: ngram_search_fwdtree.c(192): before: 0 root, 0 non-root channels, 6 single-phone wordsINFO: ngram_search_fwdtree.c(326): after: max nonroot chan increased to 136INFO: ngram_search_fwdtree.c(339): after: 10 root, 8 non-root channels, 5 single-phone wordsINFO: ngram_search_fwdflat.c(157): fwdflat: min_ef_width = 4, max_sf_win = 25ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.front.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM frontALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rearALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfeALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.sideALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround21ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround40.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround40ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround41ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround50ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround51.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround51ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.surround71.0:CARD=0'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM surround71ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM iec958ALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdifALSA lib confmisc.c:1286:(snd_func_refer) Unable to find definition 'cards.bcm2835.pcm.iec958.0:CARD=0,AES0=4,AES1=130,AES2=0,AES3=2'ALSA lib conf.c:4259:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directoryALSA lib conf.c:4738:(snd_config_expand) Evaluate error: No such file or directoryALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM spdifALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmiALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmiALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modemALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modemALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phonelineALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phonelineALSA lib dlmisc.c:252:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_bluetooth.soALSA lib dlmisc.c:252:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/arm-linux-gnueabihf/alsa-lib/libasound_module_pcm_bluetooth.soCannot connect to server socket err = No such file or directoryCannot connect to server request channeljack server is not running or cannot be startedExpression 'parameters->channelCount<=maxChans' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1514Expression 'ValidateParameters(inputParameters,hostApi,StreamDirection_In)' failed in 'src/hostapi/alsa/pa_linux_alsa.c',line:2818ExceptioninthreadThread-1:Traceback(mostrecentcalllast):File"/usr/lib/python2.7/threading.py",line810,in__bootstrap_innerself.run()File"testMic0.py",line53,inrunstream=p.open(format=pyaudio.paInt16,channels=1,rate=16000,input=True,frames_per_buffer=1024,input_device_index=1)File"build/bdist.linux-armv7l/egg/pyaudio.py",line750,inopenstream=Stream(self,*args,**kwargs)File"build/bdist.linux-armv7l/egg/pyaudio.py",line441,in__init__self._stream=pa.open(**arguments)IOError:[Errno -9998]InvalidnumberofchannelsINFO:ngram_search_fwdtree.c(432):TOTALfwdtree0.00CPUnanxRTINFO:ngram_search_fwdtree.c(435):TOTALfwdtree0.00wallnanxRTINFO:ngram_search_fwdflat.c(176):TOTALfwdflat0.00CPUnanxRTINFO:ngram_search_fwdflat.c(179):TOTALfwdflat0.00wallnanxRTINFO:ngram_search.c(303):TOTALbestpath0.00CPUnanxRTINFO:ngram_search.c(306):TOTALbestpath0.00wallnanxRT
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I don't think that index 3 is valid in your system, most likely you have different card layout. To get help on this issue you need to provide the alsa configuration. You can dump it with
arecord -l
you can also try to record from command line to make sure things work:
I'm trying to launch pocketsphinx with a mic.
So when I'm launching "pocketsphinx_continuous -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9961.lm -dict 9961.dic -samprate 16000/8000/48000 -inmic yes -adcdev plughw:1,0", there are no problems.
But when I'm launching a script with pocketsphinx where I give some arguments to the decoder, it doesn't work.
Here is an extract of the code :
But it returns : ERROR: "cmd_ln.c", line 938: Unknown argument: -adcdev
Maybe I haven't the right syntax, I don't know.
In python you configure adcdev in pyaudio framework which does the recording, not in pocketsphinx. You can use input_device_index option for that.
So I remove the line
config.set_string('-adcdev', 'plughw:1,0').Then I replace the line
stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024)with
stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024, input_device_index=1)But I still have some errors.
What errors
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in bootstrap_inner
self.run()
File "testMic0.py", line 51, in run
decoder = Decoder(config)
File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 266, in __init
this = _pocketsphinx.new_Decoder(*args)
RuntimeError: new_Decoder returned -1
You can enable logging back (-logfn option) to see the details.
It is saved in /dev/null, but I don't know how to open this file.
/dev/null is a unix special file (device) to drop output. Everything written to that file is lost.
You can remove the line
to dump log to stdout. You can also use
to dump log to a file.
Ok, thanks you.
So I could fix some erros, but I still have these ones :
I converted 9961.lm.bin into 9961.lm.bin and some errors are no longer here.
It seems like I have some problems with my cards
You need to configure alsa properly first, then start playing with pocketsphinx.
It didn't work on my Raspberry Pi, but on my laptop, when I'm launching my program with a stream related to the third micro like this :
stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024, input_device_index = 3I obtain these errors, which said that the number of channel (1 here) is incorrect.
I don't think that index 3 is valid in your system, most likely you have different card layout. To get help on this issue you need to provide the alsa configuration. You can dump it with
you can also try to record from command line to make sure things work:
The result of arecord -l is :
So I'm launching
arecord -D plughw;3,0, but index_option_device requires an integer.The result of arecord -l is :
So I'm launching
arecord -D plughw;3,0, but index_option_device requires an integer.I guess you need to try other values of index like 1 or 2, don't you think so.
Yes, of course I already tried index between 0 and 3 but none of these work. I think the channel is the problem.
Try with two channels?
With this piece of code found on https://doc.ubuntu-fr.org/pocketsphinx, I succeeded to list all the input devices index like this :
Here the index was 5.
Thanks you very much for your help, I'm very grateful to you.