#------------------------------------------------------------------- # This file is part of the CMake build system for Scol # # The contents of this file are placed in the public domain. Feel # free to make use of it in any way you like. #------------------------------------------------------------------- ############################################################ # Speech plugin CMakeList ############################################################ PROJECT(speech) find_host_package(vosk) macro_log_feature(vosk_FOUND "Vosk SDK" "Text to speech and voice recognition plugin" "https://alphacephei.com/vosk/" FALSE "" "") find_host_package(piper) macro_log_feature(piper_FOUND "Piper SDK" "TTS plugin" "https://github.com/rhasspy/piper/" FALSE "" "") option(SPEECH_USE_SAPI_TTS "USE WINDOWS SAPI for TTS" FALSE) option(SPEECH_USE_SAPI_RECO "USE WINDOWS SAPI for TTS" FALSE) set(SPEECH_COMPILE_FLAGS "") if(MSVC) # Force compiler to use UTF-8 for IPA constants add_compile_options("$<$:/utf-8>") add_compile_options("$<$:/utf-8>") endif() # define source files for the library set (SPEECH_HEADER_FILES include/pluginSpeechPrerequisites.h) if (SPEECH_USE_SAPI_RECO) set (SPEECH_HEADER_FILES ${SPEECH_HEADER_FILES} include/reco.h) set (SPEECH_COMPILE_FLAGS ${SPEECH_COMPILE_FLAGS} -DRECO_USE_SAPI) else() set (SPEECH_HEADER_FILES ${SPEECH_HEADER_FILES} include/reco_vosk.h) endif(SPEECH_USE_SAPI_RECO) if (SPEECH_USE_SAPI_TTS) set (SPEECH_HEADER_FILES ${SPEECH_HEADER_FILES} include/speech.h) set (SPEECH_COMPILE_FLAGS ${SPEECH_COMPILE_FLAGS} -DSPEECH_USE_SAPI) else() set (SPEECH_HEADER_FILES ${SPEECH_HEADER_FILES} include/speech_piper.h) endif() if (Scol_STATIC) set (SPEECH_HEADER_FILES ${SPEECH_HEADER_FILES} include/loadScolSpeech.h) endif() set (SPEECH_SOURCE_FILES src/plugin.cpp) if (SPEECH_USE_SAPI_RECO) set (SPEECH_SOURCE_FILES ${SPEECH_SOURCE_FILES} src/reco.cpp) else() set (SPEECH_SOURCE_FILES ${SPEECH_SOURCE_FILES} src/reco_vosk.cpp) endif() if (SPEECH_USE_SAPI_TTS) set (SPEECH_SOURCE_FILES ${SPEECH_SOURCE_FILES} src/speech.cpp) else() set (SPEECH_SOURCE_FILES ${SPEECH_SOURCE_FILES} src/speech_piper.cpp) endif() scol_include_plugin("SPEECH" "${PROJECT_SOURCE_DIR}/include" "loadScolSpeech.h") # Add directories includes if (SPEECH_USE_SAPI_RECO OR SPEECH_USE_SAPI_TTS) include_directories(include ${SAPI_INCLUDE_DIRS}) else() include_directories(include) endif() # Add definition for P4 optimizations, warnings removal. add_definitions(-DOPTI_P4 -D_CRT_SECURE_NO_WARNINGS) set(LIBRARIES "") if (SPEECH_USE_SAPI_RECO OR SPEECH_USE_SAPI_TTS) set(LIBRARIES ${LIBRARIES} ${SAPI_LIBRARIES}) endif() if (NOT SPEECH_USE_SAPI_TTS) set(LIBRARIES ${LIBRARIES} vosk::vosk) endif() if (NOT SPEECH_USE_SAPI_TTS) set(LIBRARIES ${LIBRARIES} piper::piper) endif() if (ANDROID) set(LIBRARIES ${LIBRARIES} ${Boost_LIBRARIES} android) endif () # setup Scol speech plugin target add_library(speech ${Scol_LIB_TYPE} ${SPEECH_HEADER_FILES} ${SPEECH_SOURCE_FILES} ) #C++17 needed for piper target_compile_features(speech PUBLIC cxx_std_17) add_dependencies(speech kernel) # set preprocessors for this project only target_compile_options(speech PUBLIC ${SPEECH_COMPILE_FLAGS}) # set the dll version. #set_target_properties(speech PROPERTIES VERSION ${Scol_VERSION} SOVERSION ${Scol_VERSION_MAJOR}) target_link_libraries(speech ${LIBRARIES}) # install Scol speech (no headers to install for this plugin) scol_config_plugin(speech) #install(FILES ${SPEECH_HEADER_FILES} DESTINATION include/SCOL/plugins/speech)