1

Ubuntu 14 に PocketSphinx をインストールし、簡単なサンプルを作成しようとしています。公式ウェブサイトSphinxからコードを取得しました。

#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;
config = cmd_ln_init(NULL, ps_args(), TRUE,
             "-hmm", MODELDIR "/en-us/en-us",
             "-lm", MODELDIR "/en-us/en-us.lm.dmp",
             "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
             NULL);

if (config == NULL)
    return 1;
ps = ps_init(config);
if (ps == NULL)
    return 1;

fh = fopen("goforward.raw", "rb");
if (fh == NULL)
    return -1;
    rv = ps_start_utt(ps);
if (rv < 0)
    return 1;
    while (!feof(fh)) {
        size_t nsamp;
        nsamp = fread(buf, 2, 512, fh);
        rv = ps_process_raw(ps, buf, nsamp, FALSE, FALSE);
    }
    rv = ps_end_utt(ps);
if (rv < 0)
    return 1;
hyp = ps_get_hyp(ps, &score);
if (hyp == NULL)
    return 1;
printf("Recognized: %s\n", hyp);

fclose(fh);
    ps_free(ps);
    cmd_ln_free_r(config);
return 0;
}

そしてQmakeは

    QT       += core
QT       -= gui

TARGET = OpenCVQt
CONFIG   += console
CONFIG   -= app_bundle

TEMPLATE = app

DEPENDPATH += /usr/local/lib

INCLUDEPATH += /usr/local/include
INCLUDEPATH += /usr/local/include/pocketsphinx
INCLUDEPATH += /usr/local/include/sphinxbase

LIBS += -lopencv_core
LIBS += -lopencv_imgproc
LIBS += -lopencv_highgui
LIBS +=-lpocketsphinx
LIBS += -lsphinxbase
LIBS += -lsphinxad

SOURCES += main.cpp

何が悪いのか理解できません。/usr/local/include/sphinxbase に sphinx_config.h がありました。ありがとう。

  18:54:06: Starting: "/usr/bin/make" 
/home/warezovvv/Qt/5.4/gcc_64/bin/qmake -spec linux-g++ CONFIG+=debug -o Makefile ../OpenCVQt/OpenCVQt.pro
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_CORE_LIB -I../OpenCVQt -I. -I/usr/local/include -I/usr/local/include/pocketsphinx -I/usr/local/include/sphinxbase -I../../../Qt/5.4/gcc_64/include -I../../../Qt/5.4/gcc_64/include/QtCore -I. -I../../../Qt/5.4/gcc_64/mkspecs/linux-g++ -o main.o ../OpenCVQt/main.cpp
In file included from /usr/include/sphinxbase/cmd_ln.h:66:0,
                 from /usr/local/include/pocketsphinx/pocketsphinx.h:52,
                 from ../OpenCVQt/main.cpp:1:
/usr/include/sphinxbase/prim_type.h:88:27: fatal error: sphinx_config.h: No such file or directory
 #include <sphinx_config.h>
                           ^
compilation terminated.
make: *** [main.o] Error 1
18:54:06: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project OpenCVQt (kit: Desktop Qt 5.4.1 GCC 64bit)
When executing step "Make"
18:54:06: Elapsed time: 00:01.

ヘッダーにエラーはありません。今新しいエラー - >

22:42:41: Running steps for project OpenCVQt...
22:42:41: Configuration unchanged, skipping qmake step.
22:42:41: Starting: "/usr/bin/make" 
/home/warezovvv/Qt/5.4/gcc_64/bin/qmake -spec linux-g++ CONFIG+=debug -o Makefile ../OpenCVQt/OpenCVQt.pro
g++ -c -pipe -g -Wall -W -D_REENTRANT -fPIE -DQT_CORE_LIB -I../OpenCVQt -I. -I/usr/local/include -I/usr/local/include/pocketsphinx -I/usr/local/include/sphinxbase -I/usr/include/sphinxbase -I../../../Qt/5.4/gcc_64/include -I../../../Qt/5.4/gcc_64/include/QtCore -I. -I../../../Qt/5.4/gcc_64/mkspecs/linux-g++ -o main.o ../OpenCVQt/main.cpp
../OpenCVQt/main.cpp: In function 'int main(int, char**)':
../OpenCVQt/main.cpp:14:22: error: 'MODELDIR' was not declared in this scope
              "-hmm", MODELDIR "/en-us/en-us",
                      ^
../OpenCVQt/main.cpp:15:30: error: expected ')' before string constant
              "-lm", MODELDIR "/en-us/en-us.lm.dmp",
                              ^
../OpenCVQt/main.cpp:16:32: error: expected ')' before string constant
              "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
                                ^
../OpenCVQt/main.cpp:9:23: warning: unused variable 'uttid' [-Wunused-variable]
     char const *hyp, *uttid;
                       ^
../OpenCVQt/main.cpp: At global scope:
../OpenCVQt/main.cpp:4:1: warning: unused parameter 'argc' [-Wunused-parameter]
 main(int argc, char *argv[])
 ^
../OpenCVQt/main.cpp:4:1: warning: unused parameter 'argv' [-Wunused-parameter]
make: *** [main.o] Error 1
22:42:42: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project OpenCVQt (kit: Desktop Qt 5.4.1 GCC 64bit)
When executing step "Make"
22:42:42: Elapsed time: 00:01.
4

2 に答える 2