2015-03-29 1 views
1

J'ai installé PocketSphinx sur Ubuntu 14 et essaye maintenant de créer un échantillon simple. J'ai pris le code du site officiel Sphinx.Sphinx Ubuntu 14 C++ sphinx_config.h pas trouvé

#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; 
} 

Et Qmake est

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 

Ne peut pas comprendre ce qui est faux. J'ai vu sphinx_config.h dans/usr/local/include/sphinxbase. Merci.

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. 

Aucune erreur avec en-tête. Maintenant nouvelle erreur ->

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. 
+0

Lorsque vous posez des questions sur les problèmes du compilateur, veuillez fournir la sortie du compilateur, y compris la ligne de commande du compilateur. Vous pouvez le trouver dans la fenêtre IDE. –

+0

Voir Voir http://qt-project.org/doc/qtcreator-2.6/creator-quick-tour.html#viewing-output –

+0

@NikolayShmyrev Merci pour votre réponse! J'ai ajouté la sortie en question. J'espère que ça aide! – Warezovvv

Répondre

0

Vous semblez avoir l'installation des en-têtes de sphinxbase dans /usr/include, pas /usr/local/include. Si vous avez volontairement compilé sphinxbase de cette façon, vous devez ajouter -I/usr/include/sphinxbase dans Makefile, pas -I/usr/local/include/sphinxbase.

L'ensemble des pocketsphinx-5prealpha nécessite un sphinxbase-5prealpha et le préfixe d'installation par défaut est/usr/local. Je vous suggère d'enlever sphinxbase de/usr.

+0

Oui cela fonctionne, mais maintenant j'ai d'autres problèmes mis à jour. – Warezovvv

+0

Vous devez définir MODELDIR dans Makefile. Quelque chose comme CFLAGS + = -DMODELDIR "/ usr/share/pocketsphinx/model". Ou juste un code dur MODELDIR dans les sources. –

+0

Le didacticiel en parle: La macro MODELDIR est définie sur la ligne de commande GCC en utilisant pkg-config pour obtenir la variable modeldir à partir de la configuration de PocketSphinx. Sous Windows, vous pouvez simplement ajouter une définition de préprocesseur au code, comme ceci: #define MODELDIR "c:/sphinx/model" –