0

アプリケーションで TTS エンジンを使用する必要があり、Flite を使用しようとしました。インストールしてコマンドラインからテストしましたが、アプリケーションに入れようとすると動作しませんでした。ほとんどの指示はWindowsまたはAndroid用であるため、私はすでにWebを検索しましたが成功しませんでした。Barath-Kannan による c++ ラッパーも認識していますが、C++17 が必要であり、現時点では使用できません。Ubuntu 16.04 で C++11 を使用しています。

これが私のコードです:

TTSFliteManager: (Flite を使用するクラス)

#include "TTSFliteManager.h"
#include </home/user/flite/include/flite.h>
#include <utils/Logger.h>
...

void
TTSFliteManager::TTSTranslate(std::string text, std::string destination)
{
    ADD_LOG_DEBUG << "TTSFliteManager::TTSTranslate()";
    cst_voice *voice;
    flite_init();

    voice = flite_voice_select(NULL);

    float secs = flite_text_to_speech(text.c_str(),voice,destination.c_str());
    if (secs == 0)
        ADD_LOG_ERROR << "TTSFliteManager::TTSTranslate() ERROR GENERATED AUDIO FILE IS EMPTY";
    
}
...

ビルド時に発生するエラーは次のとおりです。

...
libPlugin.so: undefined reference to "flite_voice_select"
libPlugin.so: undefined reference to "flite_text_to_speech"
libPlugin.so: undefined reference to "flite_init"
collect2: error: ld returned 1 exit status

ドキュメントの例を見ると、プロジェクトにいくつかのライブラリ (「-lflite_cmu_us_kal」「-lflite_usenglish」「-lflite_cmulex」「-lflite」「-lm」) が不足していることがわかります。

「find_package」を使用する必要がありますか? "include_directories"? もしそうなら、それを機能させるための適切なパラメータは何ですか? 私が使用したもの (Flite、FliteDll) は、そのようなパッケージが見つからないことを示すエラーを返しました。

CMakeLists を適切に構成する必要があると思いますが、プロジェクトに flite ライブラリを表示させるためにそこに何を書けばよいかわかりません。

編集

プラグイン CMakeList:

set(PLUGSOURCECD_DIR "$ENV{DEV_ROOT}/Plugin/ModPlugin")
set(PLUGSOURCEMD_DIR "$ENV{DEV_ROOT}/src/")
set(PLUGSOURCEAWT_DIR "$ENV{DEV_ROOT}/AWT/sources")
set(PLUG_DIR "$ENV{DEV_ROOT}/Plugin")
include( "$ENV{CMAKE_ADDITIONAL_MODULES_DIR}/CommonRules.cmake" )

MESSAGE("Dir = ${PLUGSOURCECD_DIR}")
MESSAGE("CMAKE_SOURCE_DIR = ${CMAKE_SOURCE_DIR}")


IF(WIN32)

    IF(NOT CMAKE_DEBUG_POSTFIX)
      set(CMAKE_DEBUG_POSTFIX d)
    ENDIF()
    if(POLICY CMP0020)
      cmake_policy(SET CMP0020 NEW)
    endif()
    if(POLICY CMP0074)
      cmake_policy(SET CMP0074 NEW)
    endif()
    if(POLICY CMP0011)
      cmake_policy(SET CMP0011 NEW)
    endif()
ENDIF()

IF(CMAKE_SOURCE_DIR STREQUAL PLUGSOURCECD_DIR)

# CMake compatibility issues.
cmake_minimum_required(VERSION 2.8)
mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY)
project(modPlugin)
#include( "Project.cmake" )

include( "Target.cmake" )

find_package(Qt5 5.8 COMPONENTS Widgets Multimedia MultimediaWidgets REQUIRED)
# The Qt5Widgets_INCLUDES also includes the include directories for
  # dependencies QtCore and QtGui
  include_directories(${Qt5Widgets_INCLUDE_DIRS})
    MESSAGE("QT Qt5Widgets_INCLUDES = ${Qt5Widgets_INCLUDE_DIRS}")
  # We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
  add_definitions(${Qt5Widgets_DEFINITIONS})
set(QT_LIBRARIES 
    Qt5::Gui Qt5::Core Qt5::Multimedia Qt5::MultimediaWidgets )
MESSAGE("QT5LIB = ${QT_LIBRARIES}")
set(QT_CLILIBRARIES ${QT_LIBRARIES})

ENDIF(CMAKE_SOURCE_DIR STREQUAL PLUGSOURCECD_DIR)

# LiquidSDR
find_package(liquiddsp REQUIRED)
include_directories(${liquiddsp_INCLUDE_DIR})
MESSAGE("LiquidDSP = ${liquiddsp_LIBRARY}")
MESSAGE("LiquidDSP include = ${liquiddsp_INCLUDE_DIR}")

INCLUDE_DIRECTORIES(${PLUGSOURCECD_DIR})


set(PCDSOURCES
#list of .cpp files
...
    ${PLUGSOURCECD_DIR}/sources/TTSFliteManager.cpp
...
        )     

set(PCDHEADER
#list of .h files
...
    ${PLUGSOURCECD_DIR}/sources/TTSFliteManager.h
...
        )               

set ( UIS
lust of .ui files
...
)

set(CMAKE_AUTORCC ON)
SET(CMAKE_AUTOUIC ON)

QT5_WRAP_CPP(PLUGINTMOCCD_SOURCES ${PCDHEADER})
QT5_WRAP_UI( UI_HEADERS ${UIS} )
set(PLUGIN_DIR "${CMAKE_BINARY_DIR}/plugins")

file(MAKE_DIRECTORY ${PLUGIN_DIR})

MESSAGE("Source = ${PCDSOURCES}")
set(modPlugin_LIBRARIES modPlugin)
add_library(${modPlugin_LIBRARIES} SHARED ${PCDSOURCES} ${PLUGINTMOCCD_SOURCES} ${UI_HEADERS})

target_link_libraries( 
    ${modPlugin_LIBRARIES} 
    ${gui_LIBRARIES} 
    ${QT_LIBRARIES}  
    ${liquiddsp_LIBRARY}
)

add_custom_command(TARGET ${modPlugin_LIBRARIES} 
                   POST_BUILD
                   COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${modPlugin_LIBRARIES}> ${PLUGIN_DIR})

プロジェクト CMakeList:

# CMake compatibility issues.
cmake_minimum_required(VERSION 2.6)
mark_as_advanced(CMAKE_BACKWARDS_COMPATIBILITY)

PROJECT(SSTUDIO)

include(Target.cmake)

INCLUDE(Project.cmake)

SET(BUILD_SHARED_LIBS "true")
set(SMSSTYLEDIR "$ENV{DEV_ROOT}/styles")
IF(BUILD_SHARED_LIBS)
MESSAGE(STATUS "=====>>>>> Compile internal libraries as shared")
ELSE()
MESSAGE(STATUS "=====>>>>> Compile internal libraries as static")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
ENDIF()

IF(WIN32)
    IF(BUILD_SHARED_LIBS)
        ADD_DEFINITIONS(-DBUILD_SHARED_LIBS)
    ENDIF()
    IF(NOT CMAKE_DEBUG_POSTFIX)
        SET(CMAKE_DEBUG_POSTFIX d)
    ENDIF()

    cmake_policy(SET CMP0020 NEW)
ENDIF()

INCLUDE("$ENV{CMAKE_ADDITIONAL_MODULES_DIR}/CommonRules.cmake")

set(SSTUDIO_SOURCES
#list of .cpp files
...
)

SET(SSTUDIO_MOC_HEADERS
#list of .h files
...
)


FIND_PACKAGE(Boost 1.57.0 REQUIRED system date_time program_options filesystem chrono thread)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
IF(WIN32)
    ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB)
    ADD_DEFINITIONS(-DBOOST_ALL_DYN_LINK)
    ADD_DEFINITIONS(-DBOOST_NO_RVALUE_REFERENCES)

    LINK_DIRECTORIES(${LINK_DIRECTORIES} ${Boost_LIBRARY_DIRS})
ENDIF()

# fftw3
find_package(FFTW REQUIRED)
include_directories(${FFTW_INCLUDES})
MESSAGE(STATUS "FFTW_INCLUDES : '${FFTW_INCLUDES}'")


find_package(ZeroMQ REQUIRED)
INCLUDE_DIRECTORIES(${ZeroMQ_INCLUDE_DIRS})


#TTS Flite commented out since is not working anyway
#set(TTS_DIR "/home/user/flite")
#find_package(FliteDll REQUIRED flite_cmu_us_kal flite_usenglish flite_cmulex flite m)
#include_directories(${FliteDll_INCLUDES})


set(CMAKE_INCLUDE_CURRENT_DIR ON)

# Libsndfile
find_package(sndfile REQUIRED)
include_directories(${sndfile_INCLUDE_DIR})
MESSAGE("Libsndfile = ${sndfile_LIBRARY}")
MESSAGE("Libsndfile include = ${sndfile_INCLUDE_DIR}")


IF($ENV{QT_SELECT} STREQUAL "4")
    set(QT_QMAKE_EXECUTABLE "$ENV{QTDIR}/Bin/qmake.exe")
    find_package(Qt4 4.8.6 REQUIRED QtGui QtCore QtSql QtNetwork QtTest QtUiTools QtXml)
    include (Qt4Macros)
    include(${QT_USE_FILE})
    include_directories(${QT_INCLUDES})
    ADD_DEFINITIONS( ${QT_DEFINITIONS} )
ELSE()
    find_package(Qt5 5.8 COMPONENTS Widgets Core Network Xml Sql UiTools Multimedia MultimediaWidgets Concurrent REQUIRED)
    # The Qt5Widgets_INCLUDES also includes the include directories for dependencies QtCore and QtGui
    include_directories(${Qt5Widgets_INCLUDE_DIRS} ${Qt5Multimedia_INCLUDE_DIRS} ${Qt5Concurrent_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS})

    # We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5.
    add_definitions(${Qt5Widgets_DEFINITIONS})
    set(SSTUDIO_QT_LIBRARIES Qt5::Gui Qt5::Core Qt5::Sql Qt5::Network Qt5::UiTools Qt5::Xml Qt5::Multimedia Qt5::MultimediaWidgets)
ENDIF()

SET(CMAKE_AUTORCC ON)
SET(CMAKE_AUTOUIC ON)

# moc'ing
if(Qt4_FOUND OR QT4_FOUND)
  QT4_WRAP_CPP( SSTUDIO_MOC_SOURCES ${SSTUDIO_MOC_HEADERS} )
ELSE()
  QT5_WRAP_CPP( SSTUDIO_MOC_SOURCES ${SSTUDIO_MOC_HEADERS})
endif(Qt4_FOUND OR QT4_FOUND)

find_package(Poco REQUIRED Net NetSSL)
find_package(OpenSSL REQUIRED)

INCLUDE("Dependencies.cmake")


SET(SSTUDIO_LIBS
    ${Boost_LIBRARIES}
    ${ZeroMQ_LIBRARIES}
    ${FFTW_LIBRARIES}
    ${SSTUDIO_QT_LIBRARIES}
...
    ${modPlugin_LIBRARIES}
    ${ftpPlugin_LIBRARIES}
    ${sndfile_LIBRARIES}
#    ${FliteDll_LIBRARIES} commented out since is not working anyway
)

IF(UNIX)
    #target_link_libraries(${roofipc_LIBRARIES} ${ZeroMQ_LIBRARIES})
ENDIF()


add_executable(
    ${TARGET_NAME} 
    ${SSTUDIO_SOURCES} 
    ${SSTUDIO_MOC_SOURCES} 
)
target_link_libraries(
    ${TARGET_NAME} 
    ${SSTUDIO_LIBS} 
    ${Poco_LIBRARIES}
)


INCLUDE("$ENV{CMAKE_ADDITIONAL_MODULES_DIR}/ProductInfo.cmake")

# ----- POST-BUILD -----
#

# post build package creation
add_custom_target( pack
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/pack.cmake
    COMMENT "Creating package..." )

# postbuild copies
include ( copyConfig.cmake )
include ( copyScripts.cmake )

# post RUNTIME Environment Setup
add_custom_target( runtime COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/runtimeConfiguration.sh ${TARGET_NAME} COMMENT "Setup Runtime..." )
4

1 に答える 1