Menu

Problem getting cmd_ln_init working properly

Help
AD
2016-05-31
2016-06-04
  • AD

    AD - 2016-05-31

    I try and run this line:
    cmd_ln_init(NULL, ps_args(), TRUE, "-inmic yes", "-hmm", MODELDIR "/en-us/en-us", "-lm", MODELDIR "/en-us/en-us.lm.bin", "-dict", MODELDIR "/en-us/cmudict-en-us.dict", NULL);

    But i keep getting an error that says I need even arguments?

    what do i need to add to the continious file stream github code to get it to recognize my mic. Im just trying to get a bare bones live mic to text recognition going so I could then tweak and understand it as go. But im having the hardest time getting it up and working.

     

    Last edit: AD 2016-06-01
    • Nickolay V. Shmyrev

      You need to remove "-inmic yes" argument.

       
  • AD

    AD - 2016-06-02

    Ok well where do i place the -inmic part. im tryint to run the continious speech option when im presented this screen
    http://s33.postimg.org/hsngj5v5b/image.png

    heres my main function code that I got from github:

    int
    main(int argc, char *argv[])
    {
        char const *cfg;
    
        config = cmd_ln_parse_r(NULL, cont_args_def, argc, argv, TRUE);
    
        /* Handle argument file as -argfile. */
        if (config && (cfg = cmd_ln_str_r(config, "-argfile")) != NULL) {
            config = cmd_ln_parse_file_r(config, cont_args_def, cfg, FALSE);
        }
    
        if (config == NULL || (cmd_ln_str_r(config, "-infile") == NULL && cmd_ln_boolean_r(config, "-inmic") == FALSE)) {
        E_INFO("Specify '-infile <file.wav>' to recognize from file or '-inmic yes' to recognize from microphone.\n");
            cmd_ln_free_r(config);
        return 1;
        }
    
        ps_default_search_args(config);
        ps = ps_init(config);
        if (ps == NULL) {
            cmd_ln_free_r(config);
            return 1;
        }
    
        E_INFO("%s COMPILED ON: %s, AT: %s\n\n", argv[0], __DATE__, __TIME__);
    
        if (cmd_ln_str_r(config, "-infile") != NULL) {
            recognize_from_file();
        } else if (cmd_ln_boolean_r(config, "-inmic")) {
            recognize_from_microphone();
        }
    
        ps_free(ps);
        cmd_ln_free_r(config);
    
        return 0;
    }
    

    what do I have to add and where, to get it to run the continious speech option

     

    Last edit: Nickolay V. Shmyrev 2016-06-02
    • Nickolay V. Shmyrev

      If you want to recognize from microphone exclusively you can remove all inmic-related checks from your code and leave only recognize_from_microphone.

       
      • AD

        AD - 2016-06-02

        When I do that I get this error:
        http://s33.postimg.org/w1t4d1i5r/image.png

         
        • Nickolay V. Shmyrev

          You need to be more precise on what have you done exactly. You also need to try to understand the program you create instead of blindly cutting and pasting code.

           
  • AD

    AD - 2016-06-02

    Tutorial series only covers reading from a voice file. Im trying to read live mic. ill paste my code.
    http://s33.postimg.org/oy4qcu5i7/image.png

     
    • Nickolay V. Shmyrev

      It is better to provide a source file instead of a picture. You can attach it to your message.

       
      • AD

        AD - 2016-06-04

        Heres the source code. Im trying to get it to just run the mic function. But it breaks when I run it.

         
        • Nickolay V. Shmyrev

          In this piece of your code:

            if (config == NULL || (cmd_ln_str_r(config, "-infile") == NULL && cmd_ln_boolean_r(config, "-inmic") == FALSE)) {
              E_INFO("Specify '-infile <file.wav>' to recognize from file or '-inmic yes' to recognize from microphone.\n");
                  cmd_ln_free_r(config);
          
              }
          

          You check for non-important inmic option, then you free configuration thus corrupting memory and then you continue execution with the corrupted memory. I suspect it is not the behaviour you meant to implement.

           

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.