Closed iProMC closed 4 years ago
Hello, when I start the project I have an error with this code decoder.set_fsg(grammar_name, fsg)
grammar_file = "contact" # do not use any extension for this file
config = pocketsphinx.Decoder.default_config() config.set_string("-hmm", os.path.join(rootdir2, 'acoustic-model')) config.set_string("-lm", os.path.join(rootdir2, 'language-model.lm.bin')) config.set_string("-dict", os.path.join(rootdir2, 'pronounciation-dictionary.dict')) config.set_string("-logfn", os.devnull) decoder = pocketsphinx.Decoder(config)
grammar_path = os.path.abspath(os.path.dirname(grammar_file)) grammar_name = os.path.splitext(os.path.basename(grammar_file))[0] fsg_path = "{0}/{1}.fsg".format(grammar_path, grammar_name) if not os.path.exists(fsg_path): # create FSG grammar if not available jsgf = ps.Jsgf(grammar_file) rule = jsgf.get_rule("{0}.{0}".format(grammar_name)) fsg = jsgf.build_fsg(rule, decoder.get_logmath(), 7.5) fsg.writefile(fsg_path) print('Successful JSFG to FSG conversion!!!')
decoder.set_fsg(grammar_name, fsg) # <--- BUG IS HERE!!!
Hello, when I start the project I have an error with this code decoder.set_fsg(grammar_name, fsg)
grammar_file = "contact" # do not use any extension for this file
Create decoder object
config = pocketsphinx.Decoder.default_config() config.set_string("-hmm", os.path.join(rootdir2, 'acoustic-model')) config.set_string("-lm", os.path.join(rootdir2, 'language-model.lm.bin')) config.set_string("-dict", os.path.join(rootdir2, 'pronounciation-dictionary.dict')) config.set_string("-logfn", os.devnull) decoder = pocketsphinx.Decoder(config)
Convert grammar
grammar_path = os.path.abspath(os.path.dirname(grammar_file)) grammar_name = os.path.splitext(os.path.basename(grammar_file))[0] fsg_path = "{0}/{1}.fsg".format(grammar_path, grammar_name) if not os.path.exists(fsg_path): # create FSG grammar if not available jsgf = ps.Jsgf(grammar_file) rule = jsgf.get_rule("{0}.{0}".format(grammar_name)) fsg = jsgf.build_fsg(rule, decoder.get_logmath(), 7.5) fsg.writefile(fsg_path) print('Successful JSFG to FSG conversion!!!')
Pass the fsg file into the decoder
decoder.set_fsg(grammar_name, fsg) # <--- BUG IS HERE!!!