Fixed Windows build
This commit is contained in:
parent
fd842111dc
commit
4baab9b207
|
@ -16,16 +16,21 @@ if("${CMAKE_GENERATOR}" STREQUAL "Xcode")
|
||||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Use static run-time
|
||||||
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
add_compile_options(/MT$<$<CONFIG:Debug>:d>)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Set output directories
|
# Set output directories
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
||||||
|
|
||||||
# Define flags variables for later use
|
# Define flags variables for later use
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||||
set(enableWarningsFlags "-Wall;-Wextra")
|
set(enableWarningsFlags "-Wall;-Wextra")
|
||||||
set(disableWarningsFlags "-w")
|
set(disableWarningsFlags "-w")
|
||||||
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
set(enableWarningsFlags "/W4")
|
set(enableWarningsFlags "/W4")
|
||||||
set(disableWarningsFlags "/W0")
|
set(disableWarningsFlags "/W0")
|
||||||
endif()
|
endif()
|
||||||
|
@ -46,13 +51,13 @@ add_library(cppFormat ${cppFormatFiles})
|
||||||
target_compile_options(cppFormat PRIVATE ${disableWarningsFlags})
|
target_compile_options(cppFormat PRIVATE ${disableWarningsFlags})
|
||||||
|
|
||||||
# ... sphinxbase
|
# ... sphinxbase
|
||||||
include_directories(SYSTEM "lib/sphinxbase-5prealpha-2015-08-05/include")
|
include_directories(SYSTEM "lib/sphinxbase-redefine/include" "lib/sphinxbase-5prealpha-2015-08-05/include")
|
||||||
FILE(GLOB_RECURSE sphinxbaseFiles "lib/sphinxbase-5prealpha-2015-08-05/src/libsphinxbase/*.c")
|
FILE(GLOB_RECURSE sphinxbaseFiles "lib/sphinxbase-5prealpha-2015-08-05/src/libsphinxbase/*.c")
|
||||||
add_library(sphinxbase ${sphinxbaseFiles})
|
add_library(sphinxbase ${sphinxbaseFiles})
|
||||||
target_compile_options(sphinxbase PRIVATE ${disableWarningsFlags})
|
target_compile_options(sphinxbase PRIVATE ${disableWarningsFlags})
|
||||||
|
|
||||||
# ... PocketSphinx
|
# ... PocketSphinx
|
||||||
include_directories(SYSTEM "lib/pocketsphinx-5prealpha-2015-08-05/include")
|
include_directories(SYSTEM "lib/pocketsphinx-redefine/include" "lib/pocketsphinx-5prealpha-2015-08-05/include")
|
||||||
FILE(GLOB pocketSphinxFiles "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx/*.c")
|
FILE(GLOB pocketSphinxFiles "lib/pocketsphinx-5prealpha-2015-08-05/src/libpocketsphinx/*.c")
|
||||||
add_library(pocketSphinx ${pocketSphinxFiles})
|
add_library(pocketSphinx ${pocketSphinxFiles})
|
||||||
target_link_libraries(pocketSphinx sphinxbase)
|
target_link_libraries(pocketSphinx sphinxbase)
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef __POCKETSPHINX_EXPORT_H__
|
||||||
|
#define __POCKETSPHINX_EXPORT_H__
|
||||||
|
|
||||||
|
// We're creating a static library. No __declspec!
|
||||||
|
#define POCKETSPHINX_EXPORT
|
||||||
|
|
||||||
|
#endif /* __POCKETSPHINX_EXPORT_H__ */
|
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef __SPHINXBASE_EXPORT_H__
|
||||||
|
#define __SPHINXBASE_EXPORT_H__
|
||||||
|
|
||||||
|
// We're creating a static library. No __declspec!
|
||||||
|
#define SPHINXBASE_EXPORT
|
||||||
|
|
||||||
|
#endif /* __SPHINXBASE_EXPORT_H__ */
|
|
@ -1,14 +1,17 @@
|
||||||
#include <pocketsphinx.h>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <sphinxbase/err.h>
|
|
||||||
#include "phone_extraction.h"
|
#include "phone_extraction.h"
|
||||||
#include "audio_input/SampleRateConverter.h"
|
#include "audio_input/SampleRateConverter.h"
|
||||||
#include "audio_input/ChannelDownmixer.h"
|
#include "audio_input/ChannelDownmixer.h"
|
||||||
#include "platform_tools.h"
|
#include "platform_tools.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
#include <pocketsphinx.h>
|
||||||
|
#include <sphinxbase/err.h>
|
||||||
|
}
|
||||||
|
|
||||||
using std::runtime_error;
|
using std::runtime_error;
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
@ -128,7 +131,7 @@ void sphinxErrorCallback(void* user_data, err_lvl_t errorLevel, const char* form
|
||||||
// Create varArgs list
|
// Create varArgs list
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
auto _ = finally([&args](){ va_end(args); });
|
auto _ = finally([&args]() { va_end(args); });
|
||||||
|
|
||||||
// Format message
|
// Format message
|
||||||
const int initialSize = 256;
|
const int initialSize = 256;
|
||||||
|
@ -174,7 +177,8 @@ map<centiseconds, Phone> detectPhones(unique_ptr<AudioStream> audioStream) {
|
||||||
|
|
||||||
// Collect results into map
|
// Collect results into map
|
||||||
return getPhones(*recognizer.get());
|
return getPhones(*recognizer.get());
|
||||||
} catch (...) {
|
}
|
||||||
|
catch (...) {
|
||||||
std::throw_with_nested(runtime_error("Error detecting phones via Pocketsphinx. " + errorMessage));
|
std::throw_with_nested(runtime_error("Error detecting phones via Pocketsphinx. " + errorMessage));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue