Add g_steal_pointer to avoid double-free
[platform/core/uifw/tts.git] / include / tts.h
1 /*
2  * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __TTS_H__
19 #define __TTS_H__
20
21
22 #include <tizen.h>
23
24
25 /**
26 * @file tts.h
27 */
28
29
30 /**
31 * @addtogroup CAPI_UIX_TTS_MODULE
32 * @{
33 */
34
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40
41 /**
42  * @brief Enumeration for error code.
43  * @since_tizen 2.3
44 */
45 typedef enum {
46         TTS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
47         TTS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
48         TTS_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
49         TTS_ERROR_INVALID_PARAMETER     = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
50         TTS_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Network is down */
51         TTS_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */
52         TTS_ERROR_PERMISSION_DENIED     = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */
53         TTS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< TTS NOT supported */
54         TTS_ERROR_INVALID_STATE = TIZEN_ERROR_TTS | 0x01, /**< Invalid state */
55         TTS_ERROR_INVALID_VOICE = TIZEN_ERROR_TTS | 0x02, /**< Invalid voice */
56         TTS_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_TTS | 0x03, /**< No available engine */
57         TTS_ERROR_OPERATION_FAILED = TIZEN_ERROR_TTS | 0x04, /**< Operation failed */
58         TTS_ERROR_AUDIO_POLICY_BLOCKED = TIZEN_ERROR_TTS | 0x05, /**< Audio policy blocked */
59         TTS_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_TTS | 0x06, /**< Not supported feature of current engine (Since 3.0) */
60         TTS_ERROR_SERVICE_RESET = TIZEN_ERROR_TTS | 0x07, /**< Service reset (Since 3.0) */
61         TTS_ERROR_SCREEN_READER_OFF = TIZEN_ERROR_TTS | 0x08 /**< Screen reader is off (Since 6.5) */
62 } tts_error_e;
63
64
65 /**
66  * @brief Enumeration for TTS mode.
67  * @since_tizen 2.3
68 */
69 typedef enum {
70         TTS_MODE_DEFAULT = 0, /**< Default mode for normal application */
71         TTS_MODE_NOTIFICATION = 1, /**< Notification mode */
72         TTS_MODE_SCREEN_READER = 2 /**< Accessibility mode */
73 } tts_mode_e;
74
75
76 /**
77  * @brief Enumeration for state.
78  * @since_tizen 2.3
79 */
80 typedef enum {
81         TTS_STATE_CREATED = 0, /**< 'CREATED' state */
82         TTS_STATE_READY = 1, /**< 'READY' state */
83         TTS_STATE_PLAYING = 2, /**< 'PLAYING' state */
84         TTS_STATE_PAUSED = 3 /**< 'PAUSED' state*/
85 } tts_state_e;
86
87
88 /**
89  * @brief Enumeration for service state.
90  * @since_tizen 7.0
91 */
92 typedef enum {
93         TTS_SERVICE_STATE_NONE = -1, /**< 'None' state (Since 8.0) */
94         TTS_SERVICE_STATE_READY = 0, /**< 'Ready' state */
95         TTS_SERVICE_STATE_SYNTHESIZING, /**< 'Synthesizing' state */
96         TTS_SERVICE_STATE_PLAYING, /**< 'Playing' state */
97         TTS_SERVICE_STATE_BLOCKED /**< 'Blocked' state (Since 8.0) */
98 } tts_service_state_e;
99
100
101 /**
102  * @brief Enumeration for playing mode of TTS.
103  * @since_tizen 8.0
104 */
105 typedef enum {
106         TTS_PLAYING_MODE_BY_SERVICE = 0, /**< Mode for TTS playing on TTS service */
107         TTS_PLAYING_MODE_BY_CLIENT = 1, /**< Mode for TTS playing on TTS client */
108 } tts_playing_mode_e;
109
110
111 /**
112  * @brief Enumeration for audio type.
113  * @since_tizen 8.0
114  */
115 typedef enum {
116         TTS_AUDIO_TYPE_RAW_S16 = 0, /**< Signed 16-bit audio type */
117         TTS_AUDIO_TYPE_RAW_U8 /**< Unsigned 8-bit audio type */
118 } tts_audio_type_e;
119
120
121 /**
122  * @brief Enumeration for synthesized pcm event.
123  * @since_tizen 8.0
124 */
125 typedef enum {
126         TTS_SYNTHESIZED_PCM_EVENT_FAIL = -1, /**< Event when the synthesized PCM is failed */
127         TTS_SYNTHESIZED_PCM_EVENT_START = 1, /**< Event when the synthesized PCM is received at first */
128         TTS_SYNTHESIZED_PCM_EVENT_CONTINUE = 2, /**< Event when the synthesized PCM is received, not first and not last */
129         TTS_SYNTHESIZED_PCM_EVENT_FINISH = 3 /**< Event when the synthesized PCM is received finally */
130 } tts_synthesized_pcm_event_e;
131
132
133 /**
134  * @brief Definition for automatic speaking speed.
135  * @since_tizen 2.3
136 */
137 #define TTS_SPEED_AUTO          0
138
139
140 /**
141  * @brief Definition for automatic speaking pitch.
142  * @since_tizen 9.0
143 */
144 #define TTS_PITCH_AUTO          0
145
146
147 /**
148  * @brief Definition for automatic speaking volume.
149  * @since_tizen 9.0
150 */
151 #define TTS_VOLUME_AUTO         0
152
153
154 /**
155  * @brief Definition for automatic voice type.
156  * @since_tizen 2.3
157 */
158 #define TTS_VOICE_TYPE_AUTO     0
159
160
161 /**
162  * @brief Definition for male voice type.
163  * @since_tizen 2.3
164 */
165 #define TTS_VOICE_TYPE_MALE     1
166
167
168 /**
169  * @brief Definition for female voice type.
170  * @since_tizen 2.3
171 */
172 #define TTS_VOICE_TYPE_FEMALE   2
173
174
175 /**
176  * @brief Definition for child voice type.
177  * @since_tizen 2.3
178 */
179 #define TTS_VOICE_TYPE_CHILD    3
180
181
182 /**
183  * @brief Definition for personal voice type.
184  * @since_tizen 9.0
185 */
186 #define TTS_VOICE_TYPE_PERSONAL  4
187
188
189 /**
190  * @brief The TTS handle.
191  * @since_tizen 2.3
192 */
193 typedef struct tts_s *tts_h;
194
195
196 /**
197  * @brief The TTS synthesis parameter handle.
198  * @since_tizen 9.0
199 */
200 typedef struct tts_synthesis_parameter_s *tts_synthesis_parameter_h;
201
202
203 /**
204  * @brief Called when the state of TTS is changed.
205  * @details If the daemon must stop player because of changing engine and
206  *          the daemon must pause player because of other requests, this callback function is called.
207  * @since_tizen 2.3
208  * @param[in] tts The TTS handle
209  * @param[in] previous The previous state
210  * @param[in] current The current state
211  * @param[in] user_data The user data passed from the callback registration function
212  * @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
213  * @see tts_set_state_changed_cb()
214  * @see tts_unset_state_changed_cb()
215 */
216 typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
217
218
219 /**
220  * @brief Called when utterance has started.
221  * @since_tizen 2.3
222  * @param[in] tts The TTS handle
223  * @param[in] utt_id The utterance ID passed from the add text function
224  * @param[in] user_data The user data passed from the callback registration function
225  * @pre An application registers this callback using tts_set_utterance_started_cb() to detect utterance started.
226  * @see tts_add_text()
227  * @see tts_set_utterance_started_cb()
228  * @see tts_unset_utterance_started_cb()
229 */
230 typedef void (*tts_utterance_started_cb)(tts_h tts, int utt_id, void* user_data);
231
232
233 /**
234  * @brief Called when utterance is finished.
235  * @since_tizen 2.3
236  * @param[in] tts The TTS handle
237  * @param[in] utt_id The utterance ID passed from the add text function
238  * @param[in] user_data The user data passed from the callback registration function
239  * @pre An application registers this callback using tts_set_utterance_completed_cb() to detect utterance completed.
240  * @see tts_add_text()
241  * @see tts_set_utterance_completed_cb()
242  * @see tts_unset_utterance_completed_cb()
243 */
244 typedef void (*tts_utterance_completed_cb)(tts_h tts, int utt_id, void *user_data);
245
246
247 /**
248  * @brief Called when an error occurs.
249  * @since_tizen 2.3
250  * @param[in] tts The TTS handle
251  * @param[in] utt_id The utterance ID passed from the add text function
252  * @param[in] reason The error code
253  * @param[in] user_data The user data passed from the callback registration function
254  * @pre An application registers this callback using tts_set_error_cb() to detect error.
255  * @see tts_play()
256  * @see tts_pause()
257  * @see tts_stop()
258  * @see tts_set_error_cb()
259  * @see tts_unset_error_cb()
260 */
261 typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* user_data);
262
263
264 /**
265  * @brief Called to retrieve the supported voice.
266  * @since_tizen 2.3
267  * @param[in] tts The TTS handle
268  * @param[in] language Language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
269  * @param[in] voice_type A voice type (e.g. #TTS_VOICE_TYPE_MALE, #TTS_VOICE_TYPE_FEMALE)
270  * @param[in] user_data The user data passed from the foreach function
271  * @return @c true to continue with the next iteration of the loop,
272  *         @c false to break out of the loop
273  * @pre tts_foreach_supported_voices() will invoke this callback function.
274  * @see tts_foreach_supported_voices()
275 */
276 typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, int voice_type, void* user_data);
277
278
279 /**
280  * @brief Called when the default voice is changed.
281  * @since_tizen 2.3
282  * @param[in] tts The TTS handle
283  * @param[in] previous_language The previous language
284  * @param[in] previous_voice_type The previous voice type
285  * @param[in] current_language The current language
286  * @param[in] current_voice_type The current voice type
287  * @param[in] user_data The user data passed from the callback registration function
288  * @see tts_set_default_voice_changed_cb()
289 */
290 typedef void (*tts_default_voice_changed_cb)(tts_h tts, const char* previous_language, int previous_voice_type,
291                                 const char* current_language, int current_voice_type, void* user_data);
292
293
294 /**
295  * @brief Called when the engine is changed.
296  * @since_tizen 3.0
297  * @param[in] tts The TTS handle
298  * @param[in] engine_id Engine ID
299  * @param[in] language The default language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
300  * @param[in] voice_type The default voice type
301  * @param[in] need_credential The necessity of credential
302  * @param[in] user_data The user data passed from the callback registration function
303  * @see tts_set_engine_changed_cb()
304 */
305 typedef void (*tts_engine_changed_cb)(tts_h tts, const char* engine_id, const char* language, int voice_type, bool need_credential, void* user_data);
306
307
308 /**
309  * @brief Called when the option of screen reader is changed.
310  * @since_tizen 6.5
311  * @param[in] tts The TTS handle
312  * @param[in] is_on The status of screen reader. If @a is_on is @c true, screen reader is turned on. If not, it is turned off.
313  * @param[in] user_data The user data passed from the callback registration function
314  * @see tts_set_screen_reader_changed_cb()
315 */
316 typedef void (*tts_screen_reader_changed_cb)(tts_h tts, bool is_on, void* user_data);
317
318
319 /**
320  * @brief Called when the state of TTS service is changed.
321  * @since_tizen 7.0
322  * @remarks The @a tts handle should not be destroyed in the callback.
323  * @param[in] tts The TTS handle, the same handle for which the callback was set.
324  * @param[in] previous The previous state of TTS service
325  * @param[in] current The current state of TTS service
326  * @param[in] user_data The user data passed from the callback registration function
327  * @pre An application registers this callback using tts_set_service_state_changed_cb() to detect changing state of TTS service.
328  * @see tts_set_service_state_changed_cb()
329  * @see tts_unset_service_state_changed_cb()
330 */
331 typedef void (*tts_service_state_changed_cb)(tts_h tts, tts_service_state_e previous, tts_service_state_e current, void* user_data);
332
333
334 /**
335  * @brief Called when the synthesized pcm data is come from the engine.
336  * @since_tizen 8.0
337  * @remarks The @a tts handle should not be destroyed in the callback.
338  * @param[in] tts The TTS handle, the same handle for which the callback was set.
339  * @param[in] utt_id The utterance ID
340  * @param[in] event The event type
341  * @param[in] pcm_data The synthesized pcm data. The @a pcm_data can be used only in the callback. To use outside, make a copy.
342  * @param[in] pcm_data_size The size of the pcm data
343  * @param[in] audio_type The audio type of pcm data
344  * @param[in] sample_rate The sampling rate of pcm data
345  * @param[in] user_data The user data passed from the callback registration function
346  * @pre An application registers this callback using tts_set_synthesized_pcm_cb() to get pcm data.
347  * @see tts_set_synthesized_pcm_cb()
348  * @see tts_unset_synthesized_pcm_cb()
349  */
350 typedef void (*tts_synthesized_pcm_cb)(tts_h tts, int utt_id, tts_synthesized_pcm_event_e event, const char* pcm_data, int pcm_data_size, tts_audio_type_e audio_type, int sample_rate, void *user_data);
351
352
353 /**
354  * @brief Creates a handle for TTS.
355  * @since_tizen 2.3
356  * @remarks If the function succeeds, @a tts handle must be released with tts_destroy().
357  * @param[out] tts The TTS handle
358  * @return @c 0 on success,
359  *         otherwise a negative error value
360  * @retval #TTS_ERROR_NONE Successful
361  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
362  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
363  * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
364  * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
365  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
366  * @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
367  * @see tts_destroy()
368 */
369 int tts_create(tts_h* tts);
370
371
372 /**
373  * @brief Destroys the handle and disconnects the daemon.
374  * @since_tizen 2.3
375  * @param[in] tts The TTS handle
376  * @return @c 0 on success,
377  *         otherwise a negative error value
378  * @retval #TTS_ERROR_NONE Successful
379  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
380  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
381  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
382  * @see tts_create()
383 */
384 int tts_destroy(tts_h tts);
385
386
387 /**
388  * @brief Sets the TTS mode.
389  * @since_tizen 2.3
390  * @param[in] tts The TTS handle
391  * @param[in] mode The mode
392  * @return @c 0 on success,
393  *         otherwise a negative error value
394  * @retval #TTS_ERROR_NONE Successful
395  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
396  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
397  * @retval #TTS_ERROR_INVALID_STATE Invalid state
398  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
399  * @pre The state should be #TTS_STATE_CREATED.
400  * @see tts_get_mode()
401 */
402 int tts_set_mode(tts_h tts, tts_mode_e mode);
403
404
405 /**
406  * @brief Gets the TTS mode.
407  * @since_tizen 2.3
408  * @param[in] tts The TTS handle
409  * @param[out] mode The mode
410  * @return @c 0 on success,
411  *         otherwise a negative error value
412  * @retval #TTS_ERROR_NONE Successful
413  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
414  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
415  * @retval #TTS_ERROR_INVALID_STATE Invalid state
416  * @pre The state should be #TTS_STATE_CREATED.
417  * @see tts_set_mode()
418 */
419 int tts_get_mode(tts_h tts, tts_mode_e* mode);
420
421
422 /**
423  * @brief Sets the app credential.
424  * @details Using this API, the application can set a credential.
425  *          The credential is a key to verify the authorization about using the engine.
426  *          If the application sets the credential, it will be able to use functions of the engine entirely.
427  * @since_tizen 3.0
428  * @remarks The necessity of the credential depends on the engine. In case of the engine which is basically embedded in Tizen, the credential is not necessary so far.
429  *          However, if the user wants to apply the 3rd party's engine, the credential may be necessary. In that case, please follow the policy provided by the corresponding engine.
430  * @param[in] tts The TTS handle
431  * @param[in] credential The app credential
432  * @return @c 0 on success,
433  *         otherwise a negative error value
434  * @retval #TTS_ERROR_NONE Success
435  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
436  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
437  * @retval #TTS_ERROR_INVALID_STATE Invalid state
438  * @pre The state should be #TTS_STATE_CREATED or #TTS_STATE_READY.
439  * @see tts_play()
440 */
441 int tts_set_credential(tts_h tts, const char* credential);
442
443
444 /**
445  * @brief Connects the daemon asynchronously.
446  * @since_tizen 2.3
447  * @param[in] tts The TTS handle
448  * @return @c 0 on success,
449  *         otherwise a negative error value
450  * @retval #TTS_ERROR_NONE Successful
451  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
452  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
453  * @retval #TTS_ERROR_INVALID_STATE Invalid state
454  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
455  * @pre The state should be #TTS_STATE_CREATED.
456  * @post If this function is successful, the TTS state will be #TTS_STATE_READY.
457  *       If this function is failed, the error callback is called. (e.g. #TTS_ERROR_ENGINE_NOT_FOUND)
458  * @see tts_unprepare()
459 */
460 int tts_prepare(tts_h tts);
461
462
463 /**
464  * @brief Disconnects the daemon.
465  * @since_tizen 2.3
466  * @param[in] tts The TTS handle
467  * @return @c 0 on success,
468  *         otherwise a negative error value
469  * @retval #TTS_ERROR_NONE Successful
470  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
471  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
472  * @retval #TTS_ERROR_INVALID_STATE Invalid state
473  * @pre The state should be #TTS_STATE_READY.
474  * @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
475  * @see tts_prepare()
476 */
477 int tts_unprepare(tts_h tts);
478
479
480 /**
481  * @brief Connects the daemon synchronously.
482  * @since_tizen 7.0
483  * @param[in] tts The TTS handle
484  * @return @c 0 on success,
485  *         otherwise a negative error value
486  * @retval #TTS_ERROR_NONE Successful
487  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
488  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
489  * @retval #TTS_ERROR_INVALID_STATE Invalid state
490  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
491  * @pre The state should be #TTS_STATE_CREATED.
492  * @post If this function is successful, the TTS state will be #TTS_STATE_READY.
493  * @see tts_unprepare()
494 */
495 int tts_prepare_sync(tts_h tts);
496
497
498 /**
499  * @brief Retrieves all supported voices of the current engine using callback function.
500  * @since_tizen 2.3
501  * @param[in] tts The TTS handle
502  * @param[in] callback The callback function to invoke
503  * @param[in] user_data The user data to be passed to the callback function
504  * @return @c 0 on success,
505  *         otherwise a negative error value
506  * @retval #TTS_ERROR_NONE Successful
507  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
508  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
509  * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
510  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
511  * @post This function invokes tts_supported_voice_cb() repeatedly for getting voices.
512  * @see tts_get_default_voice()
513 */
514 int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data);
515
516
517 /**
518  * @brief Gets the default voice set by the user.
519  * @since_tizen 2.3
520  * @remarks If the function succeeds, @a language must be released with free().
521  * @param[in] tts The TTS handle
522  * @param[out] language Language specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code (for example, "ko_KR" for Korean, "en_US" for American English)
523  * @param[out] voice_type The voice type
524  * @return @c 0 on success,
525  *         otherwise a negative error value
526  * @retval #TTS_ERROR_NONE Successful
527  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
528  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
529  * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
530  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
531  * @see tts_foreach_supported_voices()
532 */
533 int tts_get_default_voice(tts_h tts, char** language, int* voice_type);
534
535
536 /**
537  * @brief Sets the private data to tts engine.
538  * @details The private data is the setting parameter for applying keys provided by the engine.
539  *          Using this API, the application can set the private data and use the corresponding key of the engine.
540  *          For example, if the engine provides 'girl's voice' as a voice type, the application can set the private data as the following.
541  *          int ret = tts_set_private_data(#tts_h, "voice_type", "GIRL");
542  * @since_tizen 3.0
543  * @remarks If the engine is replaced with the other engine, the key may be ignored.
544  * @param[in] tts The TTS handle
545  * @param[in] key The field name of private data
546  * @param[in] data The data for set
547  * @return @c 0 on success,
548  *         otherwise a negative error value
549  * @retval #TTS_ERROR_NONE Successful
550  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
551  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
552  * @retval #TTS_ERROR_INVALID_STATE Invalid state
553  * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
554  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
555  * @pre The state should be #TTS_STATE_READY.
556  * @see tts_get_private_data()
557 */
558 int tts_set_private_data(tts_h tts, const char* key, const char* data);
559
560
561 /**
562  * @brief Gets the private data from tts engine.
563  * @details The private data is the information provided by the engine.
564  *          Using this API, the application can get the private data which corresponds to the key from the engine.
565  * @since_tizen 3.0
566  * @remarks The @a data must be released using free() when it is no longer required.
567  *          If the engine is replaced with the other engine, the key may be ignored.
568  * @param[in] tts The TTS handle
569  * @param[in] key The field name of private data
570  * @param[out] data The data field of private data
571  * @return @c 0 on success,
572  *         otherwise a negative error value
573  * @retval #TTS_ERROR_NONE Successful
574  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
575  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
576  * @retval #TTS_ERROR_INVALID_STATE Invalid state
577  * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
578  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
579  * @pre The state should be #TTS_STATE_READY.
580  * @see tts_set_private_data()
581 */
582 int tts_get_private_data(tts_h tts, const char* key, char** data);
583
584
585 /**
586  * @brief Gets the maximum byte size for text.
587  * @since_tizen 2.3
588  * @param[in] tts The TTS handle
589  * @param[out] size The maximum byte size for text
590  * @return @c 0 on success,
591  *         otherwise a negative error value
592  * @retval #TTS_ERROR_NONE Successful
593  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
594  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
595  * @retval #TTS_ERROR_INVALID_STATE Invalid state
596  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
597  * @pre The state should be #TTS_STATE_READY.
598  * @see tts_add_text()
599 */
600 int tts_get_max_text_size(tts_h tts, unsigned int* size);
601
602
603 /**
604  * @brief Gets the current state of TTS.
605  * @since_tizen 2.3
606  * @param[in] tts The TTS handle
607  * @param[out] state The current state of TTS
608  * @return @c 0 on success,
609  *         otherwise a negative error value
610  * @retval #TTS_ERROR_NONE Successful
611  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
612  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
613  * @see tts_play()
614  * @see tts_stop()
615  * @see tts_pause()
616 */
617 int tts_get_state(tts_h tts, tts_state_e* state);
618
619
620 /**
621  * @brief Gets the speed range.
622  * @since_tizen 2.3
623  * @param[in] tts The TTS handle
624  * @param[out] min The minimum speed value
625  * @param[out] normal The normal speed value
626  * @param[out] max The maximum speed value
627  * @return @c 0 on success,
628  *         otherwise a negative error value
629  * @retval #TTS_ERROR_NONE Successful
630  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
631  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
632  * @retval #TTS_ERROR_INVALID_STATE Invalid state
633  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
634  * @pre The state should be #TTS_STATE_CREATED.
635  * @see tts_add_text()
636 */
637 int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max);
638
639
640 /**
641  * @brief Gets the current error message.
642  * @since_tizen 3.0
643  * @remarks This function should be called from a tts error callback. Calling in any other context will result in an Operation failed error.
644  *          A successful call will allocate @a err_msg, which must be released by calling free() when it is no longer required.
645  * @param[in] tts The TTS handle
646  * @param[out] err_msg The current error message
647  * @return @c 0 on success,
648  *         otherwise a negative error value
649  * @retval #TTS_ERROR_NONE Successful
650  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
651  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
652  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
653  * @see tts_set_error_cb()
654  * @see tts_unset_error_cb()
655 */
656 int tts_get_error_message(tts_h tts, char** err_msg);
657
658
659 /**
660  * @brief Gets the current state of TTS service.
661  * @since_tizen 7.0
662  * @param[in] tts The TTS handle
663  * @param[out] service_state The current state of TTS service
664  * @return @c 0 on success,
665  *         otherwise a negative error value
666  * @retval #TTS_ERROR_NONE Successful
667  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
668  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
669  * @retval #TTS_ERROR_INVALID_STATE Invalid state
670  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
671  * @pre The TTS state should be one of: #TTS_STATE_READY, #TTS_STATE_PLAYING, #TTS_STATE_PAUSED.
672  * @see tts_play()
673  * @see tts_stop()
674  * @see tts_pause()
675 */
676 int tts_get_service_state(tts_h tts, tts_service_state_e* service_state);
677
678
679 /**
680  * @brief Checks whether screen reader is turned on or not.
681  * @since_tizen 6.5
682  * @remarks If TTS mode is #TTS_MODE_SCREEN_READER, you should call this function to check whether screen reader is turned on or not, before calling 'tts_prepare()'.
683  *          If TTS mode is #TTS_MODE_SCREEN_READER and @a is_on is @c false, all other functions will return #TTS_ERROR_SCREEN_READER_OFF.
684  *          The @a is_on must be released using free() when it is no longer required.
685  * @param[in] tts The TTS handle
686  * @param[out] is_on The current status of screen reader
687  * @return @c 0 on success,
688  *         otherwise a negative error value
689  * @retval #TTS_ERROR_NONE Successful
690  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
691  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
692  * @see tts_set_screen_reader_changed_cb()
693  * @see tts_unset_screen_reader_changed_cb()
694 */
695 int tts_check_screen_reader_on(tts_h tts, bool* is_on);
696
697
698 /**
699  * @brief Adds a text to the queue.
700  * @since_tizen 2.3
701  * @remarks Locale(e.g. setlocale()) MUST be set for utf8 text validation check.
702  * @param[in] tts The TTS handle
703  * @param[in] text An input text based utf8
704  * @param[in] language The language selected from the tts_foreach_supported_voices() (e.g. 'NULL'(Automatic), 'en_US')
705  * @param[in] voice_type The voice type selected from the tts_foreach_supported_voices() (e.g. #TTS_VOICE_TYPE_AUTO, #TTS_VOICE_TYPE_FEMALE)
706  * @param[in] speed A speaking speed (e.g. #TTS_SPEED_AUTO or the value from tts_get_speed_range())
707  * @param[out] utt_id The utterance ID passed to the callback function
708  * @return @c 0 on success,
709  *         otherwise a negative error value
710  * @retval #TTS_ERROR_NONE Successful
711  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
712  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
713  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
714  * @retval #TTS_ERROR_INVALID_STATE Invalid state
715  * @retval #TTS_ERROR_INVALID_VOICE Invalid voice about language, voice type
716  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
717  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
718  * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
719  * @see tts_get_max_text_size()
720  * @see tts_set_credential()
721 */
722 int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id);
723
724
725 /**
726  * @brief Starts synthesizing voice from the text and plays the synthesized audio data.
727  * @since_tizen 2.3
728  * @param[in] tts The TTS handle
729  * @return @c 0 on success,
730  *         otherwise a negative error value
731  * @retval #TTS_ERROR_NONE Successful
732  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
733  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
734  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
735  * @retval #TTS_ERROR_OUT_OF_NETWORK Out of network
736  * @retval #TTS_ERROR_INVALID_STATE Invalid state
737  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
738  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
739  * @pre The current state should be #TTS_STATE_READY or #TTS_STATE_PAUSED.
740  * @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
741  * @see tts_add_text()
742  * @see tts_pause()
743  * @see tts_stop()
744  * @see tts_utterance_started_cb()
745  * @see tts_utterance_completed_cb()
746  * @see tts_error_cb()
747  * @see tts_set_credential()
748 */
749 int tts_play(tts_h tts);
750
751
752 /**
753  * @brief Stops playing the utterance and clears the queue.
754  * @since_tizen 2.3
755  * @param[in] tts The TTS handle
756  * @return @c 0 on success,
757  *         otherwise a negative error value
758  * @retval #TTS_ERROR_NONE Successful
759  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
760  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
761  * @retval #TTS_ERROR_INVALID_STATE Invalid state
762  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
763  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
764  * @pre The TTS state should be #TTS_STATE_READY or #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
765  * @post If this function succeeds, the TTS state will be #TTS_STATE_READY.
766  *       This function will remove all text via tts_add_text() and synthesized sound data.
767  * @see tts_play()
768  * @see tts_pause()
769 */
770 int tts_stop(tts_h tts);
771
772
773 /**
774  * @brief Pauses the currently playing utterance.
775  * @since_tizen 2.3
776  * @param[in] tts The TTS handle
777  * @return @c 0 on success,
778  *         otherwise a negative error value
779  * @retval #TTS_ERROR_NONE Successful
780  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
781  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
782  * @retval #TTS_ERROR_INVALID_STATE Invalid state
783  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
784  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
785  * @pre The TTS state should be #TTS_STATE_PLAYING.
786  * @post If this function succeeds, the TTS state will be #TTS_STATE_PAUSED.
787  * @see tts_play()
788  * @see tts_stop()
789  * @see tts_error_cb()
790 */
791 int tts_pause(tts_h tts);
792
793 /**
794  * @brief Repeats the last added text.
795  * @since_tizen 5.0
796  * @remarks This function repeats the last added text once again.
797  *          If there is no previously added text, this function will not work.
798  *          If the language is changed, the last added text is removed from the service.
799  *          Before calling this function, please call 'tts_stop()' in order to stop playing the previous one.
800  *          If this function succeeds, @a text_repeat must be released with free().
801  * @param[in] tts The TTS handle
802  * @param[out] text_repeat Texts to be played repeatedly
803  * @param[out] utt_id The utterance ID passed to the callback function
804  *
805  * @return @c 0 on success,
806  *         otherwise a negative error value
807  * @retval #TTS_ERROR_NONE Successful
808  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
809  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
810  * @retval #TTS_ERROR_INVALID_STATE Invalid state
811  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
812  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
813  * @pre The state should be #TTS_STATE_READY.
814  * @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
815  * @see tts_add_text()
816  * @see tts_stop()
817  */
818 int tts_repeat(tts_h tts, char** text_repeat, int* utt_id);
819
820 /**
821  * @brief Sets a callback function to be called when the TTS state changes.
822  * @since_tizen 2.3
823  * @param[in] tts The TTS handle
824  * @param[in] callback The callback function to register
825  * @param[in] user_data The user data to be passed to the callback function
826  * @return @c 0 on success,
827  *         otherwise a negative error value
828  * @retval #TTS_ERROR_NONE Successful
829  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
830  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
831  * @retval #TTS_ERROR_INVALID_STATE Invalid state
832  * @pre The state should be #TTS_STATE_CREATED.
833  * @see tts_state_changed_cb()
834  * @see tts_unset_state_changed_cb()
835 */
836 int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
837
838
839 /**
840  * @brief Unsets the callback function to be called when the TTS state changes.
841  * @since_tizen 2.3
842  * @param[in] tts The TTS handle
843  * @return @c 0 on success,
844  *         otherwise a negative error value
845  * @retval #TTS_ERROR_NONE Successful
846  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
847  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
848  * @retval #TTS_ERROR_INVALID_STATE Invalid state
849  * @pre The state should be #TTS_STATE_CREATED.
850  * @see tts_set_state_changed_cb()
851 */
852 int tts_unset_state_changed_cb(tts_h tts);
853
854
855 /**
856  * @brief Sets a callback function to detect utterance start.
857  * @since_tizen 2.3
858  * @param[in] tts The TTS handle
859  * @param[in] callback The callback function to register
860  * @param[in] user_data The user data to be passed to the callback function
861  * @return @c 0 on success,
862  *         otherwise a negative error value
863  * @retval #TTS_ERROR_NONE Successful
864  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
865  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
866  * @retval #TTS_ERROR_INVALID_STATE Invalid state
867  * @pre The state should be #TTS_STATE_CREATED.
868  * @see tts_utterance_started_cb()
869  * @see tts_unset_utterance_started_cb()
870 */
871 int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data);
872
873
874 /**
875  * @brief Unsets the callback function to detect utterance start.
876  * @since_tizen 2.3
877  * @param[in] tts The TTS handle
878  * @return @c 0 on success,
879  *         otherwise a negative error value
880  * @retval #TTS_ERROR_NONE Successful
881  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
882  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
883  * @retval #TTS_ERROR_INVALID_STATE Invalid state
884  * @pre The state should be #TTS_STATE_CREATED.
885  * @see tts_set_utterance_started_cb()
886 */
887 int tts_unset_utterance_started_cb(tts_h tts);
888
889
890 /**
891  * @brief Sets a callback function to detect utterance completion.
892  * @since_tizen 2.3
893  * @param[in] tts The TTS handle
894  * @param[in] callback The callback function to register
895  * @param[in] user_data The user data to be passed to the callback function
896  * @return @c 0 on success,
897  *         otherwise a negative error value
898  * @retval #TTS_ERROR_NONE Successful
899  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
900  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
901  * @retval #TTS_ERROR_INVALID_STATE Invalid state
902  * @pre The state should be #TTS_STATE_CREATED.
903  * @see tts_utterance_completed_cb()
904  * @see tts_unset_utterance_completed_cb()
905 */
906 int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data);
907
908
909 /**
910  * @brief Unsets the callback function to detect utterance completion.
911  * @since_tizen 2.3
912  * @param[in] tts The TTS handle
913  * @return @c 0 on success,
914  *         otherwise a negative error value
915  * @retval #TTS_ERROR_NONE Successful
916  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
917  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
918  * @retval #TTS_ERROR_INVALID_STATE Invalid state
919  * @pre The state should be #TTS_STATE_CREATED.
920  * @see tts_set_utterance_completed_cb()
921 */
922 int tts_unset_utterance_completed_cb(tts_h tts);
923
924
925 /**
926  * @brief Sets a callback function to detect errors.
927  * @since_tizen 2.3
928  * @param[in] tts The TTS handle
929  * @param[in] callback The callback function to register
930  * @param[in] user_data The user data to be passed to the callback function
931  * @return @c 0 on success,
932  *         otherwise a negative error value
933  * @retval #TTS_ERROR_NONE Successful
934  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
935  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
936  * @retval #TTS_ERROR_INVALID_STATE Invalid state
937  * @pre The state should be #TTS_STATE_CREATED.
938  * @see tts_error_cb()
939  * @see tts_unset_error_cb()
940 */
941 int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
942
943
944 /**
945  * @brief Unsets the callback function to detect errors.
946  * @since_tizen 2.3
947  * @param[in] tts The TTS handle
948  * @return @c 0 on success,
949  *         otherwise a negative error value
950  * @retval #TTS_ERROR_NONE Successful
951  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
952  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
953  * @retval #TTS_ERROR_INVALID_STATE Invalid state
954  * @pre The state should be #TTS_STATE_CREATED.
955  * @see tts_set_error_cb()
956 */
957 int tts_unset_error_cb(tts_h tts);
958
959
960 /**
961  * @brief Sets a callback function to detect default voice change.
962  * @since_tizen 2.3
963  * @param[in] tts The TTS handle
964  * @param[in] callback The callback function to register
965  * @param[in] user_data The user data to be passed to the callback function
966  * @return @c 0 on success,
967  *         otherwise a negative error value
968  * @retval #TTS_ERROR_NONE Successful
969  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
970  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
971  * @retval #TTS_ERROR_INVALID_STATE Invalid state
972  * @pre The state should be #TTS_STATE_CREATED.
973  * @see tts_default_voice_changed_cb()
974  * @see tts_unset_default_voice_changed_cb()
975 */
976 int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb callback, void* user_data);
977
978
979 /**
980  * @brief Unsets the callback function to detect default voice change.
981  * @since_tizen 2.3
982  * @param[in] tts The TTS handle
983  * @return @c 0 on success,
984  *         otherwise a negative error value
985  * @retval #TTS_ERROR_NONE Successful
986  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
987  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
988  * @retval #TTS_ERROR_INVALID_STATE Invalid state
989  * @pre The state should be #TTS_STATE_CREATED.
990  * @see tts_set_default_voice_changed_cb()
991 */
992 int tts_unset_default_voice_changed_cb(tts_h tts);
993
994
995  /**
996  * @brief Sets a callback function to detect the engine change.
997  * @since_tizen 3.0
998  * @param[in] tts The TTS handle
999  * @param[in] callback The callback function to register
1000  * @param[in] user_data The user data to be passed to the callback function
1001  * @return @c 0 on success,
1002  *         otherwise a negative error value
1003  * @retval #TTS_ERROR_NONE Successful
1004  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1005  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1006  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1007  * @pre The state should be #TTS_STATE_CREATED.
1008  * @see tts_engine_changed_cb()
1009  * @see tts_unset_engine_changed_cb()
1010 */
1011 int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* user_data);
1012
1013
1014 /**
1015  * @brief Unsets the callback function to detect the engine change.
1016  * @since_tizen 3.0
1017  * @param[in] tts The TTS handle
1018  * @return @c 0 on success,
1019  *         otherwise a negative error value
1020  * @retval #TTS_ERROR_NONE Successful
1021  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1022  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1023  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1024  * @pre The state should be #TTS_STATE_CREATED.
1025  * @see tts_set_engine_changed_cb()
1026 */
1027 int tts_unset_engine_changed_cb(tts_h tts);
1028
1029
1030 /**
1031  * @brief Sets a callback function to detect the option of screen reader is changed or not.
1032  * @since_tizen 6.5
1033  * @remarks If TTS mode is #TTS_MODE_SCREEN_READER, you should set the callback to check the option of screen reader is changed or not.
1034  * @param[in] tts The TTS handle
1035  * @param[in] callback The callback function to register
1036  * @param[in] user_data The user data to be passed to the callback function
1037  * @return @c 0 on success,
1038  *         otherwise a negative error value
1039  * @retval #TTS_ERROR_NONE Successful
1040  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1041  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1042  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1043  * @pre The state should be #TTS_STATE_CREATED.
1044  * @see tts_screen_reader_changed_cb()
1045  * @see tts_unset_screen_reader_changed_cb()
1046 */
1047 int tts_set_screen_reader_changed_cb(tts_h tts, tts_screen_reader_changed_cb callback, void* user_data);
1048
1049
1050 /**
1051  * @brief Unsets the callback function to detect the option of screen reader is changed or not.
1052  * @since_tizen 6.5
1053  * @param[in] tts The TTS handle
1054  * @return @c 0 on success,
1055  *         otherwise a negative error value
1056  * @retval #TTS_ERROR_NONE Successful
1057  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1058  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1059  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1060  * @pre The state should be #TTS_STATE_CREATED.
1061  * @see tts_set_screen_reader_changed_cb()
1062 */
1063 int tts_unset_screen_reader_changed_cb(tts_h tts);
1064
1065
1066 /**
1067  * @brief Sets a callback function to be called when the TTS service state changes.
1068  * @since_tizen 7.0
1069  * @param[in] tts The TTS handle
1070  * @param[in] callback The callback function to register
1071  * @param[in] user_data The user data to be passed to the callback function
1072  * @return @c 0 on success,
1073  *         otherwise a negative error value
1074  * @retval #TTS_ERROR_NONE Successful
1075  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1076  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1077  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1078  * @pre The TTS state should be #TTS_STATE_CREATED.
1079  * @see tts_service_state_changed_cb()
1080  * @see tts_unset_service_state_changed_cb()
1081 */
1082 int tts_set_service_state_changed_cb(tts_h tts, tts_service_state_changed_cb callback, void* user_data);
1083
1084
1085 /**
1086  * @brief Unsets the callback function to be called when the TTS service state changes.
1087  * @since_tizen 7.0
1088  * @param[in] tts The TTS handle
1089  * @return @c 0 on success,
1090  *         otherwise a negative error value
1091  * @retval #TTS_ERROR_NONE Successful
1092  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1093  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1094  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1095  * @pre The TTS state should be #TTS_STATE_CREATED.
1096  * @see tts_set_service_state_changed_cb()
1097 */
1098 int tts_unset_service_state_changed_cb(tts_h tts);
1099
1100
1101 /**
1102  * @brief Sets the TTS playing mode.
1103  * @since_tizen 8.0
1104  * @param[in] tts The TTS handle
1105  * @param[in] mode The mode
1106  * @return @c 0 on success,
1107  *         otherwise a negative error value
1108  * @retval #TTS_ERROR_NONE Successful
1109  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1110  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1111  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1112  * @pre The state should be #TTS_STATE_CREATED.
1113  * @see tts_get_playing_mode()
1114  * @see tts_play()
1115  */
1116 int tts_set_playing_mode(tts_h tts, tts_playing_mode_e mode);
1117
1118
1119 /**
1120  * @brief Sets the callback function to receive the synthesized pcm data from the tts service.
1121  * @since_tizen 8.0
1122  * @param[in] tts The TTS handle
1123  * @param[in] callback The callback function to register
1124  * @param[in] user_data The user data to be passed to the callback function
1125  * @return @c 0 on success,
1126  *         otherwise a negative error value
1127  * @retval #TTS_ERROR_NONE Successful
1128  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1129  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
1130  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1131  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1132  * @pre The TTS state should be #TTS_STATE_CREATED.
1133  * @see tts_synthesized_pcm_cb()
1134  * @see tts_unset_synthesized_pcm_cb()
1135  */
1136 int tts_set_synthesized_pcm_cb(tts_h tts, tts_synthesized_pcm_cb callback, void* user_data);
1137
1138
1139 /**
1140  * @brief Unsets the callback function to receive synthesized PCM data from the tts service.
1141  * @since_tizen 8.0
1142  * @param[in] tts The TTS handle
1143  * @return @c 0 on success,
1144  *         otherwise a negative error value
1145  * @retval #TTS_ERROR_NONE Successful
1146  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1147  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1148  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1149  * @pre The TTS state should be #TTS_STATE_CREATED.
1150  * @see tts_set_synthesized_pcm_cb()
1151   */
1152 int tts_unset_synthesized_pcm_cb(tts_h tts);
1153
1154
1155 /**
1156  * @brief Adds silence for the specified amount of time
1157  * @since_tizen 9.0
1158  * @remarks The maximum silent time is 5000 msec. If you want to perform a silent time of more than 5000 msec, call this function several times.
1159  * @param[in] tts The TTS handle
1160  * @param[in] duration_in_msec The duration of the silence
1161  * @param[out] utt_id The utterance ID passed to the callback function
1162  * @return @c 0 on success,
1163  *         otherwise a negative error value
1164  * @retval #TTS_ERROR_NONE Successful
1165  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1166  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1167  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1168  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
1169  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
1170  * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING, or #TTS_STATE_PAUSED.
1171 */
1172 int tts_add_silent_utterance(tts_h tts, unsigned int duration_in_msec, int* utt_id);
1173
1174
1175 /**
1176  * @brief Creates a handle for TTS synthesis parameters.
1177  * @since_tizen 9.0
1178  * @remarks If the function succeeds, @a paramter handle must be released with tts_synthesis_parameter_destroy().
1179  * @param[out] parameter The TTS synthesis parameter handle
1180  * @return @c 0 on success,
1181  *         otherwise a negative error value
1182  * @retval #TTS_ERROR_NONE Successful
1183  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1184  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1185  * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
1186  * @see tts_synthesis_parameter_destroy()
1187 */
1188 int tts_synthesis_parameter_create(tts_synthesis_parameter_h *parameter);
1189
1190 /**
1191  * @brief Destroys the TTS synthesis paramter handle.
1192  * @since_tizen 9.0
1193  * @param[in] parameter The TTS synthesis parameter handle
1194  * @return @c 0 on success,
1195  *         otherwise a negative error value
1196  * @retval #TTS_ERROR_NONE Successful
1197  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1198  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1199  * @see tts_synthesis_parameter_create()
1200 */
1201 int tts_synthesis_parameter_destroy(tts_synthesis_parameter_h parameter);
1202
1203 /**
1204  * @brief Sets the language.
1205  * @since_tizen 9.0
1206  * @param[in] parameter The TTS synthesis parameter handle
1207  * @param[in] language The language selected from the tts_foreach_supported_voices() (e.g. 'NULL'(Automatic), 'en_US')
1208  * @return @c 0 on success,
1209  *         otherwise a negative error value
1210  * @retval #TTS_ERROR_NONE Successful
1211  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1212  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1213  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
1214  * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
1215 */
1216 int tts_synthesis_parameter_set_language(tts_synthesis_parameter_h parameter, const char *language);
1217
1218 /**
1219  * @brief Sets the voice type.
1220  * @since_tizen 9.0
1221  * @param[in] parameter The TTS synthesis parameter handle
1222  * @param[in] voice_type The voice type selected from the tts_foreach_supported_voices() (e.g. #TTS_VOICE_TYPE_AUTO, #TTS_VOICE_TYPE_FEMALE)
1223  * @return @c 0 on success,
1224  *         otherwise a negative error value
1225  * @retval #TTS_ERROR_NONE Successful
1226  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1227  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1228 */
1229 int tts_synthesis_parameter_set_voice_type(tts_synthesis_parameter_h parameter, int voice_type);
1230
1231 /**
1232  * @brief Sets the ID for personal voice data.
1233  * @since_tizen 9.0
1234  * @param[in] parameter The TTS synthesis parameter handle
1235  * @param[in] ptts_id The id for personal voice data
1236  * @return @c 0 on success,
1237  *         otherwise a negative error value
1238  * @retval #TTS_ERROR_NONE Successful
1239  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1240  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1241  * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
1242 */
1243 int tts_synthesis_parameter_set_personal_voice(tts_synthesis_parameter_h parameter, const char *ptts_id);
1244
1245 /**
1246  * @brief Sets the speed.
1247  * @since_tizen 9.0
1248  * @param[in] parameter The TTS synthesis parameter handle
1249  * @param[in] speed A speaking speed (e.g. #TTS_SPEED_AUTO or the value from tts_get_speed_range())
1250  * @return @c 0 on success,
1251  *         otherwise a negative error value
1252  * @retval #TTS_ERROR_NONE Successful
1253  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1254  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1255  * @see tts_get_speed_range()
1256 */
1257 int tts_synthesis_parameter_set_speed(tts_synthesis_parameter_h parameter, int speed);
1258
1259 /**
1260  * @brief Sets the pitch.
1261  * @since_tizen 9.0
1262  * @param[in] parameter The TTS synthesis parameter handle
1263  * @param[in] pitch A speaking pitch (e.g. #TTS_PITCH_AUTO or the value from tts_get_pitch_range())
1264  * @return @c 0 on success,
1265  *         otherwise a negative error value
1266  * @retval #TTS_ERROR_NONE Successful
1267  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1268  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1269  * @see tts_get_pitch_range()
1270 */
1271 int tts_synthesis_parameter_set_pitch(tts_synthesis_parameter_h parameter, int pitch);
1272
1273 /**
1274  * @brief Sets the volume.
1275  * @since_tizen 9.0
1276  * @param[in] parameter The TTS synthesis parameter handle
1277  * @param[in] volume A speaking volume ratio (e.g. #TTS_VOLUME_AUTO or the value from tts_get_volume_range())
1278  * @return @c 0 on success,
1279  *         otherwise a negative error value
1280  * @retval #TTS_ERROR_NONE Successful
1281  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1282  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1283  * @see tts_get_volume_range()
1284 */
1285 int tts_synthesis_parameter_set_volume(tts_synthesis_parameter_h parameter, double volume);
1286
1287 /**
1288  * @brief Sets the background volume ratio.
1289  * @since_tizen 9.0
1290  * @param[in] parameter The TTS synthesis parameter handle
1291  * @param[in] background_volume_ratio A background volume ratio ratio (Range 0.0 ~ 1.0)
1292  * @return @c 0 on success,
1293  *         otherwise a negative error value
1294  * @retval #TTS_ERROR_NONE Successful
1295  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1296  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1297 */
1298 int tts_synthesis_parameter_set_background_volume_ratio(tts_synthesis_parameter_h parameter, double background_volume_ratio);
1299
1300 /**
1301  * @brief Gets the pitch range.
1302  * @since_tizen 9.0
1303  * @param[in] tts The TTS handle
1304  * @param[out] min The minimum pitch value
1305  * @param[out] normal The normal pitch value
1306  * @param[out] max The maximum pitch value
1307  * @return @c 0 on success,
1308  *         otherwise a negative error value
1309  * @retval #TTS_ERROR_NONE Successful
1310  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1311  * @retval #TTS_ERROR_NOT_SUPPORTED_FEATURE Not supported feature.
1312  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1313  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1314  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
1315  * @pre The state should be #TTS_STATE_READY.
1316  * @see tts_synthesis_parameter_set_pitch()
1317 */
1318 int tts_get_pitch_range(tts_h tts, int* min, int* normal, int* max);
1319
1320 /**
1321  * @brief Gets the volume range.
1322  * @since_tizen 9.0
1323  * @param[in] tts The TTS handle
1324  * @param[out] min The minimum volume value
1325  * @param[out] max The maximum volume value
1326  * @return @c 0 on success,
1327  *         otherwise a negative error value
1328  * @retval #TTS_ERROR_NONE Successful
1329  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1330  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1331  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1332  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
1333  * @pre The state should be #TTS_STATE_READY.
1334  * @see tts_synthesis_parameter_set_volume()
1335 */
1336 int tts_get_volume_range(tts_h tts, int* min, int* max);
1337
1338 /**
1339  * @brief Adds a text to the queue with synthesis parameter.
1340  * @since_tizen 9.0
1341  * @remarks Locale(e.g. setlocale()) MUST be set for utf8 text validation check.
1342  * @param[in] tts The TTS handle
1343  * @param[in] text An input text based utf8
1344  * @param[in] parameter The TTS synthesis parameter handle
1345  * @param[out] utt_id The utterance ID passed to the callback function
1346  * @return @c 0 on success,
1347  *         otherwise a negative error value
1348  * @retval #TTS_ERROR_NONE Successful
1349  * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1350  * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
1351  * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1352  * @retval #TTS_ERROR_INVALID_STATE Invalid state
1353  * @retval #TTS_ERROR_INVALID_VOICE Invalid voice about language, voice type
1354  * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
1355  * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
1356  * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
1357  * @see tts_get_max_text_size()
1358  * @see tts_set_credential()
1359 */
1360 int tts_add_text_with_synthesis_parameter(tts_h tts, const char* text, tts_synthesis_parameter_h parameter, int* utt_id);
1361
1362 #ifdef __cplusplus
1363 }
1364 #endif
1365
1366
1367 /**
1368  * @}
1369  */
1370
1371
1372 #endif  /* __TTS_H__ */