Change to TTS engine process
[platform/core/uifw/tts.git] / include / ttse.h
1 /*
2 *  Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3 *  Licensed under the Apache License, Version 2.0 (the "License");
4 *  you may not use this file except in compliance with the License.
5 *  You may obtain a copy of the License at
6 *  http://www.apache.org/licenses/LICENSE-2.0
7 *  Unless required by applicable law or agreed to in writing, software
8 *  distributed under the License is distributed on an "AS IS" BASIS,
9 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 *  See the License for the specific language governing permissions and
11 *  limitations under the License.
12 */
13
14
15 #ifndef __TTSE_H__
16 #define __TTSE_H__
17
18 #include <tizen.h>
19
20 /**
21 * @addtogroup CAPI_UIX_TTSE_MODULE
22 * @{
23 */
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /**
30 * @brief Enumerations for error codes.
31 * @since_tizen 3.0
32 */
33 typedef enum {
34         TTSE_ERROR_NONE                         = TIZEN_ERROR_NONE,                     /**< Successful */
35         TTSE_ERROR_OUT_OF_MEMORY                = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of Memory */
36         TTSE_ERROR_IO_ERROR                     = TIZEN_ERROR_IO_ERROR,                 /**< I/O error */
37         TTSE_ERROR_INVALID_PARAMETER            = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
38         TTSE_ERROR_NETWORK_DOWN                 = TIZEN_ERROR_NETWORK_DOWN,             /**< Out of network */
39         TTSE_ERROR_PERMISSION_DENIED            = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
40         TTSE_ERROR_INVALID_STATE                = TIZEN_ERROR_TTS | 0x01,               /**< Invalid state */
41         TTSE_ERROR_INVALID_VOICE                = TIZEN_ERROR_TTS | 0x02,               /**< Invalid voice */
42         TTSE_ERROR_OPERATION_FAILED             = TIZEN_ERROR_TTS | 0x04,               /**< Operation failed */
43         TTSE_ERROR_NOT_SUPPORTED_FEATURE        = TIZEN_ERROR_TTS | 0x06,               /**< Not supported feature */
44         TTSE_ERROR_NOT_SUPPORTED                = TIZEN_ERROR_NOT_SUPPORTED             /**< Not supported */
45 } ttse_error_e;
46
47 /**
48 * @brief Enumerations for audio type.
49 * @since_tizen 3.0
50 */
51 typedef enum {
52         TTSE_AUDIO_TYPE_RAW_S16 = 0,            /**< Signed 16-bit audio type */
53         TTSE_AUDIO_TYPE_RAW_U8,                 /**< Unsigned 8-bit audio type */
54         TTSE_AUDIO_TYPE_MAX
55 } ttse_audio_type_e;
56
57 /**
58 * @brief Enumerations for result event type.
59 * @since_tizen 3.0
60 */
61 typedef enum {
62         TTSE_RESULT_EVENT_FAIL          = -1,   /**< Event when the voice synthesis is failed */
63         TTSE_RESULT_EVENT_START         = 1,    /**< Event when the sound data is first data by callback function */
64         TTSE_RESULT_EVENT_CONTINUE      = 2,    /**< Event when the next sound data exist, not first and not last */
65         TTSE_RESULT_EVENT_FINISH        = 3             /**< Event when the sound data is last data or sound data is only one result */
66 } ttse_result_event_e;
67
68 /**
69 * @brief Definitions for male voice type.
70 * @since_tizen 3.0
71 */
72 #define TTSE_VOICE_TYPE_MALE    1
73
74 /**
75 * @brief Definitions for female voice type.
76 * @since_tizen 3.0
77 */
78 #define TTSE_VOICE_TYPE_FEMALE  2
79
80 /**
81 * @brief Definitions for child's voice type.
82 * @since_tizen 3.0
83 */
84 #define TTSE_VOICE_TYPE_CHILD   3
85
86
87 /**
88 * @brief Called when TTS engine informs the engine service user about whole supported language and voice type list.
89 * @details This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function.
90 * @since_tizen 3.0
91 *
92 * @remarks This callback function is called by ttse_foreach_supported_voices_cb() to inform the whole supported voice list.
93 *       @a user_data must be transferred from ttse_foreach_supported_voices_cb().
94 *
95 * @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
96 *       followed by ISO 639-1 for the two-letter language code. \n
97 *       For example, "ko_KR" for Korean, "en_US" for American English.
98 * @param[in] type The voice type
99 * @param[in] user_data The user data passed from ttse_foreach_supported_voices_cb()
100 *
101 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
102 *
103 * @pre ttse_foreach_supported_voices_cb() will invoke this callback function.
104 *
105 * @see ttse_foreach_supported_voices_cb()
106 */
107 typedef bool (*ttse_supported_voice_cb)(const char* language, int type, void* user_data);
108
109 /**
110 * @brief Called when the engine service user initializes TTS engine.
111 * @since_tizen 3.0
112 *
113 * @remarks This callback function is mandatory and must be registered using ttse_main().
114 *
115 * @return 0 on success, otherwise a negative error value
116 * @retval #TTSE_ERROR_NONE Successful
117 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
118 * @retval #TTSE_ERROR_INVALID_STATE Already initialized
119 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
120 * @retval #TTSE_ERROR_PERMISSION_DENIED Permission denied
121 *
122 * @see ttse_deinitialize_cb()
123 */
124 typedef int (*ttse_initialize_cb)(void);
125
126 /**
127 * @brief Called when the engine service user deinitializes TTS engine.
128 * @since_tizen 3.0
129 *
130 * @remarks This callback function is mandatory and must be registered using ttse_main().
131 *       NOTE that the engine may be terminated automatically.
132 *       When this callback function is invoked, the release of resources is necessary.
133 *
134 * @return 0 on success, otherwise a negative error value
135 * @retval #TTSE_ERROR_NONE Successful
136 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
137 *
138 * @see ttse_initialize_cb()
139 */
140 typedef int (*ttse_deinitialize_cb)(void);
141
142 /**
143 * @brief Called when the engine service user gets the whole supported voice list.
144 * @since_tizen 3.0
145 *
146 * @remarks This callback function is mandatory and must be registered using ttse_main().
147 *       In this function, the engine service user's callback function 'ttse_supported_voice_cb()' is invoked repeatedly for getting all supported voices, and @a user_data must be transferred to 'ttse_supported_voice_cb()'.
148 *       If 'ttse_supported_voice_cb()' returns @c false, it should be stopped to call 'ttse_supported_voice_cb()'.
149 *
150 *
151 * @param[in] callback The callback function
152 * @param[in] user_data The user data which must be passed to ttse_supported_voice_cb()
153 *
154 * @return 0 on success, otherwise a negative error value
155 * @retval #TTSE_ERROR_NONE Successful
156 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
157 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
158 *
159 * @post This callback function invokes ttse_supported_voice_cb() repeatedly for getting all supported voices.
160 *
161 * @see ttse_supported_voice_cb()
162 */
163 typedef int (*ttse_foreach_supported_voices_cb)(ttse_supported_voice_cb callback, void* user_data);
164
165 /**
166 * @brief Called when the engine service user checks whether the voice is valid or not in TTS engine.
167 * @since_tizen 3.0
168 *
169 * @remarks This callback function is mandatory and must be registered using ttse_main().
170 *
171 * @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
172 *       followed by ISO 639-1 for the two-letter language code. \n
173 *       For example, "ko_KR" for Korean, "en_US" for American English.
174 * @param[in] type The voice type
175 * @param[out] is_valid A variable for checking whether the corresponding voice is valid or not. \n @c true to be valid, @c false to be invalid.
176 *
177 * @return 0 on success, otherwise a negative error value
178 * @retval #TTSE_ERROR_NONE Successful
179 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
180 *
181 * @see ttse_foreach_supported_voices_cb()
182 */
183 typedef int (*ttse_is_valid_voice_cb)(const char* language, int type, bool* is_valid);
184
185 /**
186 * @brief Called when the engine service user sets the default pitch of TTS engine.
187 * @since_tizen 3.0
188 *
189 * @remarks This callback function is mandatory and must be registered using ttse_main().
190 *
191 * @param[in] pitch The default pitch
192 *
193 * @return 0 on success, otherwise a negative error value
194 * @retval #TTSE_ERROR_NONE Successful
195 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
196 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
197 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
198 */
199 typedef int (*ttse_set_pitch_cb)(int pitch);
200
201 /**
202 * @brief Called when the engine service user requests to load the corresponding voice type for the first time.
203 * @since_tizen 3.0
204 *
205 * @remarks This callback function is mandatory and must be registered using ttse_main().
206 *
207 * @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
208 *       followed by ISO 639-1 for the two-letter language code. \n
209 *       For example, "ko_KR" for Korean, "en_US" for American English.
210 * @param[in] type The voice type
211 *
212 * @return 0 on success, otherwise a negative error value
213 * @retval #TTSE_ERROR_NONE Successful
214 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
215 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
216 * @retval #TTSE_ERROR_OUT_OF_MEMORY Out of memory
217 * @retval #TTSE_ERROR_INVALID_VOICE Invalid voice
218 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
219 *
220 * @see ttse_unload_voice_cb()
221 */
222 typedef int (*ttse_load_voice_cb)(const char* language, int type);
223
224 /**
225 * @brief Called when the engine service user requests to unload the corresponding voice type or to stop using voice.
226 * @since_tizen 3.0
227 *
228 * @remarks This callback function is mandatory and must be registered using ttse_main().
229 *
230 * @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
231 *       followed by ISO 639-1 for the two-letter language code. \n
232 *       For example, "ko_KR" for Korean, "en_US" for American English.
233 * @param[in] type The voice type
234 *
235 * @return 0 on success, otherwise a negative error value
236 * @retval #TTSE_ERROR_NONE Successful
237 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
238 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
239 * @retval #TTSE_ERROR_INVALID_VOICE Invalid voice
240 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
241 *
242 * @see ttse_load_voice_cb()
243 */
244 typedef int (*ttse_unload_voice_cb)(const char* language, int type);
245
246 /**
247 * @brief Called when the engine service user requests for TTS engine to check whether the application agreed the usage of TTS engine.
248 * @details This callback function is called when the engine service user requests for TTS engine to check the application's agreement about using the engine.
249 *       According to the need, the engine developer can provide some user interfaces to check the agreement.
250 * @since_tizen 3.0
251 *
252 * @remarks This callback function is mandatory and must be registered using ttse_main().
253 *       If the TTS engine developer wants not to check the agreement, the developer has need to return proper values as @a is_agreed in accordance with the intention. \n @c true if the developer regards that every application agreed the usage of the engine, @c false if the developer regards that every application disagreed.
254 *       NOTE that, however, there may be any legal issue unless the developer checks the agreement. Therefore, we suggest that the engine developers should provide a function to check the agreement.
255 *
256 * @param[in] appid The Application ID
257 * @param[out] is_agreed A variable for checking whether the application agreed to use TTS engine or not. \n @c true to agree, @c false to disagree.
258 *
259 * @return 0 on success, otherwise a negative error value
260 * @retval #TTSE_ERROR_NONE Successful
261 * @retval #TTSE_ERROR_INVALID_STATE Not initialized
262 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
263 * @retval #TTSE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
264 */
265 typedef int (*ttse_check_app_agreed_cb)(const char* appid, bool* is_agreed);
266
267 /**
268 * @brief Called when the engine service user checks whether TTS engine needs the application's credential.
269 * @since_tizen 3.0
270 *
271 * @remarks This callback function is mandatory and must be registered using ttse_main().
272 *
273 * @return @c true if TTS engine needs the application's credential, otherwise @c false
274 */
275 typedef bool (*ttse_need_app_credential_cb)(void);
276
277 /**
278 * @brief Called when the engine service user starts to synthesize a voice, asynchronously.
279 * @since_tizen 3.0
280 *
281 * @remarks This callback function is mandatory and must be registered using ttse_main().
282 *       In this callback function, TTS engine must transfer the synthesized result and @a user_data to the engine service user using ttse_send_result().
283 *       Also, if TTS engine needs the application's credential, it can set the credential granted to the application.
284 *
285 * @param[in] language The language is specified as an ISO 3166 alpha-2 two-letter country code
286 *       followed by ISO 639-1 for the two-letter language code. \n
287 *       For example, "ko_KR" for Korean, "en_US" for American English.
288 * @param[in] type The voice type
289 * @param[in] text Texts
290 * @param[in] speed The speed of speaking
291 * @param[in] appid The Application ID
292 * @param[in] credential The credential granted to the application
293 * @param[in] user_data The user data which must be passed to ttse_send_result()
294 *
295 * @return 0 on success, otherwise a negative error value
296 * @retval #TTSE_ERROR_NONE Successful
297 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
298 * @retval #TTSE_ERROR_INVALID_STATE Not initialized or already started synthesis
299 * @retval #TTSE_ERROR_INVALID_VOICE Invalid voice
300 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
301 * @retval #TTSE_ERROR_NETWORK_DOWN Out of network
302 * @retval #TTSE_ERROR_PERMISSION_DENIED Permission denied
303 *
304 * @post This function invokes ttse_send_result().
305 *
306 * @see ttse_send_result()
307 * @see ttse_cancel_synthesis_cb()
308 * @see ttse_need_app_credential_cb()
309 */
310 typedef int (*ttse_start_synthesis_cb)(const char* language, int type, const char* text, int speed, const char* appid, const char* credential, void* user_data);
311
312 /**
313 * @brief Called when the engine service user cancels to synthesize a voice.
314 * @since_tizen 3.0
315 *
316 * @remarks This callback function is mandatory and must be registered using ttse_main().
317 *
318 * @return 0 on success, otherwise a negative error value
319 * @retval #TTSE_ERROR_NONE Successful
320 * @retval #TTSE_ERROR_INVALID_STATE Not initialized or not started synthesis
321 *
322 * @pre The ttse_start_synthesis_cb() should be performed
323 *
324 * @see ttse_start_synthesis_cb()
325 */
326 typedef int (*ttse_cancel_synthesis_cb)(void);
327
328 /**
329 * @brief Called when the engine service user requests the basic information of TTS engine.
330 * @since_tizen 3.0
331 *
332 * @remarks This callback function is mandatory and must be registered using ttse_main().
333 *       The allocated @a engine_uuid, @a engine_name, and @a engine_setting will be released internally.
334 *       In order to upload the engine at Tizen Appstore, both a service app and a ui app are necessary.
335 *       Therefore, @a engine_setting must be transferred to the engine service user.
336 *
337 * @param[out] engine_uuid UUID of engine
338 * @param[out] engine_name Name of engine
339 * @param[out] engine_setting The engine setting application(ui app)'s app id
340 * @param[out] use_network The status for using network
341 *
342 * @return 0 on success, otherwise a negative error code on failure
343 * @retval #TTSE_ERROR_NONE Successful
344 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
345 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
346 *
347 */
348 typedef int (*ttse_get_info_cb)(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
349
350 /**
351 * @brief Called when TTS engine receives the private data from the engine service user.
352 * @details This callback function is called when the engine service user sends the private data to TTS engine.
353 * @since_tizen 3.0
354 *
355 * @remarks This callback function is optional and is registered using ttse_set_private_data_set_cb().
356 *
357 * @param[in] key The key field of private data.
358 * @param[in] data The data field of private data.
359 *
360 * @return 0 on success, otherwise a negative error value
361 * @retval #TTSE_ERROR_NONE Successful
362 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
363 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
364 * @retval #TTSE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
365 *
366 * @see ttse_private_data_requested_cb()
367 * @see ttse_set_private_data_set_cb()
368 */
369 typedef int (*ttse_private_data_set_cb)(const char* key, const char* data);
370
371 /**
372 * @brief Called when TTS engine provides the engine service user with the private data.
373 * @details This callback function is called when the engine service user gets the private data from TTS engine.
374 * @since_tizen 3.0
375 *
376 * @remarks This callback function is optional and is registered using ttse_set_private_data_requested_cb().
377 *
378 * @param[out] key The key field of private data.
379 * @param[out] data The data field of private data.
380 *
381 * @return 0 on success, otherwise a negative error value
382 * @retval #TTSE_ERROR_NONE Successful
383 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
384 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
385 * @retval #TTSE_ERROR_NOT_SUPPORTED_FEATURE Not supported feature
386 *
387 * @see ttse_private_data_set_cb()
388 * @see ttse_set_private_data_requested_cb()
389 */
390 typedef int (*ttse_private_data_requested_cb)(const char* key, char** data);
391
392
393 /**
394 * @brief A structure for the TTS engine functions.
395 * @details This structure contains essential callback functions for operating TTS engine.
396 * @since_tizen 3.0
397 *
398 * @remarks These functions are mandatory for operating TTS engine. Therefore, all functions MUST be implemented.
399 */
400 typedef struct {
401         int version;                                                    /**< The version of the structure 'ttse_request_callback_s' */
402         ttse_get_info_cb                        get_info;               /**< Called when the engine service user requests the basic information of TTS engine */
403
404         ttse_initialize_cb                      initialize;             /**< Called when the engine service user initializes TTS engine */
405         ttse_deinitialize_cb                    deinitialize;           /**< Called when the engine service user deinitializes TTS engine */
406
407         ttse_foreach_supported_voices_cb        foreach_voices;         /**< Called when the engine service user gets the whole supported voice list */
408         ttse_is_valid_voice_cb                  is_valid_voice;         /**< Called when the engine service user checks whether the voice is valid or not in TTS engine */
409         ttse_set_pitch_cb                       set_pitch;              /**< Called when the engine service user sets the default pitch of TTS engine */
410
411         ttse_load_voice_cb                      load_voice;             /**< Called when the engine service user requests to load the corresponding voice type for the first time */
412         ttse_unload_voice_cb                    unload_voice;           /**< Called when the engine service user requests to unload the corresponding voice type or to stop using voice */
413
414         ttse_start_synthesis_cb                 start_synth;            /**< Called when the engine service user starts to synthesize a voice, asynchronously */
415         ttse_cancel_synthesis_cb                cancel_synth;           /**< Called when the engine service user cancels to synthesize a voice */
416
417         ttse_check_app_agreed_cb                check_app_agreed;       /**< Called when the engine service user requests for TTS engine to check whether the application agreed the usage of TTS engine */ 
418         ttse_need_app_credential_cb             need_app_credential;    /**< Called when the engine service user checks whether TTS engine needs the application's credential */
419 } ttse_request_callback_s;
420
421 /**
422 * @brief Main function for Text-To-Speech (TTS) engine.
423 * @details This function is the main function for operating TTS engine.
424 *
425 * @since_tizen 3.0
426 *
427 * @remarks The service_app_main() should be used for working the engine after this function.
428 *
429 * @param[in] argc The argument count(original)
430 * @param[in] argv The argument(original)
431 * @param[in] callback The structure of engine request callback function
432 *
433 * @return This function returns zero on success, or negative with error code on failure
434 * @retval #TTSE_ERROR_NONE Successful
435 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
436 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
437 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
438 *
439 * @see ttse_request_callback_s
440 *
441 * @code
442 #include <ttse.h>
443
444 // Required callback functions - MUST BE IMPLEMENTED
445 static int ttsengine_get_info_cb(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network);
446 static int ttsengine_initialize_cb(void);
447 static int ttsengine_deinitialize_cb(void);
448 static int ttsengine_is_valid_voice_cb(const char* language, int type, bool* is_valid);
449 static int ttsengine_foreach_supported_voices_cb(ttse_supported_voice_cb callback, void* user_data);
450 static int ttsengine_set_pitch_cb(int pitch);
451 static int ttsengine_load_voice_cb(const char* language, int type);
452 static int ttsengine_unload_voice_cb(const char* language, int type);
453 static int ttsengine_start_synthesis_cb(const char* language, int type, const char* text, int speed, void* user_data);
454 static int ttsengine_cancel_synthesis_cb(void);
455 static int ttsengine_check_app_agreed_cb(const char* appid, bool* is_agreed);
456 static bool ttsengine_need_app_credential_cb(void);
457
458 // Optional callback function
459 static int ttsengine_private_data_set_cb(const char* key, const char* data);
460
461 int main(int argc, char* argv[])
462 {
463         // 1. Create a structure 'ttse_request_callback_s'
464         ttse_request_callback_s engine_callback = { 0, };
465
466         engine_callback.size = sizeof(ttse_request_callback_s);
467         engine_callback.version = 1;
468         engine_callback.get_info = ttsengine_get_info_cb;
469         engine_callback.initialize = ttsengine_initialize_cb;
470         engine_callback.deinitialize = ttsengine_deinitialize_cb;
471         engine_callback.foreach_voices = ttsengine_foreach_supported_voices_cb;
472         engine_callback.is_valid_voice = ttsengine_is_valid_voice_cb;
473         engine_callback.set_pitch = ttsengine_set_pitch_cb;
474         engine_callback.load_voice = ttsengine_load_voice_cb;
475         engine_callback.unload_voice = ttsengine_unload_voice_cb;
476         engine_callback.start_synth = ttsengine_start_synthesis_cb;
477         engine_callback.cancel_synth = ttsengine_cancel_synthesis_cb;
478         engine_callback.check_app_agreed = ttsengine_check_app_agreed_cb;
479         engine_callback.need_app_credential = ttsengine_need_app_credential_cb;
480
481         // 2. Run 'ttse_main()'
482         if (0 != ttse_main(argc, argv, &engine_callback)) {
483                 return -1;
484         }
485
486         // Optional
487         ttse_set_private_data_set_cb(ttsengine_private_data_set_cb);
488
489         // 3. Set event callbacks for service app and Run 'service_app_main()'
490         char ad[50] = { 0, };
491
492         service_app_lifecycle_callback_s event_callback;
493         app_event_handler_h handlers[5] = { NULL, };
494
495         event_callback.create = service_app_create;
496         event_callback.terminate = service_app_terminate;
497         event_callback.app_control = service_app_control;
498
499         service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad);
500         service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad);
501         service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad);
502         service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad);
503
504         return service_app_main(argc, argv, &event_callback, ad);
505 }
506
507 * @endcode
508 */
509 int ttse_main(int argc, char** argv, ttse_request_callback_s *callback);
510
511 /**
512 * @brief Gets the speed range from Tizen platform.
513 * @since_tizen 3.0
514 *
515 * @remarks This API is used when TTS engine wants to get the speed range from Tizen platform.
516 *
517 * @param[out] min The minimum speed value
518 * @param[out] normal The normal speed value
519 * @param[out] max The maximum speed value
520 *
521 * @return 0 on success, otherwise a negative error value
522 * @retval #TTSE_ERROR_NONE Successful
523 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
524 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
525 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
526 *
527 */
528 int ttse_get_speed_range(int* min, int* normal, int* max);
529
530 /**
531 * @brief Gets the pitch range from Tizen platform.
532 * @since_tizen 3.0
533 *
534 * @remarks This API is used when TTS engine wants to get the pitch range from Tizen platform.
535 *
536 * @param[out] min The minimum pitch value
537 * @param[out] normal The normal pitch value
538 * @param[out] max The maximum pitch value
539 *
540 * @return 0 on success, otherwise a negative error value
541 * @retval #TTSE_ERROR_NONE Successful
542 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
543 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
544 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
545 *
546 */
547 int ttse_get_pitch_range(int* min, int* normal, int* max);
548
549 /**
550 * @brief Sends the synthesized result to the engine service user.
551 * @since_tizen 3.0
552 *
553 * @remarks This API is used in ttse_start_synthesis_cb(), when TTS engine sends the synthesized result to the engine service user.
554 *       The synthesized result and @a user_data must be transferred to the engine service user through this function.
555 *
556 * @param[in] event The result event
557 * @param[in] data Result data
558 * @param[in] data_size Result data size
559 * @param[in] audio_type The audio type
560 * @param[in] rate The sample rate
561 * @param[in] user_data The user data passed from ttse_start_synthesis_cb()
562 *
563 * @return 0 on success, otherwise a negative error value
564 * @retval #TTSE_ERROR_NONE Successful
565 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
566 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
567 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
568 *
569 * @pre The ttse_main() function should be invoked before this function is called.
570 *       ttse_start_synthesis_cb() will invoke this function.
571 *
572 * @see ttse_start_synthesis_cb()
573 */
574 int ttse_send_result(ttse_result_event_e event, const void* data, unsigned int data_size,
575                         ttse_audio_type_e audio_type, int rate, void* user_data);
576
577 /**
578 * @brief Sends the error to the engine service user.
579 * @details The following error codes can be delivered.\n
580 *       #TTSE_ERROR_NONE,\n
581 *       #TTSE_ERROR_OUT_OF_MEMORY,\n
582 *       #TTSE_ERROR_IO_ERROR,\n
583 *       #TTSE_ERROR_INVALID_PARAMETER,\n
584 *       #TTSE_ERROR_NETWORK_DOWN,\n
585 *       #TTSE_ERROR_PERMISSION_DENIED,\n
586 *       #TTSE_ERROR_INVALID_STATE,\n
587 *       #TTSE_ERROR_INVALID_VOICE,\n
588 *       #TTSE_ERROR_OPERATION_FAILED,\n
589 *       #TTSE_ERROR_NOT_SUPPORTED_FEATURE,\n
590 *       #TTSE_ERROR_NOT_SUPPORTED.\n
591 *
592 * @since_tizen 3.0
593
594 * @param[in] error The error reason
595 * @param[in] msg The error message
596 *
597 * @return 0 on success, otherwise a negative error value
598 * @retval #TTSE_ERROR_NONE Successful
599 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
600 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
601 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
602 *
603 * @pre The ttse_main() function should be invoked before this function is called.
604 */
605 int ttse_send_error(ttse_error_e error, const char* msg);
606
607 /**
608 * @brief Sets a callback function for setting the private data.
609 * @since_tizen 3.0
610 *
611 * @remarks The ttse_private_data_set_cb() function is called when the engine service user sends the private data.
612 *
613 * @param[in] callback_func ttse_private_data_set event callback function
614 *
615 * @return 0 on success, otherwise a negative error value
616 * @retval #TTSE_ERROR_NONE Successful
617 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
618 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
619 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
620 *
621 * @pre The ttse_main() function should be invoked before this function is called.
622 *
623 * @see ttse_private_data_set_cb()
624 */
625 int ttse_set_private_data_set_cb(ttse_private_data_set_cb callback_func);
626
627 /**
628 * @brief Sets a callback function for requesting the private data.
629 * @since_tizen 3.0
630 *
631 * @remarks The ttse_private_data_requested_cb() function is called when the engine service user gets the private data from TTS engine.
632 *
633 * @param[in] callback_func ttse_private_data_requested event callback function
634 *
635 * @return 0 on success, otherwise a negative error value
636 * @retval #TTSE_ERROR_NONE Successful
637 * @retval #TTSE_ERROR_INVALID_PARAMETER Invalid parameter
638 * @retval #TTSE_ERROR_NOT_SUPPORTED Not supported
639 * @retval #TTSE_ERROR_OPERATION_FAILED Operation failure
640 *
641 * @pre The ttse_main() function should be invoked before this function is called.
642 *
643 * @see ttse_private_data_requested_cb()
644 */
645 int ttse_set_private_data_requested_cb(ttse_private_data_requested_cb callback_func);
646
647
648
649 #ifdef __cplusplus
650 }
651 #endif
652
653 #endif /* __TTSE_H__ */