2 * Copyright (c) 2011-2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
31 * @addtogroup CAPI_UIX_TTS_MODULE
42 * @brief Enumeration for error code.
43 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
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 @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
60 TTS_ERROR_SERVICE_RESET = TIZEN_ERROR_TTS | 0x07, /**< Service reset @if MOBILE (Since 3.0) @elseif WEARABLE (Since 2.3.2) @endif */
61 TTS_ERROR_SCREEN_READER_OFF = TIZEN_ERROR_TTS | 0x08 /**< Screen reader is off (Since 6.5) */
66 * @brief Enumeration for TTS mode.
67 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
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 */
77 * @brief Enumeration for state.
78 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
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*/
89 * @brief Enumeration for service state.
93 TTS_SERVICE_STATE_READY = 0, /**< 'Ready' state */
94 TTS_SERVICE_STATE_SYNTHESIZING, /**< 'Synthesizing' state */
95 TTS_SERVICE_STATE_PLAYING /**< 'Playing' state */
96 } tts_service_state_e;
100 * @brief Definition for automatic speaking speed.
101 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
103 #define TTS_SPEED_AUTO 0
107 * @brief Definition for automatic voice type.
108 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
110 #define TTS_VOICE_TYPE_AUTO 0
114 * @brief Definition for male voice type.
115 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
117 #define TTS_VOICE_TYPE_MALE 1
121 * @brief Definition for female voice type.
122 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
124 #define TTS_VOICE_TYPE_FEMALE 2
128 * @brief Definition for child voice type.
129 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
131 #define TTS_VOICE_TYPE_CHILD 3
135 * @brief The TTS handle.
136 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
138 typedef struct tts_s *tts_h;
142 * @brief Called when the state of TTS is changed.
143 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
144 * @details If the daemon must stop player because of changing engine and
145 * the daemon must pause player because of other requests, this callback function is called.
146 * @param[in] tts The TTS handle
147 * @param[in] previous The previous state
148 * @param[in] current The current state
149 * @param[in] user_data The user data passed from the callback registration function
150 * @pre An application registers this callback using tts_set_state_changed_cb() to detect changing state.
151 * @see tts_set_state_changed_cb()
152 * @see tts_unset_state_changed_cb()
154 typedef void (*tts_state_changed_cb)(tts_h tts, tts_state_e previous, tts_state_e current, void* user_data);
158 * @brief Called when utterance has started.
159 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
160 * @param[in] tts The TTS handle
161 * @param[in] utt_id The utterance ID passed from the add text function
162 * @param[in] user_data The user data passed from the callback registration function
163 * @pre An application registers this callback using tts_set_utterance_started_cb() to detect utterance started.
164 * @see tts_add_text()
165 * @see tts_set_utterance_started_cb()
166 * @see tts_unset_utterance_started_cb()
168 typedef void (*tts_utterance_started_cb)(tts_h tts, int utt_id, void* user_data);
172 * @brief Called when utterance is finished.
173 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
174 * @param[in] tts The TTS handle
175 * @param[in] utt_id The utterance ID passed from the add text function
176 * @param[in] user_data The user data passed from the callback registration function
177 * @pre An application registers this callback using tts_set_utterance_completed_cb() to detect utterance completed.
178 * @see tts_add_text()
179 * @see tts_set_utterance_completed_cb()
180 * @see tts_unset_utterance_completed_cb()
182 typedef void (*tts_utterance_completed_cb)(tts_h tts, int utt_id, void *user_data);
186 * @brief Called when an error occurs.
187 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
188 * @param[in] tts The TTS handle
189 * @param[in] utt_id The utterance ID passed from the add text function
190 * @param[in] reason The error code
191 * @param[in] user_data The user data passed from the callback registration function
192 * @pre An application registers this callback using tts_set_error_cb() to detect error.
196 * @see tts_set_error_cb()
197 * @see tts_unset_error_cb()
199 typedef void (*tts_error_cb)(tts_h tts, int utt_id, tts_error_e reason, void* user_data);
203 * @brief Called to retrieve the supported voice.
204 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
205 * @param[in] tts The TTS handle
206 * @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)
207 * @param[in] voice_type A voice type (e.g. #TTS_VOICE_TYPE_MALE, #TTS_VOICE_TYPE_FEMALE)
208 * @param[in] user_data The user data passed from the foreach function
209 * @return @c true to continue with the next iteration of the loop,
210 * @c false to break out of the loop
211 * @pre tts_foreach_supported_voices() will invoke this callback function.
212 * @see tts_foreach_supported_voices()
214 typedef bool(*tts_supported_voice_cb)(tts_h tts, const char* language, int voice_type, void* user_data);
218 * @brief Called when the default voice is changed.
219 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
220 * @param[in] tts The TTS handle
221 * @param[in] previous_language The previous language
222 * @param[in] previous_voice_type The previous voice type
223 * @param[in] current_language The current language
224 * @param[in] current_voice_type The current voice type
225 * @param[in] user_data The user data passed from the callback registration function
226 * @see tts_set_default_voice_changed_cb()
228 typedef void (*tts_default_voice_changed_cb)(tts_h tts, const char* previous_language, int previous_voice_type,
229 const char* current_language, int current_voice_type, void* user_data);
233 * @brief Called when the engine is changed.
234 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
235 * @param[in] tts The TTS handle
236 * @param[in] engine_id Engine ID
237 * @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)
238 * @param[in] voice_type The default voice type
239 * @param[in] need_credential The necessity of credential
240 * @param[in] user_data The user data passed from the callback registration function
241 * @see tts_set_engine_changed_cb()
243 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);
247 * @brief Called when the option of screen reader is changed.
249 * @param[in] tts The TTS handle
250 * @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.
251 * @param[in] user_data The user data passed from the callback registration function
252 * @see tts_set_screen_reader_changed_cb()
254 typedef void (*tts_screen_reader_changed_cb)(tts_h tts, bool is_on, void* user_data);
258 * @brief Called when the state of TTS service is changed.
260 * @remarks The @a tts handle should not be destroyed in the callback.
261 * @param[in] tts The TTS handle, the same handle for which the callback was set.
262 * @param[in] previous The previous state of TTS service
263 * @param[in] current The current state of TTS service
264 * @param[in] user_data The user data passed from the callback registration function
265 * @pre An application registers this callback using tts_set_service_state_changed_cb() to detect changing state of TTS service.
266 * @see tts_set_service_state_changed_cb()
267 * @see tts_unset_service_state_changed_cb()
269 typedef void (*tts_service_state_changed_cb)(tts_h tts, tts_service_state_e previous, tts_service_state_e current, void* user_data);
272 * @brief Creates a handle for TTS.
273 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
274 * @remarks If the function succeeds, @a tts handle must be released with tts_destroy().
275 * @param[out] tts The TTS handle
276 * @return @c 0 on success,
277 * otherwise a negative error value
278 * @retval #TTS_ERROR_NONE Successful
279 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
280 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
281 * @retval #TTS_ERROR_OUT_OF_MEMORY Out of memory
282 * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
283 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
284 * @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
287 int tts_create(tts_h* tts);
291 * @brief Destroys the handle and disconnects the daemon.
292 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
293 * @param[in] tts The TTS handle
294 * @return @c 0 on success,
295 * otherwise a negative error value
296 * @retval #TTS_ERROR_NONE Successful
297 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
298 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
299 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
302 int tts_destroy(tts_h tts);
306 * @brief Sets the TTS mode.
307 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
308 * @param[in] tts The TTS handle
309 * @param[in] mode The mode
310 * @return @c 0 on success,
311 * otherwise a negative error value
312 * @retval #TTS_ERROR_NONE Successful
313 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
314 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
315 * @retval #TTS_ERROR_INVALID_STATE Invalid state
316 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
317 * @pre The state should be #TTS_STATE_CREATED.
318 * @see tts_get_mode()
320 int tts_set_mode(tts_h tts, tts_mode_e mode);
324 * @brief Gets the TTS mode.
325 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
326 * @param[in] tts The TTS handle
327 * @param[out] mode The mode
328 * @return @c 0 on success,
329 * otherwise a negative error value
330 * @retval #TTS_ERROR_NONE Successful
331 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
332 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
333 * @retval #TTS_ERROR_INVALID_STATE Invalid state
334 * @pre The state should be #TTS_STATE_CREATED.
335 * @see tts_set_mode()
337 int tts_get_mode(tts_h tts, tts_mode_e* mode);
341 * @brief Sets the app credential.
342 * @details Using this API, the application can set a credential.
343 * The credential is a key to verify the authorization about using the engine.
344 * If the application sets the credential, it will be able to use functions of the engine entirely.
345 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
346 * @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.
347 * 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.
348 * @param[in] tts The TTS handle
349 * @param[in] credential The app credential
350 * @return @c 0 on success,
351 * otherwise a negative error value
352 * @retval #TTS_ERROR_NONE Success
353 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
354 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
355 * @retval #TTS_ERROR_INVALID_STATE Invalid state
356 * @pre The state should be #TTS_STATE_CREATED or #TTS_STATE_READY.
359 int tts_set_credential(tts_h tts, const char* credential);
363 * @brief Connects the daemon asynchronously.
364 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
365 * @param[in] tts The TTS handle
366 * @return @c 0 on success,
367 * otherwise a negative error value
368 * @retval #TTS_ERROR_NONE Successful
369 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
370 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
371 * @retval #TTS_ERROR_INVALID_STATE Invalid state
372 * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
373 * @pre The state should be #TTS_STATE_CREATED.
374 * @post If this function is successful, the TTS state will be #TTS_STATE_READY.
375 * If this function is failed, the error callback is called. (e.g. #TTS_ERROR_ENGINE_NOT_FOUND)
376 * @see tts_unprepare()
378 int tts_prepare(tts_h tts);
382 * @brief Disconnects the daemon.
383 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
384 * @param[in] tts The TTS handle
385 * @return @c 0 on success,
386 * otherwise a negative error value
387 * @retval #TTS_ERROR_NONE Successful
388 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
389 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
390 * @retval #TTS_ERROR_INVALID_STATE Invalid state
391 * @pre The state should be #TTS_STATE_READY.
392 * @post If this function is called, the TTS state will be #TTS_STATE_CREATED.
395 int tts_unprepare(tts_h tts);
399 * @brief Connects the daemon synchronously.
401 * @param[in] tts The TTS handle
402 * @return @c 0 on success,
403 * otherwise a negative error value
404 * @retval #TTS_ERROR_NONE Successful
405 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
406 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
407 * @retval #TTS_ERROR_INVALID_STATE Invalid state
408 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
409 * @pre The state should be #TTS_STATE_CREATED.
410 * @post If this function is successful, the TTS state will be #TTS_STATE_READY.
411 * @see tts_unprepare()
413 int tts_prepare_sync(tts_h tts);
417 * @brief Retrieves all supported voices of the current engine using callback function.
418 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
419 * @param[in] tts The TTS handle
420 * @param[in] callback The callback function to invoke
421 * @param[in] user_data The user data to be passed to the callback function
422 * @return @c 0 on success,
423 * otherwise a negative error value
424 * @retval #TTS_ERROR_NONE Successful
425 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
426 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
427 * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
428 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
429 * @post This function invokes tts_supported_voice_cb() repeatedly for getting voices.
430 * @see tts_get_default_voice()
432 int tts_foreach_supported_voices(tts_h tts, tts_supported_voice_cb callback, void* user_data);
436 * @brief Gets the default voice set by the user.
437 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
438 * @remarks If the function succeeds, @a language must be released with free().
439 * @param[in] tts The TTS handle
440 * @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)
441 * @param[out] voice_type The voice type
442 * @return @c 0 on success,
443 * otherwise a negative error value
444 * @retval #TTS_ERROR_NONE Successful
445 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
446 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
447 * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
448 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
449 * @see tts_foreach_supported_voices()
451 int tts_get_default_voice(tts_h tts, char** language, int* voice_type);
455 * @brief Sets the private data to tts engine.
456 * @details The private data is the setting parameter for applying keys provided by the engine.
457 * Using this API, the application can set the private data and use the corresponding key of the engine.
458 * For example, if the engine provides 'girl's voice' as a voice type, the application can set the private data as the following.
459 * int ret = tts_set_private_data(tts_h, "voice_type", "GIRL");
460 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
461 * @remarks If the engine is replaced with the other engine, the key may be ignored.
462 * @param[in] tts The TTS handle
463 * @param[in] key The field name of private data
464 * @param[in] data The data for set
465 * @return @c 0 on success,
466 * otherwise a negative error value
467 * @retval #TTS_ERROR_NONE Successful
468 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
469 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
470 * @retval #TTS_ERROR_INVALID_STATE Invalid state
471 * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
472 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
473 * @pre The state should be #TTS_STATE_READY.
474 * @see tts_get_private_data()
476 int tts_set_private_data(tts_h tts, const char* key, const char* data);
480 * @brief Gets the private data from tts engine.
481 * @details The private data is the information provided by the engine.
482 * Using this API, the application can get the private data which corresponds to the key from the engine.
483 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
484 * @remarks The @a data must be released using free() when it is no longer required.
485 * If the engine is replaced with the other engine, the key may be ignored.
486 * @param[in] tts The TTS handle
487 * @param[in] key The field name of private data
488 * @param[out] data The data field of private data
489 * @return @c 0 on success,
490 * otherwise a negative error value
491 * @retval #TTS_ERROR_NONE Successful
492 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
493 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
494 * @retval #TTS_ERROR_INVALID_STATE Invalid state
495 * @retval #TTS_ERROR_ENGINE_NOT_FOUND Engine not found
496 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
497 * @pre The state should be #TTS_STATE_READY.
498 * @see tts_set_private_data()
500 int tts_get_private_data(tts_h tts, const char* key, char** data);
504 * @brief Gets the maximum byte size for text.
505 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
506 * @param[in] tts The TTS handle
507 * @param[out] size The maximum byte size for text
508 * @return @c 0 on success,
509 * otherwise a negative error value
510 * @retval #TTS_ERROR_NONE Successful
511 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
512 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
513 * @retval #TTS_ERROR_INVALID_STATE Invalid state
514 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
515 * @pre The state should be #TTS_STATE_READY.
516 * @see tts_add_text()
518 int tts_get_max_text_size(tts_h tts, unsigned int* size);
522 * @brief Gets the current state of TTS.
523 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
524 * @param[in] tts The TTS handle
525 * @param[out] state The current state of TTS
526 * @return @c 0 on success,
527 * otherwise a negative error value
528 * @retval #TTS_ERROR_NONE Successful
529 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
530 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
535 int tts_get_state(tts_h tts, tts_state_e* state);
539 * @brief Gets the speed range.
540 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
541 * @param[in] tts The TTS handle
542 * @param[out] min The minimum speed value
543 * @param[out] normal The normal speed value
544 * @param[out] max The maximum speed value
545 * @return @c 0 on success,
546 * otherwise a negative error value
547 * @retval #TTS_ERROR_NONE Successful
548 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
549 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
550 * @retval #TTS_ERROR_INVALID_STATE Invalid state
551 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
552 * @pre The state should be #TTS_STATE_CREATED.
553 * @see tts_add_text()
555 int tts_get_speed_range(tts_h tts, int* min, int* normal, int* max);
559 * @brief Gets the current error message.
560 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
561 * @remarks This function should be called from a tts error callback. Calling in any other context will result in an Operation failed error.
562 * A successful call will allocate @a err_msg, which must be released by calling free() when it is no longer required.
563 * @param[in] tts The TTS handle
564 * @param[out] err_msg The current error message
565 * @return @c 0 on success,
566 * otherwise a negative error value
567 * @retval #TTS_ERROR_NONE Successful
568 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
569 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
570 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
571 * @see tts_set_error_cb()
572 * @see tts_unset_error_cb()
574 int tts_get_error_message(tts_h tts, char** err_msg);
578 * @brief Gets the current state of TTS service.
580 * @param[in] tts The TTS handle
581 * @param[out] service_state The current state of TTS service
582 * @return @c 0 on success,
583 * otherwise a negative error value
584 * @retval #TTS_ERROR_NONE Successful
585 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
586 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
587 * @retval #TTS_ERROR_INVALID_STATE Invalid state
588 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
589 * @pre The TTS state should be one of: #TTS_STATE_READY, #TTS_STATE_PLAYING, #TTS_STATE_PAUSED.
594 int tts_get_service_state(tts_h tts, tts_service_state_e* service_state);
598 * @brief Checks whether screen reader is turned on or not.
600 * @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()'.
601 * 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.
602 * The @a is_on must be released using free() when it is no longer required.
603 * @param[in] tts The TTS handle
604 * @param[out] is_on The current status of screen reader
605 * @return @c 0 on success,
606 * otherwise a negative error value
607 * @retval #TTS_ERROR_NONE Successful
608 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
609 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
610 * @see tts_set_screen_reader_changed_cb()
611 * @see tts_unset_screen_reader_changed_cb()
613 int tts_check_screen_reader_on(tts_h tts, bool* is_on);
617 * @brief Adds a text to the queue.
618 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
619 * @remarks Locale(e.g. setlocale()) MUST be set for utf8 text validation check.
620 * @param[in] tts The TTS handle
621 * @param[in] text An input text based utf8
622 * @param[in] language The language selected from the tts_foreach_supported_voices() (e.g. 'NULL'(Automatic), 'en_US')
623 * @param[in] voice_type The voice type selected from the tts_foreach_supported_voices() (e.g. #TTS_VOICE_TYPE_AUTO, #TTS_VOICE_TYPE_FEMALE)
624 * @param[in] speed A speaking speed (e.g. #TTS_SPEED_AUTO or the value from tts_get_speed_range())
625 * @param[out] utt_id The utterance ID passed to the callback function
626 * @return @c 0 on success,
627 * otherwise a negative error value
628 * @retval #TTS_ERROR_NONE Successful
629 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
630 * @retval #TTS_ERROR_PERMISSION_DENIED Permission denied
631 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
632 * @retval #TTS_ERROR_INVALID_STATE Invalid state
633 * @retval #TTS_ERROR_INVALID_VOICE Invalid voice about language, voice type
634 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
635 * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
636 * @pre The state should be #TTS_STATE_READY, #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
637 * @see tts_get_max_text_size()
638 * @see tts_set_credential()
640 int tts_add_text(tts_h tts, const char* text, const char* language, int voice_type, int speed, int* utt_id);
644 * @brief Starts synthesizing voice from the text and plays the synthesized audio data.
645 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
646 * @param[in] tts The TTS handle
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_PERMISSION_DENIED Permission denied
652 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
653 * @retval #TTS_ERROR_OUT_OF_NETWORK Out of network
654 * @retval #TTS_ERROR_INVALID_STATE Invalid state
655 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
656 * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
657 * @pre The current state should be #TTS_STATE_READY or #TTS_STATE_PAUSED.
658 * @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
659 * @see tts_add_text()
662 * @see tts_utterance_started_cb()
663 * @see tts_utterance_completed_cb()
664 * @see tts_error_cb()
665 * @see tts_set_credential()
667 int tts_play(tts_h tts);
671 * @brief Stops playing the utterance and clears the queue.
672 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
673 * @param[in] tts The TTS handle
674 * @return @c 0 on success,
675 * otherwise a negative error value
676 * @retval #TTS_ERROR_NONE Successful
677 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
678 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
679 * @retval #TTS_ERROR_INVALID_STATE Invalid state
680 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
681 * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
682 * @pre The TTS state should be #TTS_STATE_READY or #TTS_STATE_PLAYING or #TTS_STATE_PAUSED.
683 * @post If this function succeeds, the TTS state will be #TTS_STATE_READY.
684 * This function will remove all text via tts_add_text() and synthesized sound data.
688 int tts_stop(tts_h tts);
692 * @brief Pauses the currently playing utterance.
693 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
694 * @param[in] tts The TTS handle
695 * @return @c 0 on success,
696 * otherwise a negative error value
697 * @retval #TTS_ERROR_NONE Successful
698 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
699 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
700 * @retval #TTS_ERROR_INVALID_STATE Invalid state
701 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
702 * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
703 * @pre The TTS state should be #TTS_STATE_PLAYING.
704 * @post If this function succeeds, the TTS state will be #TTS_STATE_PAUSED.
707 * @see tts_error_cb()
709 int tts_pause(tts_h tts);
712 * @brief Repeats the last added text.
714 * @remarks This function repeats the last added text once again.
715 * If there is no previously added text, this function will not work.
716 * If the language is changed, the last added text is removed from the service.
717 * Before calling this function, please call 'tts_stop()' in order to stop playing the previous one.
718 * If this function succeeds, @a text_repeat must be released with free().
719 * @param[in] tts The TTS handle
720 * @param[out] text_repeat Texts to be played repeatedly
721 * @param[out] utt_id The utterance ID passed to the callback function
723 * @return @c 0 on success,
724 * otherwise a negative error value
725 * @retval #TTS_ERROR_NONE Successful
726 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
727 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
728 * @retval #TTS_ERROR_INVALID_STATE Invalid state
729 * @retval #TTS_ERROR_OPERATION_FAILED Operation failure
730 * @retval #TTS_ERROR_SCREEN_READER_OFF Screen reader is turned off
731 * @pre The state should be #TTS_STATE_READY.
732 * @post If this function succeeds, the TTS state will be #TTS_STATE_PLAYING.
733 * @see tts_add_text()
736 int tts_repeat(tts_h tts, char** text_repeat, int* utt_id);
739 * @brief Registers a callback function to be called when the TTS state changes.
740 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
741 * @param[in] tts The TTS handle
742 * @param[in] callback The callback function to register
743 * @param[in] user_data The user data to be passed to the callback function
744 * @return @c 0 on success,
745 * otherwise a negative error value
746 * @retval #TTS_ERROR_NONE Successful
747 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
748 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
749 * @retval #TTS_ERROR_INVALID_STATE Invalid state
750 * @pre The state should be #TTS_STATE_CREATED.
751 * @see tts_state_changed_cb()
752 * @see tts_unset_state_changed_cb()
754 int tts_set_state_changed_cb(tts_h tts, tts_state_changed_cb callback, void* user_data);
758 * @brief Unregisters the callback function.
759 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
760 * @param[in] tts The TTS handle
761 * @return @c 0 on success,
762 * otherwise a negative error value
763 * @retval #TTS_ERROR_NONE Successful
764 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
765 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
766 * @retval #TTS_ERROR_INVALID_STATE Invalid state
767 * @pre The state should be #TTS_STATE_CREATED.
768 * @see tts_set_state_changed_cb()
770 int tts_unset_state_changed_cb(tts_h tts);
774 * @brief Registers a callback function to detect utterance start.
775 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
776 * @param[in] tts The TTS handle
777 * @param[in] callback The callback function to register
778 * @param[in] user_data The user data to be passed to the callback function
779 * @return @c 0 on success,
780 * otherwise a negative error value
781 * @retval #TTS_ERROR_NONE Successful
782 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
783 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
784 * @retval #TTS_ERROR_INVALID_STATE Invalid state
785 * @pre The state should be #TTS_STATE_CREATED.
786 * @see tts_utterance_started_cb()
787 * @see tts_unset_utterance_started_cb()
789 int tts_set_utterance_started_cb(tts_h tts, tts_utterance_started_cb callback, void* user_data);
793 * @brief Unregisters the callback function.
794 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
795 * @param[in] tts The TTS handle
796 * @return @c 0 on success,
797 * otherwise a negative error value
798 * @retval #TTS_ERROR_NONE Successful
799 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
800 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
801 * @retval #TTS_ERROR_INVALID_STATE Invalid state
802 * @pre The state should be #TTS_STATE_CREATED.
803 * @see tts_set_utterance_started_cb()
805 int tts_unset_utterance_started_cb(tts_h tts);
809 * @brief Registers a callback function to detect utterance completion.
810 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
811 * @param[in] tts The TTS handle
812 * @param[in] callback The callback function to register
813 * @param[in] user_data The user data to be passed to the callback function
814 * @return @c 0 on success,
815 * otherwise a negative error value
816 * @retval #TTS_ERROR_NONE Successful
817 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
818 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
819 * @retval #TTS_ERROR_INVALID_STATE Invalid state
820 * @pre The state should be #TTS_STATE_CREATED.
821 * @see tts_utterance_completed_cb()
822 * @see tts_unset_utterance_completed_cb()
824 int tts_set_utterance_completed_cb(tts_h tts, tts_utterance_completed_cb callback, void* user_data);
828 * @brief Unregisters the callback function.
829 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
830 * @param[in] tts The TTS handle
831 * @return @c 0 on success,
832 * otherwise a negative error value
833 * @retval #TTS_ERROR_NONE Successful
834 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
835 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
836 * @retval #TTS_ERROR_INVALID_STATE Invalid state
837 * @pre The state should be #TTS_STATE_CREATED.
838 * @see tts_set_utterance_completed_cb()
840 int tts_unset_utterance_completed_cb(tts_h tts);
844 * @brief Registers a callback function to detect errors.
845 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
846 * @param[in] tts The TTS handle
847 * @param[in] callback The callback function to register
848 * @param[in] user_data The user data to be passed to the callback function
849 * @return @c 0 on success,
850 * otherwise a negative error value
851 * @retval #TTS_ERROR_NONE Successful
852 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
853 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
854 * @retval #TTS_ERROR_INVALID_STATE Invalid state
855 * @pre The state should be #TTS_STATE_CREATED.
856 * @see tts_error_cb()
857 * @see tts_unset_error_cb()
859 int tts_set_error_cb(tts_h tts, tts_error_cb callback, void* user_data);
863 * @brief Unregisters the callback function.
864 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
865 * @param[in] tts The TTS handle
866 * @return @c 0 on success,
867 * otherwise a negative error value
868 * @retval #TTS_ERROR_NONE Successful
869 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
870 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
871 * @retval #TTS_ERROR_INVALID_STATE Invalid state
872 * @pre The state should be #TTS_STATE_CREATED.
873 * @see tts_set_error_cb()
875 int tts_unset_error_cb(tts_h tts);
879 * @brief Registers a callback function to detect default voice change.
880 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
881 * @param[in] tts The TTS handle
882 * @param[in] callback The callback function to register
883 * @param[in] user_data The user data to be passed to the callback function
884 * @return @c 0 on success,
885 * otherwise a negative error value
886 * @retval #TTS_ERROR_NONE Successful
887 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
888 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
889 * @retval #TTS_ERROR_INVALID_STATE Invalid state
890 * @pre The state should be #TTS_STATE_CREATED.
891 * @see tts_default_voice_changed_cb()
892 * @see tts_unset_default_voice_changed_cb()
894 int tts_set_default_voice_changed_cb(tts_h tts, tts_default_voice_changed_cb callback, void* user_data);
898 * @brief Unregisters the callback function.
899 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
900 * @param[in] tts The TTS handle
901 * @return @c 0 on success,
902 * otherwise a negative error value
903 * @retval #TTS_ERROR_NONE Successful
904 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
905 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
906 * @retval #TTS_ERROR_INVALID_STATE Invalid state
907 * @pre The state should be #TTS_STATE_CREATED.
908 * @see tts_set_default_voice_changed_cb()
910 int tts_unset_default_voice_changed_cb(tts_h tts);
914 * @brief Registers a callback function to detect the engine change.
915 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
916 * @param[in] tts The TTS handle
917 * @param[in] callback The callback function to register
918 * @param[in] user_data The user data to be passed to the callback function
919 * @return @c 0 on success,
920 * otherwise a negative error value
921 * @retval #TTS_ERROR_NONE Successful
922 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
923 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
924 * @retval #TTS_ERROR_INVALID_STATE Invalid state
925 * @pre The state should be #TTS_STATE_CREATED.
926 * @see tts_engine_changed_cb()
927 * @see tts_unset_engine_changed_cb()
929 int tts_set_engine_changed_cb(tts_h tts, tts_engine_changed_cb callback, void* user_data);
933 * @brief Unregisters the callback function.
934 * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
935 * @param[in] tts The TTS handle
936 * @return @c 0 on success,
937 * otherwise a negative error value
938 * @retval #TTS_ERROR_NONE Successful
939 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
940 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
941 * @retval #TTS_ERROR_INVALID_STATE Invalid state
942 * @pre The state should be #TTS_STATE_CREATED.
943 * @see tts_set_engine_changed_cb()
945 int tts_unset_engine_changed_cb(tts_h tts);
949 * @brief Registers a callback function to detect the option of screen reader is changed or not.
951 * @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.
952 * @param[in] tts The TTS handle
953 * @param[in] callback The callback function to register
954 * @param[in] user_data The user data to be passed to the callback function
955 * @return @c 0 on success,
956 * otherwise a negative error value
957 * @retval #TTS_ERROR_NONE Successful
958 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
959 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
960 * @retval #TTS_ERROR_INVALID_STATE Invalid state
961 * @pre The state should be #TTS_STATE_CREATED.
962 * @see tts_screen_reader_changed_cb()
963 * @see tts_unset_screen_reader_changed_cb()
965 int tts_set_screen_reader_changed_cb(tts_h tts, tts_screen_reader_changed_cb callback, void* user_data);
969 * @brief Unregisters the callback function to detect the option of screen reader is changed or not.
971 * @param[in] tts The TTS handle
972 * @return @c 0 on success,
973 * otherwise a negative error value
974 * @retval #TTS_ERROR_NONE Successful
975 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
976 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
977 * @retval #TTS_ERROR_INVALID_STATE Invalid state
978 * @pre The state should be #TTS_STATE_CREATED.
979 * @see tts_set_screen_reader_changed_cb()
981 int tts_unset_screen_reader_changed_cb(tts_h tts);
984 * @brief Sets a callback function to be called when the TTS service state changes.
986 * @param[in] tts The TTS handle
987 * @param[in] callback The callback function to register
988 * @param[in] user_data The user data to be passed to the callback function
989 * @return @c 0 on success,
990 * otherwise a negative error value
991 * @retval #TTS_ERROR_NONE Successful
992 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
993 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
994 * @retval #TTS_ERROR_INVALID_STATE Invalid state
995 * @pre The TTS state should be #TTS_STATE_CREATED.
996 * @see tts_service_state_changed_cb()
997 * @see tts_unset_service_state_changed_cb()
999 int tts_set_service_state_changed_cb(tts_h tts, tts_service_state_changed_cb callback, void* user_data);
1002 * @brief Unsets the callback function.
1004 * @param[in] tts The TTS handle
1005 * @return @c 0 on success,
1006 * otherwise a negative error value
1007 * @retval #TTS_ERROR_NONE Successful
1008 * @retval #TTS_ERROR_NOT_SUPPORTED TTS NOT supported
1009 * @retval #TTS_ERROR_INVALID_PARAMETER Invalid parameter
1010 * @retval #TTS_ERROR_INVALID_STATE Invalid state
1011 * @pre The TTS state should be #TTS_STATE_CREATED.
1012 * @see tts_set_service_state_changed_cb()
1014 int tts_unset_service_state_changed_cb(tts_h tts);
1026 #endif /* __TTS_H__ */