Menu

Error: Must specify -mdef or -hmm

Help
mindthief
2010-03-07
2012-09-22
  • mindthief

    mindthief - 2010-03-07

    Hi,
    I am trying to get the Hello World example to work in XCode. I get the
    following error when I run the code:
    ERROR: "acmod.c", line 82: Must specify -mdef or -hmm

    I looked into the cause, and it looks like when
    ps = ps_init(config);

    ..is called, ps gets the value of NULL.

    Stepping into the code, it looks like this is happening in the acoustic model
    initialization. In the function cmd_ln_str_r(cmd_ln_t cmdln, char const
    name), it looks like it does some hashtable lookup which succeeds, but in the
    statement

    return (char const *)val->ptr;

    val->ptr has a value of NULL.

    Any idea how to solve this?
    Thanks,

     
  • Nickolay V. Shmyrev

    2010-03-07 16:32:35 MSK
    You probably don't init config properly with code like

    config = cmd_ln_init(NULL, ps_args(), TRUE, "-hmm", MODELDIR "/hmm/wsj1", "-lm", MODELDIR "/lm/wsj/wlist5o.3e-7.vp.tg.lm.DMP", "-dict", MODELDIR "/lm/cmudict.0.6d", NULL)); 
    ps = ps_init(config);
    
     
  • mindthief

    mindthief - 2010-03-08

    Hi,
    I do the initialization with this code (very similar to hello world example):
    config = cmd_ln_init(NULL, ps_args(), TRUE,
    "-hmm", resPath,
    "-lm", langModelPath,
    "-dict", dictPath,
    NULL);

    In the iPhone simulator, all "resource" files are put in 'resourcePath'. This
    flattens the directory structure and all language model, ac model, and dict
    files are in the same folder on disk. resPath, langModelPath and dictPath
    point to the acoustic model folder (which is just the resourcePath), the
    language model file "turtle.lm.xcode" (had to change extension because xcode
    was complaining about the .lm extension), and the dict file "turtle.dict".
    Again, all of these files are located in the same folder at resourcePath.

    I tested the location by writing a file to resourcePath and it did show up at
    the intended location on disk. So it seems that the location is the correct
    one. The iphone pocketsphinx library that I'm using was from anchan77 in this
    post
    .

    Does the initialization look okay? I think it should be the same as the C
    example.
    Thanks

     
  • Nickolay V. Shmyrev

    Hm, it indeed could check mdef file presence and if it's missing it can fail.
    Unfortunately the only way to check this is to debug ps_add_file function
    call. You have to do this yourself.

     
  • mindthief

    mindthief - 2010-03-09

    Hi, I managed to fix it -- it was something silly. in all the confusion of the
    resource paths being flattened into one directory, I didn't realize that one
    of the arguments i was passing to cm_ln_init() was an NSString and not a
    cstring.
    Thanks for your help!

     
  • Saurabh Wadhwa

    Saurabh Wadhwa - 2010-03-14

    Hi Mindthief, Im facing a similar problem.
    In my case im running the app in simulator and passing it the goforward raw
    file. But it just crashes.
    Can you post the project or maybe give detail steps of how you used the code
    posted by anchan77

     
  • mindthief

    mindthief - 2010-03-14

    Hi saurwad,
    A friend did some of the setup so I'm not really sure what all the steps
    involved were, but if you let me know what specific problem you're having, I
    may be able to help you. I would guess that you should just include the static
    library file generated by the project from anchan77 and include it in yours
    and modify the "Header search paths" field in Project properties to point to
    $ANCHAN77_ROOT/includes. Does this make sense? I haven't tried this and I'm
    new to Xcode, but it should work.

    Also, you should take a look at the PocketSphinx "hello world" example here:
    http://cmusphinx.sourceforge.net/wiki/PocketSphinxMigration

    You need to include the models from the hello world example in your
    "Resources" folder in Xcode. My post #3 in this thread has some info on this.

     
  • Saurabh Wadhwa

    Saurabh Wadhwa - 2010-03-14

    I am getting the same error as you did.

    ERROR: "acmod.c", line 82: Must specify -mdef or -hmm

    These are the steps which I followed.
    1. Dowloaded all the three projects posted by anchan77
    2.created a new iphone project
    3.Copied libraries libiphonepocketsphinx.a and libiphonesphinxbase.a
    (simulator ones) to the new project .
    4.put the header search paths
    5. app delegate i imported pocketshinx.h and built. Everything ran fine.
    6. i downloaded pocketsphinx-0.5.1 and copied the model folder fthis to iphone project
    7. Added this model folder as a resource to iphone project.Also copied goforward.raw to my project.
    8.The lm files were giving Lex errors so renamed them to.lm.xcode as suggested
    by you.

    ps_decoder_t *ps;
        cmd_ln_t *config;
        int rv;
        int32 score;
        char const *hyp, *uttid;
    
        NSString * executablePath =  [[NSBundle mainBundle] executablePath];
        NSLog(@"executablePath: %@",executablePath);
        NSString * hmmPath = [NSString stringWithFormat:@"%@/model/wsj1",executablePath];
        NSString * lmPath = [NSString stringWithFormat:@"%@/model/lm/turtle/turtle.lm.DMP",executablePath];
        NSString * dictPath = [NSString stringWithFormat:@"%@/model/lm/turtle/turtle.dic",executablePath];
        hmmPath = [hmmPath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
        lmPath = [lmPath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
        dictPath = [dictPath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
    
        NSLog(@"executablePath: %@",hmmPath);
        NSLog(@"executablePath: %@",lmPath);
        NSLog(@"executablePath: %@",dictPath);
    
        config = cmd_ln_init(NULL, ps_args(), TRUE,
         "-hmm",
        [hmmPath cStringUsingEncoding:NSUTF16StringEncoding],
         "-lm", 
         [lmPath cStringUsingEncoding:NSUTF16StringEncoding],
         "-dict",
         [dictPath cStringUsingEncoding:NSUTF16StringEncoding],
         NULL);
    
        ps = ps_init(config);
    
        FILE *fh;
    
        NSString *path = [[NSBundle mainBundle] pathForResource:@"goforward" ofType:@"raw"];
        NSLog(@"%@",path);
    
        fh = fopen([path cStringUsingEncoding:NSUTF16StringEncoding], "rb");
        rv = ps_decode_raw(ps, fh,"goforward", -1);
        hyp = ps_get_hyp(ps, &score, &uttid);
        printf("Recognized: %s\n", hyp);
    

    It crashes with amod.c error... What am i doing wrong. Can you tell the paths
    you are using for initialization???

     
  • mindthief

    mindthief - 2010-03-15

    I notice you're using "executePath" -- not sure if that's different but I'm
    using resourcePath.

            config = cmd_ln_init(NULL, ps_args(), TRUE,
                                           "-hmm", [[[NSBundle mainBundle] resourcePath] UTF8String],
                                           "-lm", langModelPath,
                                           "-dict", dictPath,
                                           NULL);
    

    The paths to the models are:

            NSString *langModelPathNS = [[NSBundle mainBundle] pathForResource:@"turtle.lm" ofType:@"xcode"];
            NSString *dictPathNS = [[NSBundle mainBundle] pathForResource:@"turtle" ofType:@"dic"];
            NSString *testFilePathNS = [[NSBundle mainBundle] pathForResource:@"goforward" ofType:@"16k"];
    
            const char* langModelPath = [langModelPathNS cStringUsingEncoding:NSASCIIStringEncoding];
            const char* dictPath = [dictPathNS cStringUsingEncoding:NSASCIIStringEncoding];
            const char* testFilePath = [testFilePathNS cStringUsingEncoding:NSASCIIStringEncoding];
    

    (But I think you can even get the paths to the model files by just appending
    "turtle.lm.xcode" to the resourcePath, and same for the dictionary)

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.