Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 34 additions & 17 deletions ttsclient/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,30 @@ pkg_check_modules(WPEFRAMEWORK_SECURITYUTIL WPEFrameworkSecurityUtil)

# Build TTS Service Client library
set(TextToSpeechServiceClient_SOURCES
TextToSpeechServiceCOMRPC.cpp
TextToSpeechService.cpp
Service.cpp
../common/logger.cpp
TextToSpeechServiceFirebolt.cpp
)
TextToSpeechServiceCOMRPC.cpp
TextToSpeechService.cpp
Service.cpp
../common/logger.cpp
)

if(TTS_DEFAULT_BACKEND STREQUAL "firebolt")
list(APPEND TextToSpeechServiceClient_SOURCES TextToSpeechServiceFirebolt.cpp)
endif()

add_library(TextToSpeechServiceClient SHARED ${TextToSpeechServiceClient_SOURCES})

# Build TTS Service Client library
set(TTSClient_SOURCES
TTSClient.cpp
TTSClientPrivateJsonRPC.cpp
TTSClientPrivateCOMRPC.cpp
TTSClientPrivateFirebolt.cpp
)
TTSClient.cpp
TTSClientPrivateJsonRPC.cpp
TTSClientPrivateCOMRPC.cpp
)

if(TTS_DEFAULT_BACKEND STREQUAL "firebolt")
add_definitions(-DTTS_DEFAULT_BACKEND_FIREBOLT)
list(APPEND TTSClient_SOURCES TTSClientPrivateFirebolt.cpp)
endif()

add_library(TTSClient SHARED ${TTSClient_SOURCES})

target_include_directories(TextToSpeechServiceClient PUBLIC ${WPEFRAMEWORK_PLUGINS_INCLUDE_DIRS})
Expand All @@ -50,18 +59,26 @@ if(TTS_DEFAULT_BACKEND)
add_definitions(-DTTS_DEFAULT_BACKEND="${TTS_DEFAULT_BACKEND}")
endif()

target_link_libraries(TextToSpeechServiceClient PUBLIC
if(TTS_DEFAULT_BACKEND STREQUAL "firebolt")
target_link_libraries(TextToSpeechServiceClient PUBLIC
${WPEFRAMEWORK_PLUGINS_LIBRARIES}
${WPEFRAMEWORK_SECURITYUTIL_LIBRARIES}
-lpthread
FireboltSDK
FireboltSDK
)
else()
target_link_libraries(TextToSpeechServiceClient PUBLIC
${WPEFRAMEWORK_PLUGINS_LIBRARIES}
${WPEFRAMEWORK_SECURITYUTIL_LIBRARIES}
-lpthread
)
endif()

target_link_libraries(TTSClient PUBLIC
${GLIB_LIBRARIES}
${LIBS}
TextToSpeechServiceClient
)
${GLIB_LIBRARIES}
${LIBS}
TextToSpeechServiceClient
)

install(TARGETS TTSClient TextToSpeechServiceClient LIBRARY DESTINATION lib)
install(FILES TTSClient.h ../common/TTSCommon.h TextToSpeechService.h Service.h DESTINATION include)
23 changes: 16 additions & 7 deletions ttsclient/TTSClient.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*#ifdef TTS_DEFAULT_BACKEND_FIREBOLT
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
Expand All @@ -19,7 +19,9 @@

#include "TTSClientPrivateCOMRPC.h"
#include "TTSClientPrivateJsonRPC.h"
#ifdef TTS_DEFAULT_BACKEND_FIREBOLT
#include "TTSClientPrivateFirebolt.h"
#endif
#include "logger.h"
#include <mutex>
// --- //
Expand All @@ -36,7 +38,9 @@ namespace TTS {

TTSClient::Backend getTTSBackend() {
static const char *kCOMRPC = "comrpc";
#ifdef TTS_DEFAULT_BACKEND_FIREBOLT
static const char *kFIREBOLT = "firebolt";
#endif

static const char *backendEnv = getenv("TTS_CLIENT_BACKEND");
static const char *thunderClientEnv = getenv("TTS_USE_THUNDER_CLIENT"); // will go away eventually
Expand All @@ -56,8 +60,11 @@ TTSClient::Backend getTTSBackend() {
if(backendConfig) {
if(strncasecmp(backendConfig, kCOMRPC, strlen(kCOMRPC)) == 0)
backend = TTSClient::COM;
else if (strncasecmp(backendConfig, kFIREBOLT, strlen(kFIREBOLT)) == 0)
backend = TTSClient::FIREBOLT;
#ifdef TTS_DEFAULT_BACKEND_FIREBOLT
else if (strncasecmp(backendConfig, kFIREBOLT, strlen(kFIREBOLT)) == 0){
backend = TTSClient::FIREBOLT;
}
#endif
}

if(thunderClientEnv)
Expand Down Expand Up @@ -86,10 +93,12 @@ TTSClient::TTSClient(Backend backend, TTSConnectionCallback *callback, bool disc
TTSLOG_INFO("TTSClient is using JSONRPC");
m_priv = new TTSClientPrivateJsonRPC(callback, discardRtDispatching);
break;
case FIREBOLT:
TTSLOG_INFO("TTSClient is using FIREBOLT");
m_priv = new TTSClientPrivateFirebolt(callback, discardRtDispatching);
break;
#ifdef TTS_DEFAULT_BACKEND_FIREBOLT
case FIREBOLT:
TTSLOG_INFO("TTSClient is using FIREBOLT");
m_priv = new TTSClientPrivateFirebolt(callback, discardRtDispatching);
break;
#endif
}
}

Expand Down
4 changes: 3 additions & 1 deletion ttsclient/TTSClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ class TTSClient {
enum Backend {
COM,
JSON,
FIREBOLT
#ifdef TTS_DEFAULT_BACKEND_FIREBOLT
FIREBOLT
#endif
};

static TTSClient *create(TTSConnectionCallback *connCallback, bool discardRtDispatching=false);
Expand Down
18 changes: 11 additions & 7 deletions ttsclient/TextToSpeechServiceFirebolt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static std::mutex __mutex;

std::condition_variable cv;
std::mutex mtx;
namespace TTSFirebolt{
namespace TTSFirebolt {

bool TextToSpeechServiceFirebolt::isConnected;

Expand All @@ -53,18 +53,22 @@ void TextToSpeechServiceFirebolt::initialize() {
if(initialized())
return;
const char* firebolt_endpoint = std::getenv("FIREBOLT_ENDPOINT");
//const char* firebolt_endpoint = "ws://127.0.0.1:3474";
if(firebolt_endpoint != nullptr) {
std::string url = firebolt_endpoint;
if(!createFireboltInstance(url)){
if(!createFireboltInstance(url)) {
TTSLOG_ERROR("Failed to create FireboltInstance URL: [%s]", url.c_str());
return;
}
std::unique_lock<std::mutex> lock(mtx);
cv.wait(lock, [this]{ return isConnected; });
m_initialized = true;
subscribeEvents();
TTSLOG_INFO("Firebolt Core Intiailized URL: [%s]", url.c_str());
/*Wait Time is 200 millisecond*/
if (cv.wait_for(lock, std::chrono::milliseconds(200), [this] { return isConnected; })) {
m_initialized = true;
subscribeEvents();
TTSLOG_INFO("Firebolt Core Intiailized URL: [%s]", url.c_str());
}
else {
TTSLOG_ERROR("Firebolt Core Intiailized URL: [%s] Failed(Timeout)", url.c_str());
}
}
else {
TTSLOG_ERROR("No Firebolt endpoint; initialization failed");
Expand Down