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"
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)