我使用以下语法:
#JSGF V1.0;
grammar tag;
public <tag> = <tagPart> +;
<tagPart> = <digit> | <letter>;
<digit> = oh | zero | one | two | three | four | five | six |seven | eight | nine ;
<letter> = a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z ;
除非我添加重量,否则一切正常。用重量跑:
<tagPart> = /0.8/ <digit> | /0.1/ <letter>;
我收到以下错误:
Exception in thread "main" java.lang.NullPointerException
at edu.cmu.sphinx.jsgf.JSGFGrammar.getNormalizedWeights(JSGFGrammar.java:49)
我使用语法的方式是:
Configuration configuration = new Configuration();
configuration.setAcousticModelPath("file:/E/sphinx4-5prealpha-src/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us/en-us");
configuration.setDictionaryPath("file:/E/sphinx4-5prealpha-src/sphinx4-data/src/main/resources/edu/cmu/sphinx/models/en-us/cmudict-en-us.dict");
configuration.setGrammarPath("file:/E/sT/src/main/resources/");
configuration.setGrammarName("tag");
configuration.setUseGrammar(true);
StreamSpeechRecognizer recognizer = new StreamSpeechRecognizer(configuration);
答案 0 :(得分:1)
我很抱歉延迟,此问题已在修订版13217的主干中修复,请更新并重试,它应该可以正常工作。