parameter->ptts_id = NULL;
}
+ if (parameter->engine_type) {
+ free(parameter->engine_type);
+ parameter->engine_type = NULL;
+ }
+
free(parameter);
parameter = NULL;
return TTS_ERROR_NONE;
}
+int tts_synthesis_parameter_set_engine_type(tts_synthesis_parameter_h parameter, const char *engine_type)
+{
+ SLOG(LOG_INFO, TAG_TTSC, "@@@ Set engine_type to a synthesis parameter");
+ RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
+
+ RETVM_IF(NULL == parameter || NULL == engine_type, TTS_ERROR_INVALID_PARAMETER, "[ERROR] Input handle is null");
+
+ char *new_engine_type = strdup(engine_type);
+ RETVM_IF(NULL == new_engine_type, TTS_ERROR_OUT_OF_MEMORY, "[ERROR] Fail to allocate memory for engine_type");
+
+ free(parameter->engine_type);
+ parameter->engine_type = new_engine_type;
+
+ SLOG(LOG_DEBUG, TAG_TTSC, "[SUCCESS] Set engine_type(%s) to a synthesis parameter", engine_type);
+ return TTS_ERROR_NONE;
+}
+
int tts_get_pitch_range(tts_h tts, int* min, int* normal, int* max)
{
RETV_IF(TTS_ERROR_NONE != __tts_get_feature_enabled(), TTS_ERROR_NOT_SUPPORTED);
int pitch;
double volume;
double background_volume_ratio;
+ char *engine_type;
};
#ifdef __cplusplus
SLOG(LOG_DEBUG, TAG_TTSC, "parameter->pitch (%d)", parameter->pitch);
SLOG(LOG_DEBUG, TAG_TTSC, "parameter->volume (%f)", parameter->volume);
SLOG(LOG_DEBUG, TAG_TTSC, "parameter->background_volume_ratio (%f)", parameter->background_volume_ratio);
+ SLOG(LOG_DEBUG, TAG_TTSC, "parameter->engine_type(%s)", (parameter->engine_type) ? (parameter->engine_type) : "null");
- int ret = rpc_port_proxy_tts_invoke_add_text_with_synthesis_parameter(info->rpc_h, uid, text, language, ptts_id, parameter->voice_type, parameter->speed, parameter->pitch, parameter->volume, parameter->background_volume_ratio, uttid, not_null_credential);
+ int ret = rpc_port_proxy_tts_invoke_add_text_with_synthesis_parameter(info->rpc_h, uid, text, language, ptts_id, parameter->voice_type, parameter->speed, parameter->pitch, parameter->volume, parameter->background_volume_ratio, parameter->engine_type, uttid, not_null_credential);
int exception = get_last_result();
if (RPC_PORT_ERROR_NONE != exception) {
ret = __convert_and_handle_tidl_error(exception, info);
*/
int tts_stop_pcm(tts_h tts);
+
+/**
+ * @brief Sets the engine_type.
+ * @since_tizen 9.0
+ * @param[in] parameter The TTS synthesis parameter handle
+ * @param[in] engine_type The TTS engine's type
+ * @return @c 0 on success,
+ * otherwise a negative error value
+ * @retval #TTS_ERROR_NONE Successful
+ * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
+ * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
+ * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
+*/
+int tts_synthesis_parameter_set_engine_type(tts_synthesis_parameter_h parameter, const char *engine_type);
+
+
#ifdef __cplusplus
}
#endif
--- /dev/null
+/*
+* Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+* http://www.apache.org/licenses/LICENSE-2.0
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+
+#ifndef __TTSE_INTERNAL_H__
+#define __TTSE_INTERNAL_H__
+
+
+#include <ttse.h>
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+* @brief Called when the engine service user sets the engine_type of synthesized speech.
+* @since_tizen 9.0
+* @remarks This callback function is optional and is registered using ttse_set_engine_type_set_cb().
+* @param[in] engine_type The engine_type of synthesized speech
+* @param[in] user_data The user data to be passed to the callback function
+* @return @c 0 on success,
+* otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
+*/
+typedef int (*ttse_set_engine_type_cb)(const char* engine_type, void* user_data);
+
+
+
+
+/**
+* @brief Sets a callback function to be called when the engine_type of synthesized speech is set.
+* @since_tizen 9.0
+* @remarks The ttse_set_engine_type_cb() function is called when the engine service user sets the engine_type of synthesized speech.
+* @param[in] callback ttse_set_engine_type_cb event callback function
+* @param[in] user_data The user data passed from engine
+* @return @c 0 on success,
+* otherwise a negative error value
+* @retval #TTSE_ERROR_NONE Successful
+* @retval #TTSE_ERROR_NOT_SUPPORTED TTS NOT supported
+* @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
+* @retval #TTSE_ERROR_INVALID_STATE Not initialized
+* @pre The ttse_main() function should be invoked before this function is called.
+* @see ttse_set_engine_type_cb()
+*/
+int ttse_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+/**
+ * @}
+ */
+
+
+#endif /* __TTSE_INTERNAL_H__ */
return TTSD_ERROR_NONE;
}
-speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double background_volume_ratio, int utt_id, bool is_silent, unsigned int duration_in_msec)
+speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double bg_volume, const char* engine_type, int utt_id, bool is_silent, unsigned int duration_in_msec)
{
speak_data_s* speak_data = new speak_data_s();
if (nullptr == speak_data) {
speak_data->synth_parameter.speed = speed;
speak_data->synth_parameter.pitch = pitch;
speak_data->synth_parameter.volume = volume;
- speak_data->synth_parameter.background_volume_ratio = background_volume_ratio;
+ speak_data->synth_parameter.background_volume_ratio = bg_volume;
+ if (engine_type == NULL) {
+ speak_data->synth_parameter.engine_type = nullptr;
+ SLOG(LOG_INFO, tts_tag(), "[DATA INFO] engine_type of synth_parameter is null");
+ } else {
+ speak_data->synth_parameter.engine_type = strdup(engine_type);
+ }
speak_data->utt_id = utt_id;
speak_data->is_silent = is_silent;
int pitch;
double volume;
double background_volume_ratio;
+ char* engine_type;
} synthesis_parameter_s;
typedef struct {
char* ttsd_data_get_credential(unsigned int uid);
/* speak data */
-speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double bg_volume, int utt_id, bool is_silent, unsigned int duration_in_msec);
+speak_data_s* ttsd_data_create_speak_data(const char* text, const char* language, int voice_type, const char* ptts_id, int speed, int pitch, double volume, double bg_volume, const char* engine_type, int utt_id, bool is_silent, unsigned int duration_in_msec);
void ttsd_data_destroy_speak_data(speak_data_s* speak_data);
engine_info->callbacks->private_data_requested = NULL;
engine_info->callbacks->activated_mode_changed = NULL;
engine_info->callbacks->set_personal_tts_id = NULL;
+ engine_info->callbacks->set_engine_type = NULL;
SLOG(LOG_DEBUG, tts_tag(), "--- Valid Engine ---");
SLOG(LOG_DEBUG, tts_tag(), "Engine uuid : %s", engine_info->engine_uuid);
return TTSD_ERROR_NONE;
}
+int ttsd_engine_agent_set_engine_type(const char* engine_type)
+{
+ if (NULL == engine_type) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] engine_type is NULL");
+ return TTSD_ERROR_INVALID_PARAMETER;
+ }
+
+ int ret = __check_engine_initialized_and_loaded();
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Precondition is not met(%s)", get_error_message(ret));
+ return ret;
+ }
+
+ if (NULL == g_engine_info->callbacks->set_engine_type) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Setting engine_type is not supported. Fail to set engine_type.");
+ return TTSD_ERROR_NOT_SUPPORTED_FEATURE;
+ }
+
+ void* data = g_engine_info->callbacks->set_engine_type_user_data;
+ ret = g_engine_info->callbacks->set_engine_type(engine_type, data);
+ if (0 != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Fail to set engine_type : engine_type(%s), result(%s)",
+ engine_type, __ttsd_get_engine_error_code(ret));
+ return TTSD_ERROR_OPERATION_FAILED;
+ }
+
+ SLOG(LOG_INFO, tts_tag(), "[Engine Agent] Set engine_type(%s)", engine_type);
+ return TTSD_ERROR_NONE;
+}
+
int ttsd_engine_agent_is_credential_needed(unsigned int uid, bool* credential_needed)
{
if (NULL == credential_needed) {
g_engine_info->callbacks->set_personal_tts_id = callback;
+ return TTSD_ERROR_NONE;
+}
+
+int ttsd_engine_agent_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data)
+{
+ if (false == __is_agent_initialized()) {
+ SLOG(LOG_ERROR, tts_tag(), "[Engine Agent ERROR] Not Initialized");
+ return TTSD_ERROR_INVALID_STATE;
+ }
+
+ g_engine_info->callbacks->set_engine_type = callback;
+ g_engine_info->callbacks->set_engine_type_user_data = user_data;
+
return TTSD_ERROR_NONE;
}
\ No newline at end of file
int ttsd_engine_agent_set_private_data_requested_cb(ttse_private_data_requested_cb callback);
int ttsd_engine_agent_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback);
int ttsd_engine_agent_set_personal_tts_id_set_cb(ttse_personal_tts_id_set_cb callback);
+int ttsd_engine_agent_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data);
/** Unload current engine */
int ttsd_engine_agent_unload_current_engine();
int ttsd_engine_agent_set_personal_tts_id(const char* ptts_id);
+int ttsd_engine_agent_set_engine_type(const char* engine_type);
+
int ttsd_engine_agent_is_credential_needed(unsigned int uid, bool* credential_needed);
int ttsd_engine_set_private_data(const char* key, const char* data);
#include <errno.h>
#include "ttse.h"
+#include "ttse_internal.h"
#include "tts_defs.h"
#ifdef __cplusplus
ttse_private_data_requested_cb private_data_requested;
ttse_activated_mode_changed_cb activated_mode_changed;
ttse_personal_tts_id_set_cb set_personal_tts_id;
+ ttse_set_engine_type_cb set_engine_type;
+ void* set_engine_type_user_data;
} tts_engine_callback_s;
__stop_and_send_ready_state(uid);
}
} else {
-
if (NULL == speak_data->voice.language || NULL == speak_data->text) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Current data is NOT valid");
__stop_and_send_ready_state(uid);
SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------");
SLOG(LOG_INFO, tts_tag(), "ID : uid (%u), uttid(%d) ", g_utt.uid, g_utt.uttid);
- SLOG(LOG_INFO, tts_tag(), "Voice : language(%s), type(%d), ptts_id(%s), speed(%d)", speak_data->voice.language,
- speak_data->voice.type, speak_data->voice.ptts_id, speak_data->synth_parameter.speed);
+ SLOG(LOG_INFO, tts_tag(), "Voice : language(%s), type(%d), ptts_id(%s), speed(%d), engine_type(%s)", speak_data->voice.language,
+ speak_data->voice.type, speak_data->voice.ptts_id, speak_data->synth_parameter.speed, speak_data->synth_parameter.engine_type);
SLOG(LOG_INFO, tts_tag(), "Text : %s", speak_data->text);
SLOG(LOG_INFO, tts_tag(), "Credential : %s", credential);
SLOG(LOG_INFO, tts_tag(), "-----------------------------------------------------------");
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to set personal tts id !!!! * ");
}
+ ret = ttsd_engine_agent_set_engine_type(speak_data->synth_parameter.engine_type);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] * FAIL to set engine_type !!!! * ");
+ }
+
ret = ttsd_engine_start_synthesis(speak_data->voice.language, speak_data->voice.type, speak_data->voice.ptts_id, speak_data->text,
speak_data->synth_parameter.speed, appid, credential, NULL);
if (TTSD_ERROR_NONE != ret) {
return TTSD_ERROR_INVALID_VOICE;
}
- speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, NULL, speed, 0, -1.0, -1.0, utt_id, false, 0);
+ speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, NULL, speed, 0, -1.0, -1.0, NULL, utt_id, false, 0);
if (NULL == speak_data) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
if (NULL != temp_lang) {
return TTSD_ERROR_NONE;
}
-int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, int utt_id, const char* credential)
+int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, const char* engine_type, int utt_id, const char* credential)
{
app_tts_state_e state = ttsd_data_get_client_state(uid);
if (APP_STATE_NONE == state) {
return TTSD_ERROR_INVALID_VOICE;
}
- speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, ptts_id, speed, pitch, volume, background_volume_ratio, utt_id, false, 0);
+ speak_data_s* speak_data = ttsd_data_create_speak_data(text, lang, voice_type, ptts_id, speed, pitch, volume, background_volume_ratio, engine_type, utt_id, false, 0);
if (NULL == speak_data) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
if (NULL != temp_lang) {
return TTSD_ERROR_OPERATION_FAILED;
}
- SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), uttid(%d), credential(%s)", lang, voice_type, speed, utt_id, credential);
+ SLOG(LOG_INFO, tts_tag(), "[Server] Add queue, lang(%s), vctype(%d), speed(%d), engine_type(%s), uttid(%d), credential(%s)", lang, voice_type, speed, (engine_type) ? engine_type : "NULL", utt_id, credential);
/* if state is APP_STATE_READY , APP_STATE_PAUSED , only need to add speak data to queue*/
int ret = -1;
return TTSD_ERROR_INVALID_PARAMETER;
}
- speak_data_s* speak_data = ttsd_data_create_speak_data(NULL, NULL, 0, NULL, 0, 0, -1.0, -1.0, utt_id, true, duration_in_msec);
+ speak_data_s* speak_data = ttsd_data_create_speak_data(NULL, NULL, 0, NULL, 0, 0, -1.0, -1.0, NULL, utt_id, true, duration_in_msec);
if (NULL == speak_data) {
SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to allocate memory");
return TTSD_ERROR_OPERATION_FAILED;
return ret;
}
+int ttsd_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data)
+{
+ int ret = ttsd_engine_agent_set_engine_type_set_cb(callback, user_data);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[Server ERROR] Fail to set engine_type set cb : ret(%d)", ret);
+ }
+
+ return ret;
+}
+
int ttsd_server_play_pcm(unsigned int uid)
{
app_tts_state_e state = ttsd_data_get_client_state(uid);
#include <Ecore.h>
#include "ttse.h"
+#include "ttse_internal.h"
#include "tts_ipc_method.h"
#ifdef __cplusplus
int ttsd_set_activated_mode_changed_cb(ttse_activated_mode_changed_cb callback);
int ttsd_set_personal_tts_id_set_cb(ttse_personal_tts_id_set_cb callback, void* user_data);
-
int ttsd_send_personal_voice(const char* language, const char* unique_id, const char* display_name, const char* device_name);
+int ttsd_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data);
+
/*
* Server API for client
int ttsd_server_add_silent_utterance(unsigned int uid, unsigned int duration_in_msec, int utt_id, const char* credential);
-int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, int utt_id, const char* credential);
+int ttsd_server_add_text_with_synthesis_parameter(unsigned int uid, const char* text, const char* lang, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, const char* engine_type, int utt_id, const char* credential);
int ttsd_server_play(unsigned int uid, const char* credential);
return TTSD_ERROR_NONE;
}
-static int __add_text_with_synthesis_parameter_cb(rpc_port_stub_tts_context_h context, int uid, const char *text, const char* language, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, int uttid, const char *credential, void *user_data)
+static int __add_text_with_synthesis_parameter_cb(rpc_port_stub_tts_context_h context, int uid, const char *text, const char* language, const char* ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume_ratio, const char* engine_type, int uttid, const char *credential, void *user_data)
{
unsigned int u_uid = (unsigned int)uid;
SLOG(LOG_DEBUG, tts_tag(), ">>>>> TTS ADD TEXT WITH SYNTHESIS PARAMETER(%u)", u_uid);
- int ret = ttsd_server_add_text_with_synthesis_parameter(u_uid, text, language, ptts_id, voice_type, speed, pitch, volume, background_volume_ratio, uttid, credential);
+ int ret = ttsd_server_add_text_with_synthesis_parameter(u_uid, text, language, ptts_id, voice_type, speed, pitch, volume, background_volume_ratio, engine_type, uttid, credential);
if (TTSD_ERROR_NONE != ret) {
SLOG(LOG_ERROR, tts_tag(), "[ERROR] TTS ADD TEXT WITH SYNTHESIS PARAMETER (%u) fail (%d/%s) <<<<<", u_uid, ret, get_error_message(ret));
return ret;
#include <system_info.h>
#include "ttse.h"
+#include "ttse_internal.h"
static int g_feature_enabled = -1;
static bool g_is_terminated = false;
return ret;
}
+
+int ttse_set_engine_type_set_cb(ttse_set_engine_type_cb callback, void* user_data)
+{
+ if (false == is_feature_enabled()) {
+ return TTSE_ERROR_NOT_SUPPORTED;
+ }
+
+ if (NULL == callback) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Invalid parameter");
+ return TTSE_ERROR_INVALID_PARAMETER;
+ }
+
+ if (false == g_is_started) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Service engine is not started.");
+ return TTSE_ERROR_INVALID_STATE;
+ }
+
+ int ret = ttsd_set_engine_type_set_cb(callback, user_data);
+ if (TTSD_ERROR_NONE != ret) {
+ SLOG(LOG_ERROR, tts_tag(), "[ERROR] Fail to set engine_type set cb. ret(%d/%s)", ret, get_error_message(ret));
+ }
+
+ return ret;
+}
\ No newline at end of file
int pitch;
double volume;
double background_volume;
+ string engine_type;
}
interface tts {
int finalize(in int uid);
int add_text(int uid, string text, string lang, int vctype, int speed, int uttid, string credential);
int add_silent_utterance(int uid, int duration_in_msec, int uttid, string credential);
- int add_text_with_synthesis_parameter(int uid, string text, string langauge, string ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume, int uttid, string credential);
+ int add_text_with_synthesis_parameter(int uid, string text, string langauge, string ptts_id, int voice_type, int speed, int pitch, double volume, double background_volume, string engine_type, int uttid, string credential);
int stop(in int uid);
int pause(in int uid);
int play_pcm(in int uid);