3 * Copyright 2012 Samsung Electronics Co., Ltd
\r
5 * Licensed under the Flora License, Version 1.0 (the License);
\r
6 * you may not use this file except in compliance with the License.
\r
7 * You may obtain a copy of the License at
\r
9 * http://floralicense.org/license/
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an AS IS BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
21 #include "plugin_internal.h"
\r
22 #include "_SlpSmtApis.h"
\r
25 // Once eigine was initialize, that means gpDaemonAPIs and its members are not NULL.
\r
26 // So we do not need to check whether this is NULL, nor its members are NULL.
\r
27 static ttspd_funcs_s const * gpDaemonAPIs = NULL;
\r
30 int plugin_Initialize(ttspe_result_cb const pfnCallBack)
\r
32 int r = SLPSMT_Initialize(pfnCallBack);
\r
33 printf(">>>plugin Initialize() returns %d.\n", r);
\r
37 int plugin_Finalize(void)
\r
39 int r = SLPSMT_Finalize();
\r
40 printf(">>>plugin Initialize() returns %d.\n", r);
\r
44 int plugin_SynthesizeText(char* const pszLanguage, ttsp_voice_type_e eVoiceType_0, char const * pszTextUtf8,
\r
45 ttsp_speed_e eSpeechSpeed_0, void* pUserParam)
\r
47 int iVoiceInfo = -1;
\r
48 ttsp_voice_type_e eVoiceType = eVoiceType_0;
\r
49 ttsp_speed_e eSpeechSpeed = eSpeechSpeed_0;
\r
51 int ThreadId = SLPSMT_GetWorkingThreadId();
\r
52 printf(">>>plugin SynthesizeText()\n");
\r
55 printf(">>> A new text is comming into the TTS engine, while Synthesizing.\n");
\r
56 printf(">>> The text would be pushed into the thread queue.\n");
\r
58 printf(">>> ThreadId = %d\n", ThreadId);
\r
59 printf(">>> pUserParam = 0x%x\n", (unsigned int) pUserParam);
\r
61 printf(">>> eSpeechSpeed = %s\n", //eSpeechSpeed==TTSPE_SPEED_DEFAULT ? "TTSPE_SPEED_DEFAULT" :
\r
62 eSpeechSpeed==TTSP_SPEED_VERY_FAST ? "TTSP_SPEED_VERY_FAST" :
\r
63 eSpeechSpeed==TTSP_SPEED_FAST ? "TTSP_SPEED_FAST" :
\r
64 eSpeechSpeed==TTSP_SPEED_NORMAL ? "TTSP_SPEED_NORMAL" :
\r
65 eSpeechSpeed==TTSP_SPEED_SLOW ? "TTSP_SPEED_SLOW" :
\r
66 eSpeechSpeed==TTSP_SPEED_VERY_SLOW ? "TTSP_SPEED_VERY_SLOW" : ""
\r
68 printf(">>> pszLanguage = %s\n", pszLanguage);
\r
69 printf(">>> eVoiceType = %s\n", //eVoiceType==TTSPE_VCTYPE_DEFAULT ? "TTSPE_VCTYPE_DEFAULT" :
\r
70 eVoiceType==TTSP_VOICE_TYPE_MALE ? "TTSP_VOICE_TYPE_MALE" :
\r
71 eVoiceType==TTSP_VOICE_TYPE_FEMALE ? "TTSP_VOICE_TYPE_FEMALE" :
\r
72 eVoiceType==TTSP_VOICE_TYPE_CHILD ? "TTSP_VOICE_TYPE_CHILD" :
\r
73 eVoiceType==TTSP_VOICE_TYPE_USER1 ? "TTSP_VOICE_TYPE_USER1" :
\r
74 eVoiceType==TTSP_VOICE_TYPE_USER2 ? "TTSP_VOICE_TYPE_USER2" :
\r
75 eVoiceType==TTSP_VOICE_TYPE_USER3 ? "TTSP_VOICE_TYPE_USER3" : ""
\r
78 SLPSMT_SetSpeechSpeed(eSpeechSpeed);
\r
81 printf(">>> eSpeechSpeed = %s\n", //eSpeechSpeed==TTSP_SPEED_DEFAULT ? "TTSPE_SPEED_DEFAULT" :
\r
82 eSpeechSpeed==TTSP_SPEED_VERY_FAST ? "TTSPE_SPEED_VERY_FAST" :
\r
83 eSpeechSpeed==TTSP_SPEED_FAST ? "TTSPE_SPEED_FAST" :
\r
84 eSpeechSpeed==TTSP_SPEED_NORMAL ? "TTSPE_SPEED_NORMAL" :
\r
85 eSpeechSpeed==TTSP_SPEED_SLOW ? "TTSPE_SPEED_SLOW" :
\r
86 eSpeechSpeed==TTSP_SPEED_VERY_SLOW ? "TTSPE_SPEED_VERY_SLOW" : ""
\r
88 printf(">>> pszLanguage = %s\n", pszLanguage);
\r
89 printf(">>> eVoiceType = %s\n", //eVoiceType==TTSPE_VCTYPE_DEFAULT ? "TTSPE_VCTYPE_DEFAULT" :
\r
90 eVoiceType==TTSP_VOICE_TYPE_MALE ? "TTSPE_VCTYPE_MALE" :
\r
91 eVoiceType==TTSP_VOICE_TYPE_FEMALE ? "TTSPE_VCTYPE_FEMALE" :
\r
92 eVoiceType==TTSP_VOICE_TYPE_CHILD ? "TTSPE_VCTYPE_CHILD" :
\r
93 eVoiceType==TTSP_VOICE_TYPE_USER1 ? "TTSPE_VCTYPE_USER1" :
\r
94 eVoiceType==TTSP_VOICE_TYPE_USER2 ? "TTSPE_VCTYPE_USER2" :
\r
95 eVoiceType==TTSP_VOICE_TYPE_USER3 ? "TTSPE_VCTYPE_USER3" : ""
\r
99 iVoiceInfo = SLPSMT_GetiVoiceInfo(pszLanguage, eVoiceType);
\r
100 if (iVoiceInfo < 0)
\r
102 printf("iVoiceInfo < 0\n");
\r
103 return TTSP_ERROR_INVALID_VOICE;
\r
106 return SLPSMT_SynthesizeText(iVoiceInfo, pszTextUtf8, pUserParam);
\r
109 int plugin_StopSynthesis(void)
\r
111 return SLPSMT_StopSynthesis();
\r
114 int plugin_GetAudioFormat(ttsp_audio_type_e* pType, int* pSamplingRate, int* pnChannels)
\r
116 if (pType && pSamplingRate && pnChannels)
\r
118 *pSamplingRate = 16000;
\r
120 *pType = TTSP_AUDIO_TYPE_RAW;
\r
121 return TTSP_ERROR_NONE;
\r
123 return TTSP_ERROR_INVALID_PARAMETER;
\r
129 int plugin_ForeachVoices(ttspe_supported_voice_cb callback, void* user_data)
\r
131 if(NULL == callback)
\r
132 return TTSP_ERROR_INVALID_PARAMETER;
\r
134 ttspe_voice_list_s pVoiceList;
\r
135 SLPSMT_SetVoiceList(&pVoiceList);
\r
139 ttspe_voice_info_s* temp = pVoiceList.voice_info;
\r
141 for(i=0 ; i < pVoiceList.size; i++)
\r
143 if (false == callback(temp[i].lang, temp[i].vctype, user_data))
\r
145 printf(">> plugin_ForeachVoices(), callback fail!!\n");
\r
150 return TTSP_ERROR_NONE;
\r
153 bool plugin_IsValidVoice(const char* language, ttsp_voice_type_e type)
\r
155 if (NULL == language)
\r
156 return TTSP_ERROR_INVALID_PARAMETER;
\r
158 int iVoiceInfo = SLPSMT_GetiVoiceInfo((char* )language, type);
\r
160 if (iVoiceInfo < 0)
\r
162 printf("iVoiceInfo < 0\n");
\r
169 int plugin_SetSettingInfo(const char* key, const char* value)
\r
171 if (NULL == key || NULL == value) {
\r
172 return TTSP_ERROR_INVALID_PARAMETER;
\r
175 printf("Set engine setting : key(%s) value(%s)\n", key, value);
\r
177 return TTSP_ERROR_NONE;
\r
180 int plugin_ForeachEngineSetting(ttspe_engine_setting_cb callback, void* user_data)
\r
182 if (false == callback("Sample_key1", "Sample_value1", user_data))
\r
183 return TTSP_ERROR_NONE;
\r
185 if (false == callback("Sample_key2", "Sample_value2", user_data))
\r
186 return TTSP_ERROR_NONE;
\r
188 return TTSP_ERROR_NONE;
\r
191 void plugin_SetDaemonAPIs(ttspd_funcs_s const * pAPIs)
\r
193 gpDaemonAPIs = pAPIs;
\r