Menu

Hello World fail Windows SO

Help
2021-04-25
2021-04-28
  • Diego Rapal

    Diego Rapal - 2021-04-25

    My code (basically the tutorial hello world code)

    #include <stdio.h>
    #include <stdlib.h>
    
    #include <string.h>
    #include <assert.h>
    
    #include <sphinxbase/err.h>
    #include <sphinxbase/ad.h>
    
    #include <pocketsphinx.h>
    
    int
    main(int argc, char *argv[])
    {
        ps_decoder_t *ps;
        cmd_ln_t *config;
        FILE *fh;
        char const *hyp, *uttid;
        int16 buf[512];
        int rv;
        int32 score;
    
        printf("Test VoiceRecon Start\n");
    
        config = cmd_ln_init(NULL, ps_args(), TRUE,
                    "-hmm", "F:/ProyectoXP/VoiceRecon/model/",
                    "-lm", "F:/ProyectoXP/VoiceRecon/model/1851.lm",
                    "-dict", "F:/ProyectoXP/VoiceRecon/model/1851.dic",
                    NULL);
    
        printf("Config Set Done\n");
    
        if (config == NULL) {
        printf("Config Fail\n");
        fprintf(stderr, "Failed to create config object, see log for details\n");
        return -1;
        }
    
        ps = ps_init(config);
        if (ps == NULL) {
        printf("Decoder Fail\n");
        fprintf(stderr, "Failed to create recognizer, see log for details\n");
        return -1;
        }
    
        fh = fopen("goforward.raw", "rb");
        if (fh == NULL) {
        printf("File Fail\n");
        fprintf(stderr, "Unable to open input file goforward.raw\n");
        return -1;
        }
    
        rv = ps_start_utt(ps);
    
        while (!feof(fh)) {
        size_t nsamp;
        nsamp = fread(buf, 2, 512, fh);
        rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
        }
    
        printf("File Processed\n");
        rv = ps_end_utt(ps);
        hyp = ps_get_hyp(ps, &score);
        printf("Recognized: %s\n", hyp);
    
        fclose(fh);
        ps_free(ps);
        cmd_ln_free_r(config);
    
        printf("End Test\n");
    
        return 0;
    }
    

    Libs, Includes, etc done, perfect compile with no errors (on Windows 10 and DEV-C++ 5.11), getting VoiceRecon.exe

    Run in a windows CMD, Output:

    F:\ProyectoXP\VoiceRecon>VoiceRecon.exe
    Test VoiceRecon Start
    
    F:\ProyectoXP\VoiceRecon>
    

    No errors returns, no nothing, but looks like never get to the "printf("Config Set Done\n");" line.

    What is wrong with config call? HELP!!

    Dego

     

    Last edit: Diego Rapal 2021-04-25
    • Nickolay V. Shmyrev

      Can you format the code properly? You can use markdown syntax or just the vyswyg editor.

       
  • Diego Rapal

    Diego Rapal - 2021-04-25

    upload the CPP file.

     
    • Nickolay V. Shmyrev

      Please click edit button in your original post and format the code properly.

       
      • Diego Rapal

        Diego Rapal - 2021-04-25

        Sorry, just Idk how, I read Formating Help section and I think is fine now, is ok?
        Sorry my english, no a native english speaker. :-(

         
        • Nickolay V. Shmyrev

          Looks good now, thank you!

          Attention to details will help you in your programming career.

          As for exit after start, it exits because it fails to find the dlls (sphinxbase and pocketsphinx). They must be in the same folder where you run the program. You can use dll explorer to make sure dlls are present.

           
          • Diego Rapal

            Diego Rapal - 2021-04-25

            Thanks for your help Nikolay, about DLLs they are in the same folder.
            Extra info, running "pocketsphinx_continuous,exe" in same folder with same hmm, lm, dict parameters (in command line) works perfect!

             
            • Nickolay V. Shmyrev

              Then you need to check compilation params. It is something about dll, not about your code. It crashes when it plugs first sphixnbase functions.

               
              • Diego Rapal

                Diego Rapal - 2021-04-25

                You mean when compiling my code or something in the compilation of the dlls?,
                I have not recompiled the dlls but they work perfectly with the continuous.exe

                 
  • Diego Rapal

    Diego Rapal - 2021-04-25

    This is my makefile:

    # Project: VoiceRecon
    # Makefile created by Dev-C++ 5.11
    
    CPP      = g++.exe
    CC       = gcc.exe
    WINDRES  = windres.exe
    OBJ      = voicerecon.o
    LINKOBJ  = voicerecon.o
    LIBS     = -L"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/lib" -L"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib" -static-libgcc -L"F:/ProyectoXP/Development/pocketsphinx/bin/Release/x64" -L"F:/ProyectoXP/Development/sphinxbase/bin/Release/x64" ../Development/pocketsphinx/bin/Release/x64/pocketsphinx.lib ../Development/pocketsphinx/bin/Release/x64/sphinxbase.lib ../Development/pocketsphinx/bin/Release/x64/pocketsphinx.dll ../Development/pocketsphinx/bin/Release/x64/sphinxbase.dll
    INCS     = -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/include" -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"F:/ProyectoXP/Development/pocketsphinx/include" -I"F:/ProyectoXP/Development/sphinxbase/include" -I"F:/ProyectoXP/Development/sphinxbase/include/win32"
    CXXINCS  = -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/include" -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/x86_64-w64-mingw32/include" -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include" -I"F:/ProyectoXP/Development/Dev-Cpp/MinGW64/lib/gcc/x86_64-w64-mingw32/4.9.2/include/c++" -I"F:/ProyectoXP/Development/pocketsphinx/include" -I"F:/ProyectoXP/Development/sphinxbase/include" -I"F:/ProyectoXP/Development/sphinxbase/include/win32"
    BIN      = VoiceRecon.exe
    CXXFLAGS = $(CXXINCS) -std=c++11
    CFLAGS   = $(INCS) -std=c++11
    RM       = rm.exe -f
    
    .PHONY: all all-before all-after clean clean-custom
    
    all: all-before $(BIN) all-after
    
    clean: clean-custom
    ${RM} $(OBJ) $(BIN)
    
    $(BIN): $(OBJ)
    $(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)
    
    voicerecon.o: voicerecon.cpp
    $(CPP) -c voicerecon.cpp -o voicerecon.o $(CXXFLAGS)
    
     
    • Nickolay V. Shmyrev

      Did you compile pocketsphinx_batch.exe and pocketsphinx.dll with mingw or with a visual studio?

       
      • Diego Rapal

        Diego Rapal - 2021-04-25

        No i dont, is that a MUST?

         
        • Nickolay V. Shmyrev

          I asked mingw OR with a visual studio

           
  • Diego Rapal

    Diego Rapal - 2021-04-25

    I do not recompile any dll or exe from the sphinx package.

     
    • Nickolay V. Shmyrev

      Ok, you can try to remove -static-libgcc from the flags, it might help. Otherwise you'd better recompile pocketsphinx/sphinxbase with mingw too. Or you use MSVC to compile your binary since libraries were built with msvc.

      In general the rule is that you use single compiler for all the libs and binaries in the project. On Windows they are not easily cross-compatible due to different runtimes.

       
  • Diego Rapal

    Diego Rapal - 2021-04-25

    I will try what you indicate, I see clearly that the problem is compilation, I have compiled the continuous.c and I have the same symptom, although using the one included in the package works fine, it is clear that the dll and the exe must be compiled in the same environment
    thank you very much for your help!

     
  • Diego Rapal

    Diego Rapal - 2021-04-28

    To close and if help others, the problem was to include the .lib files in the compilation, only including the .dll files the compilation worked correctly.

     
  • Diego Rapal

    Diego Rapal - 2021-04-28

    To close and if help others, the problem was to include the .lib files in the compilation, only including the .dll files the compilation worked correctly.

     

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.