2 * Copyright (c) 2011-2014 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.
27 * @addtogroup CAPI_UIX_STT_MODULE
37 * @brief Enumerations for error codes.
38 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
41 STT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
42 STT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of Memory */
43 STT_ERROR_IO_ERROR = TIZEN_ERROR_IO_ERROR, /**< I/O error */
44 STT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,/**< Invalid parameter */
45 STT_ERROR_TIMED_OUT = TIZEN_ERROR_TIMED_OUT, /**< No answer from the daemon */
46 STT_ERROR_RECORDER_BUSY = TIZEN_ERROR_RESOURCE_BUSY, /**< Device or resource busy */
47 STT_ERROR_OUT_OF_NETWORK = TIZEN_ERROR_NETWORK_DOWN, /**< Network is down */
48 STT_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED,/**< Permission denied */
49 STT_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< STT NOT supported */
50 STT_ERROR_INVALID_STATE = TIZEN_ERROR_STT | 0x01, /**< Invalid state */
51 STT_ERROR_INVALID_LANGUAGE = TIZEN_ERROR_STT | 0x02, /**< Invalid language */
52 STT_ERROR_ENGINE_NOT_FOUND = TIZEN_ERROR_STT | 0x03, /**< No available engine */
53 STT_ERROR_OPERATION_FAILED = TIZEN_ERROR_STT | 0x04, /**< Operation failed */
54 STT_ERROR_NOT_SUPPORTED_FEATURE = TIZEN_ERROR_STT | 0x05, /**< Not supported feature of current engine */
55 STT_ERROR_NO_SPEECH = TIZEN_ERROR_STT | 0x06, /**< No speech while recording */
56 STT_ERROR_IN_PROGRESS_TO_READY = TIZEN_ERROR_STT | 0x07, /**< Progress to ready is not finished */
57 STT_ERROR_IN_PROGRESS_TO_RECORDING = TIZEN_ERROR_STT | 0x08, /**< Progress to recording is not finished */
58 STT_ERROR_IN_PROGRESS_TO_PROCESSING = TIZEN_ERROR_STT | 0x09 /**< Progress to processing is not finished */
62 * @brief Definition for free form dictation and default type.
63 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
65 #define STT_RECOGNITION_TYPE_FREE "stt.recognition.type.FREE"
68 * @brief Definition for continuous free dictation.
69 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
71 #define STT_RECOGNITION_TYPE_FREE_PARTIAL "stt.recognition.type.FREE.PARTIAL"
74 * @brief Definition for search.
75 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
77 #define STT_RECOGNITION_TYPE_SEARCH "stt.recognition.type.SEARCH"
80 * @brief Definition for web search.
81 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
83 #define STT_RECOGNITION_TYPE_WEB_SEARCH "stt.recognition.type.WEB_SEARCH"
86 * @brief Definition for map.
87 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
89 #define STT_RECOGNITION_TYPE_MAP "stt.recognition.type.MAP"
92 * @brief Definition for none message.
93 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
95 #define STT_RESULT_MESSAGE_NONE "stt.result.message.none"
98 * @brief Definition for failed recognition because the speech started too soon.
99 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
101 #define STT_RESULT_MESSAGE_ERROR_TOO_SOON "stt.result.message.error.too.soon"
104 * @brief Definition for failed recognition because the speech is too short.
105 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
107 #define STT_RESULT_MESSAGE_ERROR_TOO_SHORT "stt.result.message.error.too.short"
110 * @brief Definition for failed recognition because the speech is too long.
111 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
113 #define STT_RESULT_MESSAGE_ERROR_TOO_LONG "stt.result.message.error.too.long"
116 * @brief Definition for failed recognition because the speech is too quiet to listen.
117 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
119 #define STT_RESULT_MESSAGE_ERROR_TOO_QUIET "stt.result.message.error.too.quiet"
122 * @brief Definition for failed recognition because the speech is too loud to listen.
123 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
125 #define STT_RESULT_MESSAGE_ERROR_TOO_LOUD "stt.result.message.error.too.loud"
128 * @brief Definition for failed recognition because the speech is too fast to listen.
129 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
131 #define STT_RESULT_MESSAGE_ERROR_TOO_FAST "stt.result.message.error.too.fast"
135 * @brief Enumeration for state.
136 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
139 STT_STATE_CREATED = 0, /**< 'CREATED' state */
140 STT_STATE_READY = 1, /**< 'READY' state */
141 STT_STATE_RECORDING = 2, /**< 'RECORDING' state */
142 STT_STATE_PROCESSING = 3 /**< 'PROCESSING' state*/
146 * @brief Enumeration for result event.
147 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
150 STT_RESULT_EVENT_FINAL_RESULT = 0, /**< Event when the recognition full or last result is ready */
151 STT_RESULT_EVENT_PARTIAL_RESULT, /**< Event when the recognition partial result is ready */
152 STT_RESULT_EVENT_ERROR /**< Event when the recognition has failed */
153 } stt_result_event_e;
156 * @brief Enumeration for result time callback event.
157 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
160 STT_RESULT_TIME_EVENT_BEGINNING = 0, /**< Event when the token is beginning type */
161 STT_RESULT_TIME_EVENT_MIDDLE = 1, /**< Event when the token is middle type */
162 STT_RESULT_TIME_EVENT_END = 2 /**< Event when the token is end type */
163 } stt_result_time_event_e;
166 * @brief Enumeration for silence detection type.
167 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
170 STT_OPTION_SILENCE_DETECTION_FALSE = 0, /**< Silence detection type - False */
171 STT_OPTION_SILENCE_DETECTION_TRUE = 1, /**< Silence detection type - True */
172 STT_OPTION_SILENCE_DETECTION_AUTO = 2 /**< Silence detection type - Auto */
173 } stt_option_silence_detection_e;
176 * @brief A structure of STT handler.
177 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
179 typedef struct stt_s *stt_h;
182 * @brief Called to get the engine information.
183 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
185 * @param[in] engine_id Engine id
186 * @param[in] engine_name Engine name
187 * @param[in] user_data User data passed from the stt_setting_foreach_supported_engines()
189 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
190 * @pre stt_foreach_supported_engines() will invoke this callback.
192 * @see stt_foreach_supported_engines()
194 typedef bool(*stt_supported_engine_cb)(stt_h stt, const char* engine_id, const char* engine_name, void* user_data);
197 * @brief Called when STT gets the recognition result from the engine.
198 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
200 * @remarks After stt_stop() is called, silence is detected from recording, or partial result is occured,
201 * this function is called.
203 * @param[in] stt The STT handle
204 * @param[in] event The result event
205 * @param[in] data Result texts
206 * @param[in] data_count Result text count
207 * @param[in] msg Engine message (e.g. #STT_RESULT_MESSAGE_NONE, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
208 * @param[in] user_data The user data passed from the callback registration function
210 * @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
211 * @post If this function is called and event is #STT_RESULT_EVENT_FINAL_RESULT, the STT state will be #STT_STATE_READY.
214 * @see stt_set_recognition_result_cb()
215 * @see stt_unset_recognition_result_cb()
217 typedef void (*stt_recognition_result_cb)(stt_h stt, stt_result_event_e event, const char** data, int data_count,
218 const char* msg, void *user_data);
221 * @brief Called when STT get the result time stamp in free partial type.
222 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
224 * @param[in] stt The STT handle
225 * @param[in] index The result index
226 * @param[in] event The token event
227 * @param[in] text The result text
228 * @param[in] start_time The start time of result text
229 * @param[in] end_time The end time of result text
230 * @param[in] user_data The user data passed from the foreach function
232 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
234 * @pre stt_recognition_result_cb() should be called.
236 * @see stt_recognition_result_cb()
238 typedef bool (*stt_result_time_cb)(stt_h stt, int index, stt_result_time_event_e event, const char* text,
239 long start_time, long end_time, void* user_data);
242 * @brief Called when the state of STT is changed.
243 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
245 * @param[in] stt The STT handle
246 * @param[in] previous A previous state
247 * @param[in] current A current state
248 * @param[in] user_data The user data passed from the callback registration function
250 * @pre An application registers this callback using stt_set_state_changed_cb() to detect changing state.
252 * @see stt_set_state_changed_cb()
253 * @see stt_unset_state_changed_cb()
255 typedef void (*stt_state_changed_cb)(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
258 * @brief Called when an error occurs.
259 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
261 * @param[in] stt The STT handle
262 * @param[in] reason The error type (e.g. #STT_ERROR_OUT_OF_NETWORK, #STT_ERROR_IO_ERROR)
263 * @param[in] user_data The user data passed from the callback registration function
265 * @pre An application registers this callback using stt_set_error_cb() to detect error.
267 * @see stt_set_error_cb()
268 * @see stt_unset_error_cb()
270 typedef void (*stt_error_cb)(stt_h stt, stt_error_e reason, void *user_data);
273 * @brief Called to retrieve the supported languages.
274 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
275 * @remarks The language is 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.
277 * @param[in] stt The STT handle
278 * @param[in] language The language
279 * @param[in] user_data The user data passed from the foreach function
281 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
282 * @pre stt_foreach_supported_languages() will invoke this callback.
284 * @see stt_foreach_supported_languages()
286 typedef bool (*stt_supported_language_cb)(stt_h stt, const char* language, void* user_data);
289 * @brief Called when the default language is changed.
290 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
292 * @param[in] stt The STT handle
293 * @param[in] previous_language A previous language
294 * @param[in] current_language A current language
295 * @param[in] user_data The user data passed from the callback registration function
297 * @see stt_set_default_language_changed_cb()
299 typedef void (*stt_default_language_changed_cb)(stt_h stt, const char* previous_language,
300 const char* current_language, void* user_data);
303 * @brief Called when the engine is changed.
306 * @param[in] stt The STT handle
307 * @param[in] engine_id Engine id
308 * @param[in] language The default language
309 * @param[in] support_silence support silence detection
310 * @param[in] need_credential necessity of credential
311 * @param[in] user_data The user data passed from the callback registration function
313 * @see stt_set_engine_changed_cb()
315 typedef bool (*stt_engine_changed_cb)(stt_h stt, const char* engine_id, const char* language,
316 bool support_silence, bool need_credential, void* user_data);
319 * @brief Creates a STT handle.
320 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
322 * @privilege %http://tizen.org/privilege/recorder
324 * @remarks If the function succeeds, @a stt handle must be released with stt_destroy().
326 * @param[out] stt The STT handle
328 * @return 0 on success, otherwise a negative error value
329 * @retval #STT_ERROR_NONE Successful
330 * @retval #STT_ERROR_OUT_OF_MEMORY Out of memory
331 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
332 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
333 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
335 * @post If this function is called, the STT state will be #STT_STATE_CREATED.
339 int stt_create(stt_h* stt);
342 * @brief Destroys a STT handle.
343 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
345 * @privilege %http://tizen.org/privilege/recorder
347 * @param[in] stt The STT handle
349 * @return 0 on success, otherwise a negative error value
350 * @retval #STT_ERROR_NONE Successful
351 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
352 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
353 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
357 int stt_destroy(stt_h stt);
360 * @brief Retrieves supported engine information using a callback function.
361 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
363 * @privilege %http://tizen.org/privilege/recorder
365 * @param[in] stt The STT handle
366 * @param[in] callback The callback function to invoke
367 * @param[in] user_data The user data to be passed to the callback function
369 * @return 0 on success, otherwise a negative error value
370 * @retval #STT_ERROR_NONE Success
371 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
372 * @retval #STT_ERROR_INVALID_STATE STT Not initialized
373 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
374 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
376 * @pre The state should be #STT_STATE_CREATED.
377 * @post This function invokes stt_supported_engine_cb() repeatedly for getting engine information.
379 * @see stt_supported_engine_cb()
381 int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data);
384 * @brief Gets the current engine id.
385 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
387 * @privilege %http://tizen.org/privilege/recorder
389 * @remarks If the function is success, @a engine_id must be released using free().
391 * @param[in] stt The STT handle
392 * @param[out] engine_id Engine id
394 * @return 0 on success, otherwise a negative error value
395 * @retval #STT_ERROR_NONE Success
396 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
397 * @retval #STT_ERROR_INVALID_STATE STT Not initialized
398 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
399 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
401 * @pre The state should be #STT_STATE_CREATED.
403 * @see stt_set_engine()
405 int stt_get_engine(stt_h stt, char** engine_id);
408 * @brief Sets the engine id.
409 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
411 * @privilege %http://tizen.org/privilege/recorder
413 * @param[in] stt The STT handle
414 * @param[in] engine_id Engine id
416 * @return 0 on success, otherwise a negative error value
417 * @retval #STT_ERROR_NONE Success
418 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
419 * @retval #STT_ERROR_INVALID_STATE STT Not initialized
420 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
421 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
423 * @pre The state should be #STT_STATE_CREATED.
425 * @see stt_get_engine()
427 int stt_set_engine(stt_h stt, const char* engine_id);
430 * @brief Sets the app credential.
433 * @privilege %http://tizen.org/privilege/recorder
435 * @param[in] stt The STT handle
436 * @param[in] credential The app credential
438 * @return 0 on success, otherwise a negative error value
439 * @retval #STT_ERROR_NONE Success
440 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
441 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
443 * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY.
448 int stt_set_credential(stt_h stt, const char* credential);
451 * @brief Sets the private data to stt engine.
454 * @param[in] stt The STT handle
455 * @param[in] key The field name of private data
456 * @param[in] data The data for set
458 * @return 0 on success, otherwise a negative error value
459 * @retval #STT_ERROR_NONE Successful
460 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
461 * @retval #STT_ERROR_INVALID_STATE Invalid state
462 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
463 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
464 * @retval #STT_ERROR_TIMED_OUT No answer from the daemon
466 * @pre The state should be #STT_STATE_READY.
468 * @see stt_get_private_data()
470 int stt_set_private_data(stt_h stt, const char* key, const char* data);
473 * @brief Gets the private data from stt engine.
476 * @param[in] stt The STT handle
477 * @param[in] key The field name of private data
478 * @param[out] data The data
480 * @return 0 on success, otherwise a negative error value
481 * @retval #STT_ERROR_NONE Successful
482 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
483 * @retval #STT_ERROR_INVALID_STATE Invalid state
484 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
485 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
486 * @retval #STT_ERROR_TIMED_OUT No answer from the daemon
488 * @pre The state should be #STT_STATE_READY.
490 * @see stt_set_private_data()
492 int stt_get_private_data(stt_h stt, const char* key, char** data);
495 * @brief Connects the daemon asynchronously.
496 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
498 * @privilege %http://tizen.org/privilege/recorder
500 * @param[in] stt The STT handle
502 * @return 0 on success, otherwise a negative error value
503 * @retval #STT_ERROR_NONE Successful
504 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
505 * @retval #STT_ERROR_INVALID_STATE Invalid state
506 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
508 * @pre The state should be #STT_STATE_CREATED.
509 * @post If this function is successful, the STT state will be #STT_STATE_READY. \n
510 * If this function is failed, the error callback is called. (e.g. #STT_ERROR_ENGINE_NOT_FOUND)
512 * @see stt_unprepare()
514 int stt_prepare(stt_h stt);
517 * @brief Disconnects the daemon.
518 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
520 * @privilege %http://tizen.org/privilege/recorder
522 * @param[in] stt The STT handle
524 * @return 0 on success, otherwise a negative error value
525 * @retval #STT_ERROR_NONE Successful
526 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
527 * @retval #STT_ERROR_INVALID_STATE Invalid state
528 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
530 * @pre The state should be #STT_STATE_READY.
531 * @post If this function is called, the STT state will be #STT_STATE_CREATED.
535 int stt_unprepare(stt_h stt);
538 * @brief Retrieves all supported languages of current engine using callback function.
539 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
541 * @privilege %http://tizen.org/privilege/recorder
543 * @param[in] stt The STT handle
544 * @param[in] callback The callback function to invoke
545 * @param[in] user_data The user data to be passed to the callback function
547 * @return 0 on success, otherwise a negative error value
548 * @retval #STT_ERROR_NONE Successful
549 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
550 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
551 * @retval #STT_ERROR_ENGINE_NOT_FOUND No available engine
552 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
554 * @post This function invokes stt_supported_language_cb() repeatedly for getting languages.
556 * @see stt_supported_language_cb()
557 * @see stt_get_default_language()
559 int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data);
562 * @brief Gets the default language set by the user.
563 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
565 * @privilege %http://tizen.org/privilege/recorder
566 * @remarks The language is specified as an ISO 3166 alpha-2 two letter country-code followed by ISO 639-1 for the two-letter language code. \n
567 * For example, "ko_KR" for Korean, "en_US" for American English. \n
568 * If the function succeeds, @a language must be released using free() when it is no longer required.
570 * @param[in] stt The STT handle
571 * @param[out] language The language
573 * @return 0 on success, otherwise a negative error value
574 * @retval #STT_ERROR_NONE Successful
575 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
576 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
577 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
579 * @see stt_foreach_supported_languages()
581 int stt_get_default_language(stt_h stt, char** language);
584 * @brief Gets the current STT state.
585 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
587 * @privilege %http://tizen.org/privilege/recorder
589 * @param[in] stt The STT handle
590 * @param[out] state The current STT state
592 * @return 0 on success, otherwise a negative error value
593 * @retval #STT_ERROR_NONE Successful
594 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
595 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
600 * @see stt_state_changed_cb()
602 int stt_get_state(stt_h stt, stt_state_e* state);
605 * @brief Gets the current error message.
608 * @privilege %http://tizen.org/privilege/recorder
609 * @remarks This function should be called during an stt error callback. If not, the error as operation failure will be returned. \n
610 * If the function succeeds, @a err_msg must be released using free() when it is no longer required.
612 * @param[in] stt The STT handle
613 * @param[out] err_msg The current error message
615 * @return 0 on success, otherwise a negative error value
616 * @retval #STT_ERROR_NONE Successful
617 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
618 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
619 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
621 * @see stt_set_error_cb()
622 * @see stt_unset_error_cb()
624 int stt_get_error_message(stt_h stt, char** err_msg);
627 * @brief Checks whether the recognition type is supported.
628 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
630 * @privilege %http://tizen.org/privilege/recorder
632 * @param[in] stt The STT handle
633 * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
634 * @param[out] support The result status @c true = supported, @c false = not supported
636 * @return 0 on success, otherwise a negative error value
637 * @retval #STT_ERROR_NONE Successful
638 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
639 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
640 * @retval #STT_ERROR_INVALID_STATE Invalid state
641 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
643 * @pre The state should be #STT_STATE_READY.
645 int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support);
648 * @brief Sets the silence detection.
649 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
651 * @privilege %http://tizen.org/privilege/recorder
653 * @param[in] stt The STT handle
654 * @param[in] type The option type
656 * @return 0 on success, otherwise a negative error value
657 * @retval #STT_ERROR_NONE Successful
658 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
659 * @retval #STT_ERROR_INVALID_STATE Invalid state
660 * @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
661 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
663 * @pre The state should be #STT_STATE_READY.
665 int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
668 * @brief Sets the sound to start recording.
669 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
671 * @privilege %http://tizen.org/privilege/recorder
673 * @remarks Sound file type should be wav type.
675 * @param[in] stt The STT handle
676 * @param[in] filename The sound file path
678 * @return 0 on success, otherwise a negative error value
679 * @retval #STT_ERROR_NONE Successful
680 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
681 * @retval #STT_ERROR_INVALID_STATE Invalid state
682 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
683 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
685 * @pre The state should be #STT_STATE_READY.
687 int stt_set_start_sound(stt_h stt, const char* filename);
690 * @brief Unsets the sound to start recording.
691 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
693 * @privilege %http://tizen.org/privilege/recorder
695 * @param[in] stt The STT handle
697 * @return 0 on success, otherwise a negative error value
698 * @retval #STT_ERROR_NONE Successful
699 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
700 * @retval #STT_ERROR_INVALID_STATE Invalid state
701 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
702 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
704 * @pre The state should be #STT_STATE_READY.
706 int stt_unset_start_sound(stt_h stt);
709 * @brief Sets the sound to stop recording.
710 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
712 * @privilege %http://tizen.org/privilege/recorder
714 * @remarks Sound file type should be wav type.
716 * @param[in] stt The STT handle
717 * @param[in] filename The sound file path
719 * @return 0 on success, otherwise a negative error value
720 * @retval #STT_ERROR_NONE Successful
721 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
722 * @retval #STT_ERROR_INVALID_STATE Invalid state
723 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
724 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
726 * @pre The state should be #STT_STATE_READY.
728 int stt_set_stop_sound(stt_h stt, const char* filename);
731 * @brief Unsets the sound to stop recording.
732 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
734 * @privilege %http://tizen.org/privilege/recorder
736 * @param[in] stt The STT handle
738 * @return 0 on success, otherwise a negative error value
739 * @retval #STT_ERROR_NONE Successful
740 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
741 * @retval #STT_ERROR_INVALID_STATE Invalid state
742 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
743 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
745 * @pre The state should be #STT_STATE_READY.
747 int stt_unset_stop_sound(stt_h stt);
750 * @brief Starts recording and recognition asynchronously.
751 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
753 * @privilege %http://tizen.org/privilege/recorder
755 * @remarks This function starts recording in the daemon and sending recording data to engine. \n
756 * This work continues until stt_stop(), stt_cancel() or silence detected by engine.
758 * @param[in] stt The STT handle
759 * @param[in] language The language selected from stt_foreach_supported_languages()
760 * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
762 * @return 0 on success, otherwise a negative error value
763 * @retval #STT_ERROR_NONE Successful
764 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
765 * @retval #STT_ERROR_INVALID_STATE Invalid state
766 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
767 * @retval #STT_ERROR_RECORDER_BUSY Recorder busy
768 * @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
769 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
770 * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
772 * @pre The state should be #STT_STATE_READY.
773 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
774 * If this function succeeds, the STT state will be #STT_STATE_RECORDING.
775 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING.
779 * @see stt_state_changed_cb()
781 int stt_start(stt_h stt, const char* language, const char* type);
784 * @brief Finishes the recording and starts recognition processing in engine asynchronously.
785 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
787 * @privilege %http://tizen.org/privilege/recorder
789 * @param[in] stt The STT handle
791 * @return 0 on success, otherwise a negative error value
792 * @retval #STT_ERROR_NONE Successful
793 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
794 * @retval #STT_ERROR_INVALID_STATE Invalid state
795 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
796 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
797 * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
799 * @pre The state should be #STT_STATE_RECORDING.
800 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
801 * If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
802 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_PROCESSING.
803 * After processing of engine, stt_result_cb() is called.
807 * @see stt_state_changed_cb()
809 int stt_stop(stt_h stt);
812 * @brief Cancels processing recognition and recording asynchronously.
813 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
815 * @privilege %http://tizen.org/privilege/recorder
817 * @remarks This function cancels recording and engine cancels recognition processing. \n
818 * After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
820 * @param[in] stt The STT handle
822 * @return 0 on success, otherwise a negative error value
823 * @retval #STT_ERROR_NONE Successful
824 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
825 * @retval #STT_ERROR_INVALID_STATE Invalid state
826 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
827 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
828 * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
830 * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
831 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
832 * If this function succeeds, the STT state will be #STT_STATE_READY.
833 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY.
837 * @see stt_state_changed_cb()
839 int stt_cancel(stt_h stt);
842 * @brief Gets the microphone volume during recording.
843 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
845 * @privilege %http://tizen.org/privilege/recorder
847 * @param[in] stt The STT handle
848 * @param[out] volume Recording volume
850 * @return 0 on success, otherwise a negative error value
851 * @retval #STT_ERROR_NONE Successful
852 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
853 * @retval #STT_ERROR_INVALID_STATE Invalid state
854 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
855 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
857 * @pre The state should be #STT_STATE_RECORDING.
861 int stt_get_recording_volume(stt_h stt, float* volume);
864 * @brief Retrieves the time stamp of the current recognition result using the callback function.
865 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
867 * @privilege %http://tizen.org/privilege/recorder
869 * @remarks This function should be called in stt_recognition_result_cb().
870 * After stt_recognition_result_cb(), result data is NOT valid.
872 * @param[in] stt The STT handle
873 * @param[in] callback The callback function to invoke
874 * @param[in] user_data The user data to be passed to the callback function
876 * @return 0 on success, otherwise a negative error value
877 * @retval #STT_ERROR_NONE Successful
878 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
879 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
880 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
882 * @pre This function should be called in stt_recognition_result_cb().
883 * @post This function invokes stt_result_time_cb() repeatedly for getting time information.
885 * @see stt_result_time_cb()
886 * @see stt_recognition_result_cb()
888 int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data);
891 * @brief Registers a callback function to get the recognition result.
892 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
894 * @privilege %http://tizen.org/privilege/recorder
896 * @param[in] stt The STT handle
897 * @param[in] callback The callback function to register
898 * @param[in] user_data The user data to be passed to the callback function
900 * @return 0 on success, otherwise a negative error value
901 * @retval #STT_ERROR_NONE Successful
902 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
903 * @retval #STT_ERROR_INVALID_STATE Invalid state
904 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
906 * @pre The state should be #STT_STATE_CREATED.
908 * @see stt_recognition_result_cb()
909 * @see stt_unset_recognition_result_cb()
911 int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data);
914 * @brief Unregisters the callback function.
915 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
917 * @privilege %http://tizen.org/privilege/recorder
919 * @param[in] stt The STT handle
921 * @return 0 on success, otherwise a negative error value
922 * @retval #STT_ERROR_NONE Successful
923 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
924 * @retval #STT_ERROR_INVALID_STATE Invalid state
925 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
927 * @pre The state should be #STT_STATE_CREATED.
929 * @see stt_set_recognition_result_cb()
931 int stt_unset_recognition_result_cb(stt_h stt);
934 * @brief Registers a callback function to be called when STT state changes.
935 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
937 * @privilege %http://tizen.org/privilege/recorder
939 * @param[in] stt The STT handle
940 * @param[in] callback The callback function to register
941 * @param[in] user_data The user data to be passed to the callback function
943 * @return 0 on success, otherwise a negative error value
944 * @retval #STT_ERROR_NONE Successful
945 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
946 * @retval #STT_ERROR_INVALID_STATE Invalid state
947 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
949 * @pre The state should be #STT_STATE_CREATED.
951 * @see stt_state_changed_cb()
952 * @see stt_unset_state_changed_cb()
954 int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data);
957 * @brief Unregisters the callback function.
958 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
960 * @privilege %http://tizen.org/privilege/recorder
962 * @param[in] stt The STT handle
964 * @return 0 on success, otherwise a negative error value
965 * @retval #STT_ERROR_NONE Successful
966 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
967 * @retval #STT_ERROR_INVALID_STATE Invalid state
968 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
970 * @pre The state should be #STT_STATE_CREATED.
972 * @see stt_set_state_changed_cb()
974 int stt_unset_state_changed_cb(stt_h stt);
977 * @brief Registers a callback function to be called when an error occurred.
978 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
980 * @privilege %http://tizen.org/privilege/recorder
982 * @param[in] stt The STT handle
983 * @param[in] callback The callback function to register
984 * @param[in] user_data The user data to be passed to the callback function
986 * @return 0 on success, otherwise a negative error value
987 * @retval #STT_ERROR_NONE Successful
988 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
989 * @retval #STT_ERROR_INVALID_STATE Invalid state
990 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
992 * @pre The state should be #STT_STATE_CREATED.
994 * @see stt_error_cb()
995 * @see stt_unset_error_cb()
997 int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data);
1000 * @brief Unregisters the callback function.
1001 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1003 * @privilege %http://tizen.org/privilege/recorder
1005 * @param[in] stt The STT handle
1007 * @return 0 on success, otherwise a negative error value
1008 * @retval #STT_ERROR_NONE Successful
1009 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
1010 * @retval #STT_ERROR_INVALID_STATE Invalid state
1011 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
1013 * @pre The state should be #STT_STATE_CREATED.
1015 * @see stt_set_error_cb()
1017 int stt_unset_error_cb(stt_h stt);
1020 * @brief Registers a callback function to detect the default language change.
1021 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1023 * @privilege %http://tizen.org/privilege/recorder
1025 * @param[in] stt The STT handle
1026 * @param[in] callback The callback function to register
1027 * @param[in] user_data The user data to be passed to the callback function
1029 * @return 0 on success, otherwise a negative error value
1030 * @retval #STT_ERROR_NONE Successful
1031 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
1032 * @retval #STT_ERROR_INVALID_STATE Invalid state
1033 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
1035 * @pre The state should be #STT_STATE_CREATED.
1037 * @see stt_default_language_changed_cb()
1038 * @see stt_unset_default_language_changed_cb()
1040 int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data);
1043 * @brief Unregisters the callback function.
1044 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1046 * @privilege %http://tizen.org/privilege/recorder
1048 * @param[in] stt The STT handle
1050 * @return 0 on success, otherwise a negative error value
1051 * @retval #STT_ERROR_NONE Successful
1052 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
1053 * @retval #STT_ERROR_INVALID_STATE Invalid state
1054 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
1056 * @pre The state should be #STT_STATE_CREATED.
1058 * @see stt_set_default_language_changed_cb()
1060 int stt_unset_default_language_changed_cb(stt_h stt);
1070 #endif /* __STT_H__ */