我的名字是masoud
。
现在我想当我说masoud
时,我的应用程序会打印一个控制台日志。
要做到这一点,我制作了一个mdic.txt
文件,并将我的名字放在其中:
masoud MA S O D
我将mdic.txt
更改为mdic.dict
并将其放在assets/sync
目标处。
我制作了一个cm.txt
文件,我在其中放了一个字符串:
#JSGF V1.0;
/**
* JSGF Grammar for Hello World example
*/
grammar masoud;
public <greet> = (good morning | masoud) ( bhiksha | evandro | paul | philip | rita | will );
我将cm.txt
更改为cm.gram
。
在我的MainActivity中
private void setupRecognizer(File assetsDir) throws IOException {
// The recognizer can be configured to perform multiple searches
// of different kind and switch between them
recognizer = SpeechRecognizerSetup.defaultSetup()
.setAcousticModel(new File(assetsDir, "en-us-ptm"))
//.setDictionary(new File(assetsDir, "cmudict-en-us.dict"))
.setDictionary(new File(assetsDir, "mdic.dict"))
//.setRawLogDir(assetsDir) // To disable logging of raw audio comment out this call (takes a lot of space on the device)
.setKeywordThreshold(1e-45f) // Threshold to tune for keyphrase to balance between false alarms and misses
.setBoolean("-allphone_ci", true) // Use context-independent phonetic search, context-dependent is too slow for mobile
.getRecognizer();
recognizer.addListener(this);
/** In your application you might not need to add all those searches.
* They are added here for demonstration. You can leave just one.
*/
// Create keyword-activation search.
//recognizer.addKeyphraseSearch(KWS_SEARCH, KEYPHRASE);
recognizer.addKeywordSearch(KWS_SEARCH, new File(assetsDir, "mdic.dict"));
现在我收到了这条消息:
&#34; dict.c&#34;,第195行:第1行:电话&#39; MA&#39;在声学中徘徊 模型;字#masoud&#39;忽略&#34; kws_search.c&#34;,第171行:这个词 &#39;马苏德&#39;字典中缺少
我在recognizer.addKeywordSearch(KWS_SEARCH, new File(assetsDir, "mdic.dict"));
行收到此错误。
答案 0 :(得分:1)
masoud的正确转录是“M AH S UW D”。
声学模型中没有手机MA。错误说明了这一点。