Menu

pocket-sphinx-python TypeError: in method 'Decoder_set_lm', argument 3 of type 'NGramModel *'

Help
2018-01-05
2018-01-07
  • David Weßling

    David Weßling - 2018-01-05

    Hello,
    I am Trying to write a small python application using pocket-sphinx, but i'll keep encountering this TypeError, no matter how i pass the path to my languagemodel (i tried an absolute path in string-format and os.path)

    this is the relevant code:

    self.config = Decoder.default_config()
            self.config.set_string("-hmm",os.path.join(MODEL_DIR,"acousticModel"))
            self.config.set_string("-dict",os.path.join(MODEL_DIR,"mergedDic.dic"))
            self.config.set_string("-lm",os.path.join(MODEL_DIR,"voxforge.lm.bin"))
            self.languageModel=os.path.join(MODEL_DIR,"voxforge.lm.bin")
            self.keywordList=os.path.join(MODEL_DIR,"commands.keywords")
            self.numberGrammar=os.path.join(MODEL_DIR,"zahlen.jsgf")
            self.p=pyaudio.PyAudio()
            self.stream = None
            self.decoder=Decoder(self.config)
            self.decoder.set_lm(CONTINOUS_SEARCH,self.languageModel) 
            self.decoder.set_kws(COMMAND_SEARCH,self.keywordsList)
            self.decoder.set_jsgf(ZAHLEN_SEARCH,self.numberGrammar)
            self.result=""
            self.listening=False
            self.buf=None
    

    what confuses me is: the error occours in the .set_lm function but not in the config.set_string part.
    E: i used the same Model with pocketsphinx for android and in a java-program both worked as expected.

    thanks for every answere

     

    Last edit: David Weßling 2018-01-05
    • Nickolay V. Shmyrev

      set_lm expects an lm object as an argument, you can use set_lm_file instead.

       

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.