1

我的名字是masoud。现在我想当我说masoud,我的应用程序打印一个控制台日志。

为此,我制作了一个mdic.txt文件,并将我的名字放入其中:

马苏德 MA SOD

我改为mdic.txt并将mdic.dict其放在assets/syncdirecotry 中。

我制作了一个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"));

现在我收到了这条消息:

“dict.c”,第 195 行:第 1 行:声学模型中缺少电话“MA”;单词“masoud”忽略了“kws_search.c”,第 171 行:字典中缺少单词“masoud”

我在recognizer.addKeywordSearch(KWS_SEARCH, new File(assetsDir, "mdic.dict"));line 收到此错误。

4

1 回答 1

1

masoud 的正确转写是“M AH S UW D”。

声学模型中没有电话 MA。错误说明了这一点。

于 2016-09-16T06:42:21.783 回答