Menu

french language and simple python prog for pocketsphinx

Help
2017-02-14
2017-03-29
  • justin case

    justin case - 2017-02-14

    SOLVED LAST POST

    Hello communtiy,

    First of all.. I am a newbie and dont knew much.

    I read all howtos and tutorials more often as I should... I think those are for developers and useres with experience.
    Nevertheless I really want to get it to start so here are my questions.

    I found a python prog that should start a aktion to a given string

    my goal is to speak some french words to my rapserry 2 b+ and he does some aktion ...

    example "luemiere s'il vous plait" he put the lights on

    Plz help me and other newbies to get some little work done :)

    best regards

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    #!/usr/bin/python
    
    from os import environ, path
    from pocketsphinx.pocketsphinx import *
    from sphinxbase.sphinxbase import *
    import pyaudio
    import wave
    import socket
    import time
    
    #pocketsphinx_continuous -adcdev sysdefault -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9735.lm -dict 9735.dic -samprate 16000 -inmic yes
    
    #MODELDIR = "/usr/local/share/pocketsphinx/model"
    MODELDIR = "/home/mentor/pocketsphinx-5prealpha/model"
    #modeldir = "/home/mentor/pocketsphinx-5prealpha/model"
    #DATADIR = "/home/perf/Downloads/TrevorWarren/Python/Dev/PocketSpinx_TTS/data"
    #DATADIR = "/home/mentor/pocketsphinx-5prealpha/test/data"
    DATADIR = "/home/mentor/pocketsphinx-5prealpha/test/data"
    
    # Create a decoder with certain model
    config = Decoder.default_config()
    config.set_string('-adcdev', 'sysdefault')
    #config.set_string('-adcdev', 'plughw:0,0')
    config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/en-us/en-us')
    config.set_string('-lm', '/usr/local/share/pocketsphinx/model/de-deu/engwordlist/9615.lm')
    #config.set_string('-kws', '/home/perf/Downloads/TrevorWarren/Python/Dev/PocketSpinx_TTS/data/keywords')
    config.set_string('-dict', '/usr/local/share/pocketsphinx/model/de-deu/engwordlist/9615.dic')
    config.set_string('-samprate', '16000')
    config.set_string('-inmic', 'yes')
    #Specify recognition key phrase
    #config.set_string('-keyphrase', 'Open Garage')
    #config.set_float('-kws_threshold', 1e+20)
    
    # Hide the VERY verbose logging information
    config.set_string('-logfn', '/dev/null')
    
    decoder = Decoder(config)
    
    p = pyaudio.PyAudio()
    stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input_device_index=1, input=True, output=False)
    #frames_per_buffer=256
    stream.start_stream()
    in_speech_bf = False
    
    #decoder.set_lm_file("lm", '/usr/local/share/pocketsphinx/model/en-us/en-us.lm.bin')
    #decoder.set_keyphrase("kws", "FORWARD")
    #decoder.set_search("kws")
    #decoder = Decoder(config)
    
    #decoder.start_utt()
    #print "Starting to listennnnn"
    
    decoder.start_utt()
    while True:
        try:
            buf = stream.read(1024)
            if buf:
                decoder.process_raw(buf, False, False)
                if decoder.get_in_speech() != in_speech_bf:
                    in_speech_bf = decoder.get_in_speech()
                    if not in_speech_bf:
                        decoder.end_utt()
                        res = decoder.hyp().hypstr
                        print res
                        if res == "I AM FINE":
                           print "Meuuuuuuuuuuh."
                        decoder.start_utt()
            else:
                break
        except:
            print "Meh."
            pass
    decoder.end_utt()
    

    it works half .. it does the aktion i want(trigger on "I AM FINE") but there are some errors and i dont knew why he dont get the option "-inmic" for example or why he is alwas print MEH and why he does not want to close with STRG + C .....the outcame

    mentor@Bunk3r:~/pythonstt$ sudo python ESFUNZTJUHUJUHUHUBACKEDITUPSOFORT.py
    [sudo] password for mentor:
    ERROR: "cmd_ln.c", line 942: Unknown argument: -adcdev
    ERROR: "cmd_ln.c", line 994: Unknown argument: -adcdev
    ERROR: "cmd_ln.c", line 942: Unknown argument: -inmic
    ERROR: "cmd_ln.c", line 994: Unknown argument: -inmic
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    
    Meh.
    Meh.
    TIME
    Meh.
    Meh.
    I I AM FINE
    Meh.
    Meh.
    I AM FINE
    Meuuuuuuuuuuh.
    Meh.
    Meh.
    I AM FINE
    Meuuuuuuuuuuh.
    Meh.
    ^CMeh.
    Meh.
    ^CMeh.
    ^C^CMeh.
    ^C^CMeh.
    ^CMeh.
    ^C^CMeh.
    ^CMeh.
    ^C^C^C^C^C^C^C^C^C^C^C^C^C^CMeh.
    python: ngram_search_fwdtree.c:637: eval_nonroot_chan: Assertion `(&hmm->hmm)->frame == frame_idx' failed.
    mentor@Bunk3r:~/pythonstt$ ^C
    mentor@Bunk3r:~/pythonstt$ ^C
    

    So I try to adept this to french

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    #!/usr/bin/python
    
    from os import environ, path
    from pocketsphinx.pocketsphinx import *
    from sphinxbase.sphinxbase import *
    import pyaudio
    import wave
    import socket
    import time
    
    #pocketsphinx_continuous -adcdev sysdefault -hmm /usr/local/share/pocketsphinx/model/en-us/en-us -lm 9735.lm -dict 9735.dic -samprate 16000 -inmic yes
    
    #MODELDIR = "/usr/local/share/pocketsphinx/model"
    MODELDIR = "/home/mentor/pocketsphinx-5prealpha/model"
    #modeldir = "/home/mentor/pocketsphinx-5prealpha/model"
    #DATADIR = "/home/perf/Downloads/TrevorWarren/Python/Dev/PocketSpinx_TTS/data"
    #DATADIR = "/home/mentor/pocketsphinx-5prealpha/test/data"
    DATADIR = "/home/mentor/pocketsphinx-5prealpha/test/data"
    
    # Create a decoder with certain model
    config = Decoder.default_config()
    config.set_string('-adcdev', 'sysdefault')
    #config.set_string('-adcdev', 'plughw:0,0')
    config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/')
    config.set_string('-lm', '/usr/local/share/pocketsphinx/model/fr-fra/fr-small.lm.bin')
    #config.set_string('-kws', '/home/perf/Downloads/TrevorWarren/Python/Dev/PocketSpinx_TTS/data/keywords')
    config.set_string('-dict', '/usr/local/share/pocketsphinx/model/fr-fra/myselffr.dic')
    
    config.set_string('-samprate', '16000')
    config.set_string('-inmic', 'yes')
    #Specify recognition key phrase
    #config.set_string('-keyphrase', 'Open Garage')
    #config.set_float('-kws_threshold', 1e+20)
    
    # Hide the VERY verbose logging information
    config.set_string('-logfn', '/dev/null')
    
    decoder = Decoder(config)
    
    p = pyaudio.PyAudio()
    stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input_device_index=1, input=True, output=False)
    #frames_per_buffer=256
    stream.start_stream()
    in_speech_bf = False
    
    #decoder.start_utt()
    #print "Starting to listennnnn"
    
    decoder.start_utt()
    while True:
        try:
            buf = stream.read(1024)
            if buf:
                decoder.process_raw(buf, False, False)
                if decoder.get_in_speech() != in_speech_bf:
                    in_speech_bf = decoder.get_in_speech()
                    if not in_speech_bf:
                        decoder.end_utt()
                        res = decoder.hyp().hypstr
                        print res
                        if res == "rapport":
                           print "Meuuuuuuuuuuh."
                        decoder.start_utt()
            else:
                break
        except:
            print "Meh."
            pass
    decoder.end_utt()
    

    but with french it doesnt work at all here is the outcome...

    mentor@Bunk3r:~/pythonstt$ sudo python sampleprogstreamic.py
    ERROR: "cmd_ln.c", line 942: Unknown argument: -adcdev
    ERROR: "cmd_ln.c", line 994: Unknown argument: -adcdev
    ERROR: "cmd_ln.c", line 942: Unknown argument: -inmic
    ERROR: "cmd_ln.c", line 994: Unknown argument: -inmic
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    Meh.
    python: ngram_search_fwdtree.c:658: eval_word_chan: Assertion `(ngs->word_active[(w)/32] & (1UL << ((w) & (32-1))))' failed.
    mentor@Bunk3r:~/pythonstt$
    

    If i start it directly it works....

    sudo pocketsphinx_continuous -hmm /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0 -lm /usr/local/share/pocketsphinx/model/fr-fra/fr-small.lm.n -dict /usr/local/share/pocketsphinx/model/fr-fra/myselffr.dic -samprate 16000/8000/48000 -inmic yes

    mentor@Bunk3r:/usr/local/share/pocketsphinx/model/fr-fra$ sudo pocketsphinx_continuous -hmm /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0 -lm /usr/local/share/pocketsphinx/model/fr-fra/fr-small.lm.bin -dict /usr/local/share/pocketsphinx/model/fr-fra/myselffr.dic -samprate 16000/8000/48000 -inmic yes
    INFO: pocketsphinx.c(152): Parsed model-specific feature parameters from /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/feat.params
    Current configuration:
    [NAME]                  [DEFLT]         [VALUE]
    -agc                    none            max
    -agcthresh              2.0             2.000000e+00
    -allphone
    -allphone_ci            no              no
    -alpha                  0.97            9.700000e-01
    -ascale                 20.0            2.000000e+01
    -aw                     1               1
    -backtrace              no              no
    -beam                   1e-48           1.000000e-48
    -bestpath               yes             yes
    -bestpathlw             9.5             9.500000e+00
    -ceplen                 13              13
    -cmn                    live            current
    -cmninit                40,3,-1         40,3,-1
    -compallsen             no              no
    -debug                                  0
    -dict                                   /usr/local/share/pocketsphinx/model/fr-fra/myselffr.dic
    -dictcase               no              no
    -dither                 no              no
    -doublebw               no              no
    -ds                     1               1
    -fdict
    -feat                   1s_c_d_dd       1s_c_d_dd
    -featparams
    -fillprob               1e-8            1.000000e-08
    -frate                  100             100
    -fsg
    -fsgusealtpron          yes             yes
    -fsgusefiller           yes             yes
    -fwdflat                yes             yes
    -fwdflatbeam            1e-64           1.000000e-64
    -fwdflatefwid           4               4
    -fwdflatlw              8.5             8.500000e+00
    -fwdflatsfwin           25              25
    -fwdflatwbeam           7e-29           7.000000e-29
    -fwdtree                yes             yes
    -hmm                                    /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0
    -input_endian           little          little
    -jsgf
    -keyphrase
    -kws
    -kws_delay              10              10
    -kws_plp                1e-1            1.000000e-01
    -kws_threshold          1               1.000000e+00
    -latsize                5000            5000
    -lda
    -ldadim                 0               0
    -lifter                 0               0
    -lm                                     /usr/local/share/pocketsphinx/model/fr-fra/fr-small.lm.bin
    -lmctl
    -lmname
    -logbase                1.0001          1.000100e+00
    -logfn
    -logspec                no              no
    -lowerf                 133.33334       1.333333e+02
    -lpbeam                 1e-40           1.000000e-40
    -lponlybeam             7e-29           7.000000e-29
    -lw                     6.5             6.500000e+00
    -maxhmmpf               30000           30000
    -maxwpf                 -1              -1
    -mdef
    -mean
    -mfclogdir
    -min_endfr              0               0
    -mixw
    -mixwfloor              0.0000001       1.000000e-07
    -mllr
    -mmap                   yes             yes
    -ncep                   13              13
    -nfft                   512             512
    -nfilt                  40              40
    -nwpen                  1.0             1.000000e+00
    -pbeam                  1e-48           1.000000e-48
    -pip                    1.0             1.000000e+00
    -pl_beam                1e-10           1.000000e-10
    -pl_pbeam               1e-10           1.000000e-10
    -pl_pip                 1.0             1.000000e+00
    -pl_weight              3.0             3.000000e+00
    -pl_window              5               5
    -rawlogdir
    -remove_dc              no              no
    -remove_noise           yes             yes
    -remove_silence         yes             yes
    -round_filters          yes             yes
    -samprate               16000           1.600000e+04
    -seed                   -1              -1
    -sendump
    -senlogdir
    -senmgau
    -silprob                0.005           5.000000e-03
    -smoothspec             no              no
    -svspec
    -tmat
    -tmatfloor              0.0001          1.000000e-04
    -topn                   4               4
    -topn_beam              0               0
    -toprule
    -transform              legacy          legacy
    -unit_area              yes             yes
    -upperf                 6855.4976       6.855498e+03
    -uw                     1.0             1.000000e+00
    -vad_postspeech         50              50
    -vad_prespeech          20              20
    -vad_startspeech        10              10
    -vad_threshold          2.0             2.000000e+00
    -var
    -varfloor               0.0001          1.000000e-04
    -varnorm                no              no
    -verbose                no              no
    -warp_params
    -warp_type              inverse_linear  inverse_linear
    -wbeam                  7e-29           7.000000e-29
    -wip                    0.65            6.500000e-01
    -wlen                   0.025625        2.562500e-02
    
    INFO: feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='batch', VARNORM='no', AGC='max'
    INFO: agc.c(132): AGCEMax: max= 5.00
    INFO: mdef.c(518): Reading model definition: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/mdef
    INFO: bin_mdef.c(181): Allocating 85844 * 8 bytes (670 KiB) for CD tree
    INFO: tmat.c(149): Reading HMM transition probability matrices: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/transition_matrices
    INFO: acmod.c(113): Attempting to use PTM computation module
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/means
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/variances
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(304): 3502 variance values floored
    INFO: ptm_mgau.c(804): Number of codebooks exceeds 256: 5725
    INFO: acmod.c(115): Attempting to use semi-continuous computation module
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/means
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/variances
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(304): 3502 variance values floored
    INFO: acmod.c(117): Falling back to general multi-stream GMM computation
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/means
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/variances
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(304): 3502 variance values floored
    INFO: ms_senone.c(149): Reading senone mixture weights: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/mixture_weights
    INFO: ms_senone.c(200): Truncating senone logs3(pdf) values by 10 bits
    INFO: ms_senone.c(207): Not transposing mixture weights in memory
    INFO: ms_senone.c(268): Read mixture weights for 5725 senones: 1 features x 22 codewords
    INFO: ms_senone.c(320): Mapping senones to individual codebooks
    INFO: ms_mgau.c(144): The value of topn: 4
    INFO: phone_loop_search.c(114): State beam -225 Phone exit beam -225 Insertion penalty 0
    INFO: dict.c(320): Allocating 4116 * 20 bytes (80 KiB) for word entries
    INFO: dict.c(333): Reading main dictionary: /usr/local/share/pocketsphinx/model/fr-fra/myselffr.dic
    INFO: dict.c(213): Dictionary size 11, allocated 0 KiB for strings, 0 KiB for phones
    INFO: dict.c(336): 11 words read
    INFO: dict.c(358): Reading filler dictionary: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/noisedict
    INFO: dict.c(213): Dictionary size 19, allocated 0 KiB for strings, 0 KiB for phones
    INFO: dict.c(361): 8 words read
    INFO: dict2pid.c(396): Building PID tables for dictionary
    INFO: dict2pid.c(406): Allocating 45^3 * 2 bytes (177 KiB) for word-initial triphones
    INFO: dict2pid.c(132): Allocated 24480 bytes (23 KiB) for word-final triphones
    INFO: dict2pid.c(196): Allocated 24480 bytes (23 KiB) for single-phone word triphones
    INFO: ngram_model_trie.c(354): Trying to read LM in trie binary format
    INFO: ngram_search_fwdtree.c(74): Initializing search tree
    INFO: ngram_search_fwdtree.c(101): 5 unique initial diphones
    WARN: "ngram_search_fwdtree.c", line 114: Filler word 18 = [euh] has more than one phone, ignoring it.
    INFO: ngram_search_fwdtree.c(186): Creating search channels
    INFO: ngram_search_fwdtree.c(323): Max nonroot chan increased to 156
    INFO: ngram_search_fwdtree.c(333): Created 5 root, 28 non-root channels, 7 single-phone words
    INFO: ngram_search_fwdflat.c(157): fwdflat: min_ef_width = 4, max_sf_win = 25
    INFO: continuous.c(307): pocketsphinx_continuous COMPILED ON: Feb  2 2017, AT: 20:53:48
    
    INFO: continuous.c(252): Ready....
    INFO: continuous.c(261): Listening...
    INFO: cmn_live.c(120): Update from < 40.00  3.00 -1.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 >
    INFO: cmn_live.c(138): Update to   <  4.91  0.20  0.14 -0.15 -0.34 -0.23  0.05 -0.11 -0.01 -0.09 -0.02 -0.03 -0.15 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):        1 words recognized (0/fr)
    INFO: ngram_search_fwdtree.c(1552):     1328 senones evaluated (5/fr)
    INFO: ngram_search_fwdtree.c(1556):      268 channels searched (1/fr), 0 1st, 268 last
    INFO: ngram_search_fwdtree.c(1559):      268 words for which last channels evaluated (1/fr)
    INFO: ngram_search_fwdtree.c(1561):        0 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 2.05 CPU 0.765 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 4.20 wall 1.566 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 0 words
    INFO: ngram_search_fwdflat.c(948):        1 words recognized (0/fr)
    INFO: ngram_search_fwdflat.c(950):     1357 senones evaluated (5/fr)
    INFO: ngram_search_fwdflat.c(952):      279 channels searched (1/fr)
    INFO: ngram_search_fwdflat.c(954):      279 words searched (1/fr)
    INFO: ngram_search_fwdflat.c(957):        0 word transitions (0/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.04 CPU 0.015 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.04 wall 0.016 xRT
    INFO: ngram_search.c(1197): </s> not found in last frame, using <s>.2 instead
    INFO: ngram_search.c(1250): lattice start node <s>.0 end node <s>.0
    INFO: ngram_search.c(1276): Eliminated 0 nodes before end node
    INFO: ngram_search.c(1381): Lattice has 1 nodes, 0 links
    INFO: ps_lattice.c(1380): Bestpath score: -2147483648
    INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(<s>:0:2) = -536940672
    INFO: continuous.c(275): Ready....
    INFO: continuous.c(261): Listening...
    INFO: cmn_live.c(120): Update from <  4.91  0.20  0.14 -0.15 -0.34 -0.23  0.05 -0.11 -0.01 -0.09 -0.02 -0.03 -0.15 >
    INFO: cmn_live.c(138): Update to   <  5.51  0.38  0.16  0.00 -0.29 -0.29  0.00 -0.18 -0.05 -0.11 -0.06 -0.03 -0.18 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):      577 words recognized (5/fr)
    INFO: ngram_search_fwdtree.c(1552):    14993 senones evaluated (122/fr)
    INFO: ngram_search_fwdtree.c(1556):     3490 channels searched (28/fr), 426 1st, 1943 last
    INFO: ngram_search_fwdtree.c(1559):      643 words for which last channels evaluated (5/fr)
    INFO: ngram_search_fwdtree.c(1561):       83 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 1.88 CPU 1.528 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 5.94 wall 4.831 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 3 words
    INFO: ngram_search_fwdflat.c(948):      670 words recognized (5/fr)
    INFO: ngram_search_fwdflat.c(950):    13248 senones evaluated (108/fr)
    INFO: ngram_search_fwdflat.c(952):     3820 channels searched (31/fr)
    INFO: ngram_search_fwdflat.c(954):     1053 words searched (8/fr)
    INFO: ngram_search_fwdflat.c(957):       94 word transitions (0/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.46 CPU 0.374 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.46 wall 0.370 xRT
    INFO: ngram_search.c(1250): lattice start node <s>.0 end node </s>.119
    INFO: ngram_search.c(1276): Eliminated 3 nodes before end node
    INFO: ngram_search.c(1381): Lattice has 196 nodes, 576 links
    INFO: ps_lattice.c(1380): Bestpath score: -5525
    INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(</s>:119:121) = -324937
    INFO: ps_lattice.c(1441): Joint P(O,S) = -361709 P(S|O) = -36772
    INFO: ngram_search.c(872): bestpath 0.00 CPU 0.000 xRT
    INFO: ngram_search.c(875): bestpath 0.00 wall 0.003 xRT
    lumière
    INFO: continuous.c(275): Ready....
    INFO: continuous.c(261): Listening...
    INFO: cmn_live.c(120): Update from <  5.51  0.38  0.16  0.00 -0.29 -0.29  0.00 -0.18 -0.05 -0.11 -0.06 -0.03 -0.18 >
    INFO: cmn_live.c(138): Update to   <  5.67  0.52  0.20 -0.01 -0.36 -0.30  0.03 -0.20 -0.06 -0.12 -0.06 -0.03 -0.18 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):      523 words recognized (4/fr)
    INFO: ngram_search_fwdtree.c(1552):    10884 senones evaluated (90/fr)
    INFO: ngram_search_fwdtree.c(1556):     2576 channels searched (21/fr), 377 1st, 1674 last
    INFO: ngram_search_fwdtree.c(1559):      575 words for which last channels evaluated (4/fr)
    INFO: ngram_search_fwdtree.c(1561):       43 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 1.75 CPU 1.446 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 5.91 wall 4.880 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 3 words
    INFO: ngram_search_fwdflat.c(948):      554 words recognized (5/fr)
    INFO: ngram_search_fwdflat.c(950):     8977 senones evaluated (74/fr)
    INFO: ngram_search_fwdflat.c(952):     2372 channels searched (19/fr)
    INFO: ngram_search_fwdflat.c(954):      922 words searched (7/fr)
    INFO: ngram_search_fwdflat.c(957):      112 word transitions (0/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.32 CPU 0.264 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.32 wall 0.267 xRT
    INFO: ngram_search.c(1250): lattice start node <s>.0 end node </s>.78
    INFO: ngram_search.c(1276): Eliminated 0 nodes before end node
    INFO: ngram_search.c(1381): Lattice has 158 nodes, 125 links
    INFO: ps_lattice.c(1380): Bestpath score: -3020
    INFO: ps_lattice.c(1384): Normalizer P(O) = alpha(</s>:78:119) = -228434
    INFO: ps_lattice.c(1441): Joint P(O,S) = -250548 P(S|O) = -22114
    INFO: ngram_search.c(872): bestpath 0.00 CPU 0.000 xRT
    INFO: ngram_search.c(875): bestpath 0.00 wall 0.002 xRT
    rapport
    INFO: continuous.c(275): Ready....
    
     

    Last edit: justin case 2017-02-19
    • Arseniy Gorin

      Arseniy Gorin - 2017-02-15

      You do not need ''-adcdev" and "-inmic" options for this script if I understand correctly what you are trying to acheive. I would suggest to follow this script

      Also, ALSA errors can be fixed by commenting lines in the config as suggested here

       
  • justin case

    justin case - 2017-02-16

    Big thanks to you.

    I already known the script and tried about 100 times the last 2 weeks, but now i got it running...
    also big thanks for the not needed config parameters and the help to fix the also output.

    so the scritp is working with french BUT it is not important what i say he always add that
    "Detected keyphrase, restarting search" even if he knews it is not the keyword

    like (the keyword ist "musique")
    "INFO: cmn_live.c(88): Update from < 5.76 0.28 0.11 0.01 -0.28 -0.18 -0.02 -0.16 -0.10 -0.14 -0.08 -0.11 -0.13 >
    INFO: cmn_live.c(105): Update to < 5.64 0.27 0.12 0.00 -0.27 -0.16 -0.02 -0.15 -0.10 -0.15 -0.08 -0.11 -0.13 >
    0, 8049, 8077), ('<sil>', 0, 8078, 8102), ('computer', 0, 8103, 8149)]
    Detected keyphrase, restarting search"

    the code

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    #!/usr/bin/python
    
    import sys, os
    from pocketsphinx.pocketsphinx import *
    from sphinxbase.sphinxbase import *
    
    #MODELDIR = "/usr/local/share/pocketsphinx/model"
    modeldir = "/usr/local/share/pocketsphinx/model"
    #modeldir = "/home/mentor/pocketsphinx-5prealpha/model"
    datadir = "/usr/local/share/pocketsphinx/test/data"
    
    config = Decoder.default_config()
    #config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/en-us/en-us')
    #config.set_string('-lm', '/usr/local/share/pocketsphinx/model/de-deu/engwordlist/9615.lm')
    #config.set_string('-dict', '/usr/local/share/pocketsphinx/model/de-deu/engwordlist/9615.dic')
    
    config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0')
    config.set_string('-lm', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm')
    config.set_string('-dict', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrdic.dic')
    config.set_string('-samprate', '16000')
    
    #config.set_string('-hmm', os.path.join(modeldir, 'en-us/en-us'))
    #config.set_string('-dict', os.path.join(modeldir, 'en-us/cmudict-en-us.dict'))
    config.set_string('-keyphrase', 'musique')
    config.set_float('-kws_threshold', 1e+20)
    
    # Open file to read the data
    #stream = open(os.path.join(datadir, "goforward.raw"), "rb")
    
    # Alternatively you can read from microphone
    import pyaudio
    #
    p = pyaudio.PyAudio()
    stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024)
    stream.start_stream()
    
    # Process audio chunk by chunk. On keyphrase detected perform action and restart search
    decoder = Decoder(config)
    decoder.start_utt()
    while True:
        buf = stream.read(1024)
        if buf:
             decoder.process_raw(buf, False, False)
        else:
             break
        if decoder.hyp() != None:
            print ([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
            print ("Detected keyphrase, restarting search")
            decoder.end_utt()
            decoder.start_utt()
    

    the outcome

    sudo python workonit.py
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM dmix:0
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    INFO: pocketsphinx.c(152): Parsed model-specific feature parameters from /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/feat.params
    Current configuration:
    [NAME]                  [DEFLT]         [VALUE]
    -agc                    none            max
    -agcthresh              2.0             2.000000e+00
    -allphone
    -allphone_ci            no              no
    -alpha                  0.97            9.700000e-01
    -ascale                 20.0            2.000000e+01
    -aw                     1               1
    -backtrace              no              no
    -beam                   1e-48           1.000000e-48
    -bestpath               yes             yes
    -bestpathlw             9.5             9.500000e+00
    -ceplen                 13              13
    -cmn                    live            current
    -cmninit                40,3,-1         40,3,-1
    -compallsen             no              no
    -debug                                  0
    -dict                                   /usr/local/share/pocketsphinx/model/fr-fra/meinfrdic.dic
    -dictcase               no              no
    -dither                 no              no
    -doublebw               no              no
    -ds                     1               1
    -fdict
    -feat                   1s_c_d_dd       1s_c_d_dd
    -featparams
    -fillprob               1e-8            1.000000e-08
    -frate                  100             100
    -fsg
    -fsgusealtpron          yes             yes
    -fsgusefiller           yes             yes
    -fwdflat                yes             yes
    -fwdflatbeam            1e-64           1.000000e-64
    -fwdflatefwid           4               4
    -fwdflatlw              8.5             8.500000e+00
    -fwdflatsfwin           25              25
    -fwdflatwbeam           7e-29           7.000000e-29
    -fwdtree                yes             yes
    -hmm                                    /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0
    -input_endian           little          little
    -jsgf
    -keyphrase                              musique
    -kws
    -kws_delay              10              10
    -kws_plp                1e-1            1.000000e-01
    -kws_threshold          1               1.000000e+20
    -latsize                5000            5000
    -lda
    -ldadim                 0               0
    -lifter                 0               0
    -lm                                     /usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm
    -lmctl
    -lmname
    -logbase                1.0001          1.000100e+00
    -logfn
    -logspec                no              no
    -lowerf                 133.33334       1.333333e+02
    -lpbeam                 1e-40           1.000000e-40
    -lponlybeam             7e-29           7.000000e-29
    -lw                     6.5             6.500000e+00
    -maxhmmpf               30000           30000
    -maxwpf                 -1              -1
    -mdef
    -mean
    -mfclogdir
    -min_endfr              0               0
    -mixw
    -mixwfloor              0.0000001       1.000000e-07
    -mllr
    -mmap                   yes             yes
    -ncep                   13              13
    -nfft                   512             512
    -nfilt                  40              40
    -nwpen                  1.0             1.000000e+00
    -pbeam                  1e-48           1.000000e-48
    -pip                    1.0             1.000000e+00
    -pl_beam                1e-10           1.000000e-10
    -pl_pbeam               1e-10           1.000000e-10
    -pl_pip                 1.0             1.000000e+00
    -pl_weight              3.0             3.000000e+00
    -pl_window              5               5
    -rawlogdir
    -remove_dc              no              no
    -remove_noise           yes             yes
    -remove_silence         yes             yes
    -round_filters          yes             yes
    -samprate               16000           1.600000e+04
    -seed                   -1              -1
    -sendump
    -senlogdir
    -senmgau
    -silprob                0.005           5.000000e-03
    -smoothspec             no              no
    -svspec
    -tmat
    -tmatfloor              0.0001          1.000000e-04
    -topn                   4               4
    -topn_beam              0               0
    -toprule
    -transform              legacy          legacy
    -unit_area              yes             yes
    -upperf                 6855.4976       6.855498e+03
    -uw                     1.0             1.000000e+00
    -vad_postspeech         50              50
    -vad_prespeech          20              20
    -vad_startspeech        10              10
    -vad_threshold          2.0             2.000000e+00
    -var
    -varfloor               0.0001          1.000000e-04
    -varnorm                no              no
    -verbose                no              no
    -warp_params
    -warp_type              inverse_linear  inverse_linear
    -wbeam                  7e-29           7.000000e-29
    -wip                    0.65            6.500000e-01
    -wlen                   0.025625        2.562500e-02
    
    INFO: feat.c(715): Initializing feature stream to type: '1s_c_d_dd', ceplen=13, CMN='batch', VARNORM='no', AGC='max'
    INFO: agc.c(132): AGCEMax: max= 5.00
    INFO: mdef.c(518): Reading model definition: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/mdef
    INFO: bin_mdef.c(181): Allocating 85844 * 8 bytes (670 KiB) for CD tree
    INFO: tmat.c(149): Reading HMM transition probability matrices: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/transition_matrices
    INFO: acmod.c(113): Attempting to use PTM computation module
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/means
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/variances
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(304): 3502 variance values floored
    INFO: ptm_mgau.c(804): Number of codebooks exceeds 256: 5725
    INFO: acmod.c(115): Attempting to use semi-continuous computation module
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/means
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/variances
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(304): 3502 variance values floored
    INFO: acmod.c(117): Falling back to general multi-stream GMM computation
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/means
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(127): Reading mixture gaussian parameter: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/variances
    INFO: ms_gauden.c(242): 5725 codebook, 1 feature, size:
    INFO: ms_gauden.c(244):  22x39
    INFO: ms_gauden.c(304): 3502 variance values floored
    INFO: ms_senone.c(149): Reading senone mixture weights: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/mixture_weights
    INFO: ms_senone.c(200): Truncating senone logs3(pdf) values by 10 bits
    INFO: ms_senone.c(207): Not transposing mixture weights in memory
    INFO: ms_senone.c(268): Read mixture weights for 5725 senones: 1 features x 22 codewords
    INFO: ms_senone.c(320): Mapping senones to individual codebooks
    INFO: ms_mgau.c(144): The value of topn: 4
    INFO: phone_loop_search.c(114): State beam -225 Phone exit beam -225 Insertion penalty 0
    INFO: dict.c(320): Allocating 4126 * 20 bytes (80 KiB) for word entries
    INFO: dict.c(333): Reading main dictionary: /usr/local/share/pocketsphinx/model/fr-fra/meinfrdic.dic
    INFO: dict.c(213): Dictionary size 21, allocated 0 KiB for strings, 0 KiB for phones
    INFO: dict.c(336): 21 words read
    INFO: dict.c(358): Reading filler dictionary: /usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0/noisedict
    INFO: dict.c(213): Dictionary size 29, allocated 0 KiB for strings, 0 KiB for phones
    INFO: dict.c(361): 8 words read
    INFO: dict2pid.c(396): Building PID tables for dictionary
    INFO: dict2pid.c(406): Allocating 45^3 * 2 bytes (177 KiB) for word-initial triphones
    INFO: dict2pid.c(132): Allocated 24480 bytes (23 KiB) for word-final triphones
    INFO: dict2pid.c(196): Allocated 24480 bytes (23 KiB) for single-phone word triphones
    INFO: kws_search.c(406): KWS(beam: -1080, plp: -23, default threshold 449, delay 10)
    INFO: ngram_model_trie.c(354): Trying to read LM in trie binary format
    INFO: ngram_model_trie.c(365): Header doesn't match
    INFO: ngram_model_trie.c(177): Trying to read LM in arpa format
    INFO: ngram_model_trie.c(193): LM of order 2
    INFO: ngram_model_trie.c(195): #1-grams: 10
    INFO: ngram_model_trie.c(195): #2-grams: 5
    INFO: lm_trie.c(474): Training quantizer
    INFO: lm_trie.c(482): Building LM trie
    INFO: ngram_search_fwdtree.c(74): Initializing search tree
    INFO: ngram_search_fwdtree.c(101): 12 unique initial diphones
    WARN: "ngram_search_fwdtree.c", line 114: Filler word 28 = [euh] has more than one phone, ignoring it.
    INFO: ngram_search_fwdtree.c(186): Creating search channels
    INFO: ngram_search_fwdtree.c(323): Max nonroot chan increased to 165
    INFO: ngram_search_fwdtree.c(333): Created 9 root, 37 non-root channels, 7 single-phone words
    INFO: ngram_search_fwdflat.c(157): fwdflat: min_ef_width = 4, max_sf_win = 25
    INFO: kws_search.c(448): TOTAL kws 0.00 CPU nan xRT
    INFO: kws_search.c(451): TOTAL kws 0.00 wall nan xRT
    INFO: cmn_live.c(88): Update from < 40.00  3.00 -1.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00  0.00 >
    INFO: cmn_live.c(105): Update to   <  5.02  0.05  0.12  0.01 -0.20 -0.17 -0.03 -0.11 -0.08 -0.13 -0.08 -0.09 -0.10 >
    INFO: cmn_live.c(88): Update from <  5.02  0.05  0.12  0.01 -0.20 -0.17 -0.03 -0.11 -0.08 -0.13 -0.08 -0.09 -0.10 >
    INFO: cmn_live.c(105): Update to   <  5.44  0.03  0.04  0.03 -0.21 -0.13 -0.05 -0.13 -0.10 -0.14 -0.10 -0.09 -0.10 >
    [('<s>', 0, 5215, 5217), ('[mus]', 0, 5218, 6042), ('[mus]', 0, 6043, 6067), ('[b]', 0, 6068, 6124), ('[b]', 0, 6125, 6176), ('[i]', 0, 6177, 6244), ('<sil>', 0, 6245, 6258), ('[b]', 0, 6259, 6302), ('<sil>', 0, 6303, 6322), ('<sil>', 0, 6323, 6329), ('[b]', 0, 6330, 6346), ('<sil>', 0, 6347, 6406), ('musique', 0, 6407, 6440)]
    Detected keyphrase, restarting search
    INFO: cmn_live.c(120): Update from <  5.44  0.03  0.04  0.03 -0.21 -0.13 -0.05 -0.13 -0.10 -0.14 -0.10 -0.09 -0.10 >
    INFO: cmn_live.c(138): Update to   <  5.61  0.09  0.05  0.05 -0.19 -0.10 -0.03 -0.11 -0.10 -0.15 -0.11 -0.09 -0.10 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):     2372 words recognized (2/fr)
    INFO: ngram_search_fwdtree.c(1552):    57848 senones evaluated (47/fr)
    INFO: ngram_search_fwdtree.c(1556):    12157 channels searched (9/fr), 3612 1st, 3685 last
    INFO: ngram_search_fwdtree.c(1559):     3290 words for which last channels evaluated (2/fr)
    INFO: ngram_search_fwdtree.c(1561):      329 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 12.87 CPU 1.040 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 41.60 wall 3.363 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 1 words
    INFO: ngram_search_fwdflat.c(948):     2715 words recognized (2/fr)
    INFO: ngram_search_fwdflat.c(950):    17726 senones evaluated (14/fr)
    INFO: ngram_search_fwdflat.c(952):     4380 channels searched (3/fr)
    INFO: ngram_search_fwdflat.c(954):     3826 words searched (3/fr)
    INFO: ngram_search_fwdflat.c(957):       50 word transitions (0/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.51 CPU 0.041 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.51 wall 0.041 xRT
    INFO: cmn_live.c(88): Update from <  5.61  0.09  0.05  0.05 -0.19 -0.10 -0.03 -0.11 -0.10 -0.15 -0.11 -0.09 -0.10 >
    INFO: cmn_live.c(105): Update to   <  5.55  0.18  0.09  0.02 -0.23 -0.13 -0.02 -0.11 -0.10 -0.15 -0.10 -0.10 -0.10 >
    [('<s>', 0, 6044, 6060), ('<sil>', 0, 6061, 6071), ('[mus]', 0, 6072, 6095), ('[b]', 0, 6096, 6132), ('<sil>', 0, 6133, 6189), ('<sil>', 0, 6190, 6208), ('<sil>', 0, 6209, 6253), ('rapport', 0, 6254, 6306)]
    Detected keyphrase, restarting search
    INFO: cmn_live.c(120): Update from <  5.55  0.18  0.09  0.02 -0.23 -0.13 -0.02 -0.11 -0.10 -0.15 -0.10 -0.10 -0.10 >
    INFO: cmn_live.c(138): Update to   <  5.73  0.26  0.08 -0.02 -0.28 -0.16 -0.02 -0.13 -0.10 -0.15 -0.08 -0.11 -0.11 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):     1349 words recognized (5/fr)
    INFO: ngram_search_fwdtree.c(1552):    26356 senones evaluated (96/fr)
    INFO: ngram_search_fwdtree.c(1556):     5528 channels searched (20/fr), 1940 1st, 1794 last
    INFO: ngram_search_fwdtree.c(1559):     1451 words for which last channels evaluated (5/fr)
    INFO: ngram_search_fwdtree.c(1561):       40 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 3.45 CPU 1.259 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 8.54 wall 3.116 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 2 words
    INFO: ngram_search_fwdflat.c(948):     1716 words recognized (6/fr)
    INFO: ngram_search_fwdflat.c(950):    10234 senones evaluated (37/fr)
    INFO: ngram_search_fwdflat.c(952):     2612 channels searched (9/fr)
    INFO: ngram_search_fwdflat.c(954):     1979 words searched (7/fr)
    INFO: ngram_search_fwdflat.c(957):       76 word transitions (0/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.27 CPU 0.099 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.27 wall 0.097 xRT
    [('<s>', 0, 7157, 7173), ('<sil>', 0, 7174, 7188), ('<sil>', 0, 7189, 7214), ('computer(2)', 0, 7215, 7266)]
    Detected keyphrase, restarting search
    INFO: cmn_live.c(120): Update from <  5.73  0.26  0.08 -0.02 -0.28 -0.16 -0.02 -0.13 -0.10 -0.15 -0.08 -0.11 -0.11 >
    INFO: cmn_live.c(138): Update to   <  5.76  0.28  0.11  0.01 -0.28 -0.18 -0.02 -0.16 -0.10 -0.14 -0.08 -0.11 -0.13 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):      651 words recognized (5/fr)
    INFO: ngram_search_fwdtree.c(1552):    14673 senones evaluated (121/fr)
    INFO: ngram_search_fwdtree.c(1556):     3394 channels searched (28/fr), 874 1st, 1397 last
    INFO: ngram_search_fwdtree.c(1559):      717 words for which last channels evaluated (5/fr)
    INFO: ngram_search_fwdtree.c(1561):       38 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 2.23 CPU 1.843 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 11.05 wall 9.132 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 5 words
    INFO: ngram_search_fwdflat.c(948):      733 words recognized (6/fr)
    INFO: ngram_search_fwdflat.c(950):     9883 senones evaluated (82/fr)
    INFO: ngram_search_fwdflat.c(952):     2712 channels searched (22/fr)
    INFO: ngram_search_fwdflat.c(954):     1099 words searched (9/fr)
    INFO: ngram_search_fwdflat.c(957):      226 word transitions (1/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.36 CPU 0.298 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.36 wall 0.297 xRT
    INFO: cmn_live.c(88): Update from <  5.76  0.28  0.11  0.01 -0.28 -0.18 -0.02 -0.16 -0.10 -0.14 -0.08 -0.11 -0.13 >
    INFO: cmn_live.c(105): Update to   <  5.64  0.27  0.12  0.00 -0.27 -0.16 -0.02 -0.15 -0.10 -0.15 -0.08 -0.11 -0.13 >
    [('<s>', 0, 8049, 8077), ('<sil>', 0, 8078, 8102), ('computer', 0, 8103, 8149)]
    Detected keyphrase, restarting search
    INFO: cmn_live.c(120): Update from <  5.64  0.27  0.12  0.00 -0.27 -0.16 -0.02 -0.15 -0.10 -0.15 -0.08 -0.11 -0.13 >
    INFO: cmn_live.c(138): Update to   <  5.77  0.29  0.12  0.02 -0.26 -0.18 -0.04 -0.15 -0.09 -0.16 -0.09 -0.11 -0.13 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):      519 words recognized (5/fr)
    INFO: ngram_search_fwdtree.c(1552):    10443 senones evaluated (93/fr)
    INFO: ngram_search_fwdtree.c(1556):     2353 channels searched (21/fr), 581 1st, 1216 last
    INFO: ngram_search_fwdtree.c(1559):      575 words for which last channels evaluated (5/fr)
    INFO: ngram_search_fwdtree.c(1561):       43 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 1.79 CPU 1.598 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 8.26 wall 7.378 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 3 words
    INFO: ngram_search_fwdflat.c(948):      473 words recognized (4/fr)
    INFO: ngram_search_fwdflat.c(950):     7086 senones evaluated (63/fr)
    INFO: ngram_search_fwdflat.c(952):     1910 channels searched (17/fr)
    INFO: ngram_search_fwdflat.c(954):      790 words searched (7/fr)
    INFO: ngram_search_fwdflat.c(957):      126 word transitions (1/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.22 CPU 0.196 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.23 wall 0.201 xRT
    INFO: cmn_live.c(88): Update from <  5.77  0.29  0.12  0.02 -0.26 -0.18 -0.04 -0.15 -0.09 -0.16 -0.09 -0.11 -0.13 >
    INFO: cmn_live.c(105): Update to   <  5.63  0.36  0.16  0.03 -0.25 -0.17 -0.03 -0.15 -0.10 -0.17 -0.11 -0.12 -0.14 >
    [('<s>', 0, 9289, 9306), ('<sil>', 0, 9307, 9312), ('<sil>', 0, 9313, 9327), ('<sil>', 0, 9328, 9341), ('[mus]', 0, 9342, 9366), ('<sil>', 0, 9367, 9470), ('<sil>', 0, 9471, 9483), ('<sil>', 0, 9484, 9503), ('computer', 0, 9504, 9548)]
    Detected keyphrase, restarting search
    INFO: cmn_live.c(120): Update from <  5.63  0.36  0.16  0.03 -0.25 -0.17 -0.03 -0.15 -0.10 -0.17 -0.11 -0.12 -0.14 >
    INFO: cmn_live.c(138): Update to   <  5.54  0.36  0.16  0.03 -0.25 -0.17 -0.03 -0.15 -0.10 -0.16 -0.11 -0.12 -0.14 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: ngram_search_fwdtree.c(1550):     1041 words recognized (4/fr)
    INFO: ngram_search_fwdtree.c(1552):    23417 senones evaluated (86/fr)
    INFO: ngram_search_fwdtree.c(1556):     4689 channels searched (17/fr), 1135 1st, 1747 last
    INFO: ngram_search_fwdtree.c(1559):     1138 words for which last channels evaluated (4/fr)
    INFO: ngram_search_fwdtree.c(1561):       60 candidate words for entering last phone (0/fr)
    INFO: ngram_search_fwdtree.c(1564): fwdtree 3.67 CPU 1.344 xRT
    INFO: ngram_search_fwdtree.c(1567): fwdtree 12.15 wall 4.449 xRT
    INFO: ngram_search_fwdflat.c(302): Utterance vocabulary contains 3 words
    INFO: ngram_search_fwdflat.c(948):     1504 words recognized (6/fr)
    INFO: ngram_search_fwdflat.c(950):    11409 senones evaluated (42/fr)
    INFO: ngram_search_fwdflat.c(952):     2757 channels searched (10/fr)
    INFO: ngram_search_fwdflat.c(954):     1884 words searched (6/fr)
    INFO: ngram_search_fwdflat.c(957):      126 word transitions (0/fr)
    INFO: ngram_search_fwdflat.c(960): fwdflat 0.39 CPU 0.143 xRT
    INFO: ngram_search_fwdflat.c(963): fwdflat 0.41 wall 0.150 xRT
    ^CTraceback (most recent call last):
      File "workonit.py", line 44, in <module>
        decoder.process_raw(buf, False, False)
      File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 325, in process_raw
        return _pocketsphinx.Decoder_process_raw(self, *args)
    KeyboardInterrupt
    INFO: ngram_search_fwdtree.c(429): TOTAL fwdtree 24.01 CPU 1.193 xRT
    INFO: ngram_search_fwdtree.c(432): TOTAL fwdtree 81.60 wall 4.055 xRT
    INFO: ngram_search_fwdflat.c(176): TOTAL fwdflat 1.75 CPU 0.087 xRT
    INFO: ngram_search_fwdflat.c(179): TOTAL fwdflat 1.77 wall 0.088 xRT
    INFO: ngram_search.c(303): TOTAL bestpath 0.00 CPU 0.000 xRT
    INFO: ngram_search.c(306): TOTAL bestpath 0.00 wall 0.000 xRT
    

    I get to the point that i notice that this is actual the important code that do the job after initialisation.

    decoder.start_utt()
    while True:
        buf = stream.read(1024)
        if buf:
             decoder.process_raw(buf, False, False)
        else:
             break
        if decoder.hyp() != None:
            print ([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
            print ("Detected keyphrase, restarting search")
            decoder.end_utt()
            decoder.start_utt()
    

    I need some help to understand this...
    I comment the lienes with what i think they do

    //decoder  start that means it start pocketsphinx and wait for input
    decoder.start_utt()
    
    //as long the decodes is started
    while True:
        //read the streaming stuff in 1024 blocks
        buf = stream.read(1024)
        //if there is something to read do it
        if buf:
             decoder.process_raw(buf, False, False)
        //othewise dont read
        else:
             break
        //if the hypothesis (the word that pocketsphinx thinks to have reconised) is not empty
        if decoder.hyp() != None:
    
            //this si actually I dont get !!! I think he prints out all infos he has about the reconised word 
            print ([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
            //print this sentence
            print ("Detected keyphrase, restarting search")
            //restart pocketsphinx engine that is the part that hear you
            decoder.end_utt()
            decoder.start_utt()
    

    big thanks

     

    Last edit: justin case 2017-02-16
    • Nickolay V. Shmyrev

      config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0')

      It is better to use cmusphinx-fr-5.2

      config.set_string('-lm', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm')

      lm recognition is conflicting with keyphrase, you need to remove this line. It was not present in original kws example too.

       
  • justin case

    justin case - 2017-02-16

    such a fast answer. big thanks to you too!

    I commented out the line "config.set_string('-lm', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm')" and it just works ! that is so awesome :) I will update the code here later.
    (i searched for a donation link or upvote link for you but have nothing found.. so again big big thanks!)

     
  • justin case

    justin case - 2017-02-19

    so here it is.. big thanks for help this is actual working.. i cant change the topic heaer to solved :*(

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    #!/usr/bin/python
    
    import sys, os
    from pocketsphinx.pocketsphinx import *
    from sphinxbase.sphinxbase import *
    
    modeldir = "/usr/local/share/pocketsphinx/model"
    datadir = "/usr/local/share/pocketsphinx/test/data"
    
    config = Decoder.default_config()
    #config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/en-us/en-us')
    #config.set_string('-lm', '/usr/local/share/pocketsphinx/model/de-deu/engwordlist/9615.lm')
    #config.set_string('-dict', '/usr/local/share/pocketsphinx/model/de-deu/engwordlist/9615.dic')
    
    config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0')
    #config.set_string('-lm', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm')
    config.set_string('-dict', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrdic.dic')
    config.set_string('-keyphrase', 'salut')
    config.set_float('-kws_threshold', 1e+20)
    
    import pyaudio
    
    p = pyaudio.PyAudio()
    stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024)
    stream.start_stream()
    
    # Process audio chunk by chunk. On keyphrase detected perform action and restart search
    decoder = Decoder(config)
    decoder.start_utt()
    while True:
        buf = stream.read(1024)
        if buf:
             decoder.process_raw(buf, False, False)
        else:
             break
        if decoder.hyp() != None:
            print ([(seg.word, seg.prob, seg.start_frame, seg.end_frame) for seg in decoder.seg()])
            print ("Detected keyphrase, restarting search")
            decoder.end_utt()
            decoder.start_utt()
    

    outcame

    INFO: cmn_live.c(105): Update to   <  4.41 -0.00  0.46  0.30 -0.02  0.01 -0.12 -0.12 -0.13 -0.12 -0.11 -0.11 -0.19 >
    [('salut', -1032, 16158, 16227)]
    Detected keyphrase, restarting search
    INFO: cmn_live.c(120): Update from <  4.41 -0.00  0.46  0.30 -0.02  0.01 -0.12 -0.12 -0.13 -0.12 -0.11 -0.11 -0.19 >
    INFO: cmn_live.c(138): Update to   <  4.99 -0.07  0.41  0.39  0.00 -0.01 -0.13 -0.11 -0.13 -0.13 -0.15 -0.10 -0.19 >
    INFO: agc.c(172): AGCEMax: obs= 0.00, new= 0.00
    INFO: kws_search.c(656): kws 54.50 CPU 0.980 xRT
    INFO: kws_search.c(658): kws 96.34 wall 1.732 xRT
    INFO: cmn_live.c(88): Update from <  4.99 -0.07  0.41  0.39  0.00 -0.01 -0.13 -0.11 -0.13 -0.13 -0.15 -0.10 -0.19 >
    INFO: cmn_live.c(105): Update to   <  5.06 -0.11  0.35  0.36 -0.00 -0.01 -0.12 -0.10 -0.13 -0.13 -0.14 -0.09 -0.19 >
    INFO: cmn_live.c(88): Update from <  5.06 -0.11  0.35  0.36 -0.00 -0.01 -0.12 -0.10 -0.13 -0.13 -0.14 -0.09 -0.19 >
    

    now i am trying to extend this with the switch code from Nickolay V. Shmyrev from xchange
    btw near over 90% things about sphinx I ixquicked or duckduckgogoed are responed helpfull be him big thanks men!

    this is actual what I have

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    #!/usr/bin/python
    
    import sys, os
    from pocketsphinx.pocketsphinx import *
    from sphinxbase.sphinxbase import *
    import time
    
    modeldir = "/usr/local/share/pocketsphinx/model"
    datadir = "/usr/local/share/pocketsphinx/test/data"
    
    # Init decoder
    config = Decoder.default_config()
    config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0')
    config.set_string('-dict', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrdic.dic')
    config.set_string('-logfn', '/dev/null')
    decoder = Decoder(config)
    
    # Add searches
    decoder.set_kws('keyword', '/usr/local/share/pocketsphinx/model/fr-fra/keyword.list')
    decoder.set_lm_file('lm', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm')
    decoder.set_search('keyword')
    
    import pyaudio
    p = pyaudio.PyAudio()
    stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer=1024)
    stream.start_stream()
    
    in_speech_bf = False
    decoder.start_utt()
    
    while True:
        buf = stream.read(1024)
        if buf:
            decoder.process_raw(buf, False, False)
            if decoder.get_in_speech() != in_speech_bf:
                in_speech_bf = decoder.get_in_speech()
                if not in_speech_bf:
                    decoder.end_utt()
    
                    print 'first if'
                    print 'status decoder.get_search():' , decoder.get_search()
                    if decoder.get_search() == 'keyword':
                         print 'second if'
                         if decoder.hyp() != None:
                            print 'Result:', decoder.hyp().hypstr
                            i = decoder.hyp().hypstr
                            #haha = str(i)
                            if i == 'salut vite ':
                                 print '333 if '
                                 print i
                                 decoder.set_search('lm')
                                 print 'lm mode active'
                                 time.sleep(1) # delays for 1 seconds
                                 if decoder.hyp() != None:
                                    print 'last if schleife' , decoder.hyp().hypstr
                                    if decoder.hyp().hypstr == 'musique':
                                         print 'no soundplayer installed and what'
                                    elif decoder.hyp().hypstr == 'rapport':
                                         print 'nothing new'
                                    elif decoder.hyp().hypstr == 'changes musique':
                                         print 'how to change nothing'
                                    elif decoder.hyp().hypstr == 'tuez google':
                                         print 'ping -c 5 www.google.com'
                                 else:
                                    print 'DECODER EMPTY'
                    else:
                         decoder.set_search('keyword')
                         print 'keywordfuck'
    
                    decoder.start_utt()
        else:
            break
    decoder.end_utt()
    

    the outcame

    mentor@Bunk3r:~/pythonstt$ sudo python crossusepocktsphinx.py
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM dmix:0
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    first if
    status decoder.get_search(): keyword
    second if
    first if
    status decoder.get_search(): keyword
    second if
    first if
    status decoder.get_search(): keyword
    second if
    Result: salut vite
    333 if
    salut vite
    lm mode active
    DECODER EMPTY
    first if
    status decoder.get_search(): lm
    keywordfuck
    first if
    status decoder.get_search(): keyword
    second if
    Result: salut vite
    333 if
    salut vite
    lm mode active
    last if schleife
    first if
    status decoder.get_search(): lm
    keywordfuck
    first if
    status decoder.get_search(): keyword
    second if
    Result: salut vite
    333 if
    salut vite
    lm mode active
    last if schleife musique
    no soundplayer installed and what
    first if
    status decoder.get_search(): lm
    keywordfuck
    ^CTraceback (most recent call last):
      File "crossusepocktsphinx.py", line 35, in <module>
        decoder.process_raw(buf, False, False)
      File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 325, in process_raw
        return _pocketsphinx.Decoder_process_raw(self, *args)
    KeyboardInterrupt
    

    what i have done.. i started it say something wrong ... said trigger word "salut vite " then said "musique" this was in this cicle "lm mode active
    DECODER EMPTY
    first if
    status decoder.get_search(): lm
    keywordfuck"

    then i triggered "salut vite" again and he takes the musique from last call and triggers it

    so I have to say "salut vite" say "musique" and then again "salut vite" so that the musique is actual triggered.

    I really cant out find why he need a second "salut vite" I am so close for finishing .....

    best regards

     
  • justin case

    justin case - 2017-02-19

    Hi after hours I finally found my stupid fault....... it have to be in the else area so in the reloop it has the lm alrdy opened.

    the code works actually under raspbian jessie python 2.7.8

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    #!/usr/bin/python
    
    import sys, os
    from pocketsphinx.pocketsphinx import *
    from sphinxbase.sphinxbase import *
    import time
    
    modeldir = "/usr/local/share/pocketsphinx/model"
    datadir = "/usr/local/share/pocketsphinx/test/data"
    
    # Init decoder
    config = Decoder.default_config()
    config.set_string('-hmm', '/usr/local/share/pocketsphinx/model/fr-fra/lium_french_f0')
    config.set_string('-dict', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrdic.dic')
    config.set_string('-logfn', '/dev/null')
    decoder = Decoder(config)
    
    # Add searches
    decoder.set_kws('keyword', '/usr/local/share/pocketsphinx/model/fr-fra/keyword.list')
    decoder.set_lm_file('lm', '/usr/local/share/pocketsphinx/model/fr-fra/meinfrlm.lm')
    decoder.set_search('keyword')
    
    import pyaudio
    p = pyaudio.PyAudio()
    stream = p.open(format=pyaudio.paInt16, channels=1, rate=16000, input=True, frames_per_buffer$
    stream.start_stream()
    
    in_speech_bf = False
    decoder.start_utt()
    
    while True:
        buf = stream.read(1024)
        if buf:
            decoder.process_raw(buf, False, False)
            if decoder.get_in_speech() != in_speech_bf:
                in_speech_bf = decoder.get_in_speech()
                if not in_speech_bf:
                    decoder.end_utt()
                    print 'first if'
                    print 'status decoder.get_search():' , decoder.get_search()
                    if decoder.get_search() == 'keyword':
                        print 'second if'
                        if decoder.hyp() != None:
                            print 'Result:', decoder.hyp().hypstr
                            i = decoder.hyp().hypstr
                            if i == 'salut vite ':
                                print '333 if '
                                print i
                                decoder.set_search('lm')
                                print 'lm mode active'
                                time.sleep(1) # delays for 1 seconds
                                print i
                                # it is alrdy empty here print decoder.hyp().hypstr
                                print 'after sleep ops'
    
                    else:
                        print 'else'
    
                        print decoder.hyp().hypstr
                        if decoder.hyp().hypstr == 'musique':
                            print 'no soundplayer installed and what'
                        elif decoder.hyp().hypstr == 'rapport':
                            print 'nothing new'
                        elif decoder.hyp().hypstr == 'changes musique':
                            print 'how to change nothing'
                        elif decoder.hyp().hypstr == 'computer':
                            print '42'
                        elif decoder.hyp().hypstr == 'tuez google':
                            print 'contacting skynet'
                        decoder.set_search('keyword')
                        print 'keywordfuck'
    
                    decoder.start_utt()
        else:
            break
    decoder.end_utt()
    

    and here is the outcame

    mentor@Bunk3r:~/pythonstt$ sudo python OLDlastcrossusepocktsphinx.py
    ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM dmix:0
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    ALSA lib pcm_hw.c:1667:(_snd_pcm_hw_open) Invalid value for card
    Cannot connect to server socket err = No such file or directory
    Cannot connect to server request channel
    jack server is not running or cannot be started
    first if
    status decoder.get_search(): keyword
    second if
    first if
    status decoder.get_search(): keyword
    second if
    Result: salut vite
    333 if
    salut vite
    lm mode active
    salut vite
    after sleep ops
    first if
    status decoder.get_search(): lm
    else
    rapport
    nothing new
    keywordfuck
    first if
    status decoder.get_search(): keyword
    second if
    Result: salut vite
    333 if
    salut vite
    lm mode active
    salut vite
    after sleep ops
    first if
    status decoder.get_search(): lm
    else
    computer
    42
    keywordfuck
    first if
    status decoder.get_search(): keyword
    second if
    Result: salut vite
    333 if
    salut vite
    lm mode active
    salut vite
    after sleep ops
    first if
    status decoder.get_search(): lm
    else
    musique
    no soundplayer installed and what
    keywordfuck
    first if
    status decoder.get_search(): keyword
    second if
    first if
    status decoder.get_search(): keyword
    second if
    ^CTraceback (most recent call last):
      File "OLDlastcrossusepocktsphinx.py", line 35, in <module>
        decoder.process_raw(buf, False, False)
      File "/usr/local/lib/python2.7/dist-packages/pocketsphinx/pocketsphinx.py", line 325, in process_raw
        return _pocketsphinx.Decoder_process_raw(self, *args)
    KeyboardInterrupt
    mentor@Bunk3r:~/pythonstt$
    

    at first it is keywordmode i trigger lm mode with "salut vite" attention the space in if == 'salut vite ' is important ...why ever then in lm mode I can trigger actions with a word or more words. here i called
    "rapport" "computer" and "musique" after the ONE command it goes to keyword mode so I have to activate it again with "salut vite"

    Big thanks to all thats was a huge boost for me :) i hope i can help someone too with this ...

     

    Last edit: justin case 2017-02-19

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.