bambocher / pocketsphinx-python

Python interface to CMU Sphinxbase and Pocketsphinx libraries
https://pypi.python.org/pypi/pocketsphinx
Other
373 stars 187 forks source link

new_Decoder returned -1 #62

Closed iProMC closed 3 years ago

iProMC commented 3 years ago

Hello I have a problem with my project when i which is : new_Decoder returned -1 IDK why it keeps happening can anyone help me !!

grammar_file = "contact" # do not use any extension for this file model_path = "\env\Lib\site-packages\speech_recognition\pocketsphinx-data\en-US" language = "en-US"

grammar_path = os.path.join(model_path, language, rootdir3 + "\contact.gram") fsg_path = "{}.fsg".format(grammar_path)

print("Grammar Filepath: {}".format(grammar_path)) print("FSG Grammar Filepath: {}".format(fsg_path))

Create decoder object

config = pocketsphinx.Decoder.default_config() config.set_string("-hmm", os.path.join(model_path, language, 'acoustic-model')) config.set_string("-lm", os.path.join(model_path, language, 'language-model.lm.bin')) config.set_string("-dict", os.path.join(model_path, language, 'pronounciation-dictionary.dict')) config.set_string("-logfn", os.devnull) decoder = pocketsphinx.Decoder(config)

Compile Grammar File

jsgf = Jsgf(grammar_path) rule_string = "{0}.{0}".format(grammar_file) rule = jsgf.get_rule(rule_string) fsg = jsgf.build_fsg(rule, decoder.get_logmath(), 7.5) fsg.writefile(fsg_path)

Set grammar to decoder

decoder.set_fsg(grammar_file, fsg) decoder.set_search(grammar_file)

iProMC commented 3 years ago

the error on this (( decoder = pocketsphinx.Decoder(config) ))