Menu

Pocketsphinx with keyphrase on python

Help
2017-06-16
2019-11-14
  • Paulo Ferreira

    Paulo Ferreira - 2017-06-16

    Hello,
    I am building a simple program to recognize a few words and i need to reject the out of grammar words so i am using a file with keyphrase and a threshold in order to do this.
    Here is my code:

    import os
    from pocketsphinx import LiveSpeech, get_model_path
    
    model_path = get_model_path()
    
    speech = LiveSpeech(
        verbose=False,
        sampling_rate=16000,
        buffer_size=2048,
        no_search=False,
        full_utt=False,
        #lm=False,
        hmm= os.path.join(model_path,'en-us'),
        #lm= '/home/paulo/PycharmProjects/VoiceRecognition/Data/TAR4858/4858.lm',
        dic = '/home/paulo/PycharmProjects/VoiceRecognition/Data/TAR4858/4858.dic',
        kws = '/home/paulo/PycharmProjects/VoiceRecognition/Data/TAR4858/keyphrase.list'
    )
    
    for phrase in speech:
        print phrase.probability()
        frase = str(phrase)
        print frase
    

    Dictionary made with LMTool:

    BROWSER B R AW Z ER
    COMPUTER    K AH M P Y UW T ER
    HELLO   HH AH L OW
    HELLO(2)    HH EH L OW
    MUSIC   M Y UW Z IH K
    OFF AO F
    ON  AA N
    ON(2)   AO N
    OPEN    OW P AH N
    TURN    T ER N
    

    Keyphrase.list:

    OPEN BROWSER /1e+20/
    TURN ON MUSIC /1e+20/
    TURN OFF MUSIC /1e+20/
    TURN OFF COMPUTER /1e+20/
    HELLO COMPUTER /1e+20/
    

    But this is not recognizing any word at all, why this is happening?

     

    Last edit: Paulo Ferreira 2017-06-16
    • Nickolay V. Shmyrev

      Maybe your microphone is muted. You can add verbose=True to constructor and check the log values.

       
  • christian schuch

    Maybe you should lower the Threshold, this did the Trick for me. I'm using /1e+10/ now and it works flawlessly

     

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.