Aniket Sharma
Aniket Sharma

Reputation: 21

How can I use the PocketSphinx library in my C++ project?

I'm trying to use the PocketSphinx speech to text library in my project as a Git submodule. So, I added the submodule to my dependency folder and I added the following code to my MakeFile:

add_subdirectory(dependencies/pocketsphinx)

But, when I'm building the project, I'm getting an error saying that:

[build] /home/aniket/code/restapi/dependencies/pocketsphinx/src/allphone_search.c:43:10: fatal error: pocketsphinx.h: No such file or directory
[build]    43 | #include <pocketsphinx.h>
[build]       |          ^~~~~~~~~~~~~~~~
[build] compilation terminated.

My guess is that CMAKE cannot find the header files; but, when I build PocketSphinx alone it works fine.

I'm also using the JsonCpp library, which compiles without any problem.

My CMAKE file is:

cmake_minimum_required(VERSION 3.2.0)
project(assistant)

add_executable(${PROJECT_NAME} src/main.cpp)

add_subdirectory(dependencies/jsonpp)
add_subdirectory(dependencies/pocketsphinx)
target_include_directories(${PROJECT_NAME} PUBLIC include PUBLIC 
    dependencies/jsonpp/include)


target_include_directories(${PROJECT_NAME} PRIVATE include
PRIVATE dependencies/jsonpp/include)
target_link_directories(${PROJECT_NAME} PRIVATE build/lib)
target_link_libraries(${PROJECT_NAME} PRIVATE jsoncpp curl)

Here's my directory structure:

.
├── build
├── dependencies
│   ├── jsonpp
│   │   ├── cmake
│   │   ├── devtools
│   │   ├── doc
│   │   ├── example
│   │   ├── include
│   │   ├── pkg-config
│   │   ├── src
│   │   └── test
│   └── pocketsphinx
│       ├── cython
│       ├── docs
│       ├── doxygen
│       ├── examples
│       ├── gst
│       ├── include
│       ├── model
│       ├── programs
│       ├── src
│       └── test
├── include
└── src

Upvotes: 2

Views: 216

Answers (0)

Related Questions