diff --git a/CMakeLists.txt b/CMakeLists.txt index 95721e3..181ad50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,16 @@ file(READ "${CMAKE_CURRENT_LIST_DIR}/VERSION" piper_version) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) +if(MSVC) + # Force compiler to use UTF-8 for IPA constants + add_compile_options("$<$:/utf-8>") + add_compile_options("$<$:/utf-8>") +elseif(NOT APPLE) + # Linux flags + string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'") + string(APPEND CMAKE_C_FLAGS " -Wall -Wextra") +endif() + add_executable(piper src/cpp/main.cpp src/cpp/piper.cpp) # NOTE: onnxruntime is pulled from piper-phonemize @@ -15,11 +25,12 @@ add_executable(piper src/cpp/main.cpp src/cpp/piper.cpp) if(NOT DEFINED FMT_DIR) set(FMT_VERSION "10.0.0") - set(FMT_DIR "${CMAKE_CURRENT_BINARY_DIR}/fmt_install") + set(FMT_DIR "${CMAKE_CURRENT_BINARY_DIR}/fi") include(ExternalProject) ExternalProject_Add( fmt_external + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/f" URL "https://github.com/fmtlib/fmt/archive/refs/tags/${FMT_VERSION}.zip" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${FMT_DIR} CMAKE_ARGS -DFMT_TEST:BOOL=OFF # Don't build all the tests @@ -30,10 +41,11 @@ endif() # ---- spdlog --- if(NOT DEFINED SPDLOG_DIR) - set(SPDLOG_DIR "${CMAKE_CURRENT_BINARY_DIR}/spdlog_install") + set(SPDLOG_DIR "${CMAKE_CURRENT_BINARY_DIR}/si") set(SPDLOG_VERSION "1.12.0") ExternalProject_Add( spdlog_external + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/s" URL "https://github.com/gabime/spdlog/archive/refs/tags/v${SPDLOG_VERSION}.zip" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SPDLOG_DIR} ) @@ -43,9 +55,10 @@ endif() # ---- piper-phonemize --- if(NOT DEFINED PIPER_PHONEMIZE_DIR) - set(PIPER_PHONEMIZE_DIR "${CMAKE_CURRENT_BINARY_DIR}/piper_phonemize_install") + set(PIPER_PHONEMIZE_DIR "${CMAKE_CURRENT_BINARY_DIR}/pi") ExternalProject_Add( piper_phonemize_external + PREFIX "${CMAKE_CURRENT_BINARY_DIR}/p" URL "https://github.com/rhasspy/piper-phonemize/archive/refs/heads/workflow.zip" CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${PIPER_PHONEMIZE_DIR} ) @@ -54,11 +67,7 @@ endif() # ---- Declare executable ---- -if(WIN32) - # Force compiler to use UTF-8 for IPA constants - add_compile_options("$<$:/utf-8>") - add_compile_options("$<$:/utf-8>") -elseif(NOT APPLE) +if((NOT MSVC) AND (NOT APPLE)) # Linux flags string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wl,-rpath,'$ORIGIN'") string(APPEND CMAKE_C_FLAGS " -Wall -Wextra") @@ -80,53 +89,49 @@ target_link_directories(piper PUBLIC ${FMT_DIR}/lib ${SPDLOG_DIR}/lib ${PIPER_PHONEMIZE_DIR}/lib - ${ONNXRUNTIME_DIR}/lib ) target_include_directories(piper PUBLIC ${FMT_DIR}/include ${SPDLOG_DIR}/include ${PIPER_PHONEMIZE_DIR}/include - ${ONNXRUNTIME_DIR}/include ) target_compile_definitions(piper PUBLIC _PIPER_VERSION=${piper_version}) # ---- Declare test ---- -include(CTest) -enable_testing() -add_executable(test_piper src/cpp/test.cpp src/cpp/piper.cpp) -add_test( - NAME test_piper - COMMAND test_piper "${CMAKE_SOURCE_DIR}/etc/test_voice.onnx" "${PIPER_PHONEMIZE_DIR}/share/espeak-ng-data" "${CMAKE_CURRENT_BINARY_DIR}/test.wav" +# include(CTest) +# enable_testing() +# add_executable(test_piper src/cpp/test.cpp src/cpp/piper.cpp) +# add_test( +# NAME test_piper +# COMMAND test_piper "${CMAKE_SOURCE_DIR}/etc/test_voice.onnx" "${PIPER_PHONEMIZE_DIR}/share/espeak-ng-data" "${CMAKE_CURRENT_BINARY_DIR}/test.wav" -) -target_compile_features(test_piper PUBLIC cxx_std_17) +# ) +# target_compile_features(test_piper PUBLIC cxx_std_17) -target_include_directories( - test_piper PUBLIC - ${FMT_DIR}/include - ${SPDLOG_DIR}/include - ${PIPER_PHONEMIZE_DIR}/include - ${ONNXRUNTIME_DIR}/include -) +# target_include_directories( +# test_piper PUBLIC +# ${FMT_DIR}/include +# ${SPDLOG_DIR}/include +# ${PIPER_PHONEMIZE_DIR}/include +# ) -target_link_directories( - test_piper PUBLIC - ${FMT_DIR}/lib - ${SPDLOG_DIR}/lib - ${PIPER_PHONEMIZE_DIR}/lib - ${ONNXRUNTIME_DIR}/lib -) +# target_link_directories( +# test_piper PUBLIC +# ${FMT_DIR}/lib +# ${SPDLOG_DIR}/lib +# ${PIPER_PHONEMIZE_DIR}/lib +# ) -target_link_libraries(test_piper PUBLIC - fmt - spdlog - espeak-ng - piper_phonemize - onnxruntime -) +# target_link_libraries(test_piper PUBLIC +# fmt +# spdlog +# espeak-ng +# piper_phonemize +# onnxruntime +# ) # ---- Declare install targets ---- diff --git a/src/cpp/main.cpp b/src/cpp/main.cpp index 8972eac..3c6192e 100644 --- a/src/cpp/main.cpp +++ b/src/cpp/main.cpp @@ -117,7 +117,8 @@ int main(int argc, char *argv[]) { GetModuleFileNameW(nullptr, moduleFileName, std::size(moduleFileName)); return filesystem::path(moduleFileName); }(); -#elifdef __APPLE__ +#else +#ifdef __APPLE__ auto exePath = []() { char moduleFileName[PATH_MAX] = {0}; uint32_t moduleFileNameSize = std::size(moduleFileName); @@ -126,6 +127,7 @@ int main(int argc, char *argv[]) { }(); #else auto exePath = filesystem::canonical("/proc/self/exe"); +#endif #endif if (voice.phonemizeConfig.phonemeType == piper::eSpeakPhonemes) { diff --git a/src/cpp/piper.cpp b/src/cpp/piper.cpp index 838efa5..5310037 100644 --- a/src/cpp/piper.cpp +++ b/src/cpp/piper.cpp @@ -482,7 +482,7 @@ void textToAudio(PiperConfig &config, Voice &voice, std::string text, // DEBUG log for phonemes std::string phonemesStr; for (auto phoneme : sentencePhonemes) { - utf8::append(phoneme, &phonemesStr); + utf8::append(phoneme, std::back_inserter(phonemesStr)); } spdlog::debug("Converting {} phoneme(s) to ids: {}", @@ -596,7 +596,7 @@ void textToAudio(PiperConfig &config, Voice &voice, std::string text, for (auto phonemeCount : missingPhonemes) { std::string phonemeStr; - utf8::append(phonemeCount.first, &phonemeStr); + utf8::append(phonemeCount.first, std::back_inserter(phonemeStr)); spdlog::warn("Missing \"{}\" (\\u{:04X}): {} time(s)", phonemeStr, (uint32_t)phonemeCount.first, phonemeCount.second); }