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.
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 */
59 STT_ERROR_RECORDING_TIMED_OUT = TIZEN_ERROR_STT | 0x10, /**< Recording timed out */
60 STT_ERROR_SERVICE_RESET = TIZEN_ERROR_STT | 0x11 /**< Service reset */
64 * @brief Definition for free form dictation and default type.
65 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
67 #define STT_RECOGNITION_TYPE_FREE "stt.recognition.type.FREE"
70 * @brief Definition for continuous free dictation.
71 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
73 #define STT_RECOGNITION_TYPE_FREE_PARTIAL "stt.recognition.type.FREE.PARTIAL"
76 * @brief Definition for search.
77 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
79 #define STT_RECOGNITION_TYPE_SEARCH "stt.recognition.type.SEARCH"
82 * @brief Definition for web search.
83 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
85 #define STT_RECOGNITION_TYPE_WEB_SEARCH "stt.recognition.type.WEB_SEARCH"
88 * @brief Definition for map.
89 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
91 #define STT_RECOGNITION_TYPE_MAP "stt.recognition.type.MAP"
94 * @brief Definition for none message.
95 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
97 #define STT_RESULT_MESSAGE_NONE "stt.result.message.none"
100 * @brief Definition for failed recognition because the speech started too soon.
101 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
103 #define STT_RESULT_MESSAGE_ERROR_TOO_SOON "stt.result.message.error.too.soon"
106 * @brief Definition for failed recognition because the speech is too short.
107 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
109 #define STT_RESULT_MESSAGE_ERROR_TOO_SHORT "stt.result.message.error.too.short"
112 * @brief Definition for failed recognition because the speech is too long.
113 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
115 #define STT_RESULT_MESSAGE_ERROR_TOO_LONG "stt.result.message.error.too.long"
118 * @brief Definition for failed recognition because the speech is too quiet to listen.
119 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
121 #define STT_RESULT_MESSAGE_ERROR_TOO_QUIET "stt.result.message.error.too.quiet"
124 * @brief Definition for failed recognition because the speech is too loud to listen.
125 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
127 #define STT_RESULT_MESSAGE_ERROR_TOO_LOUD "stt.result.message.error.too.loud"
130 * @brief Definition for failed recognition because the speech is too fast to listen.
131 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133 #define STT_RESULT_MESSAGE_ERROR_TOO_FAST "stt.result.message.error.too.fast"
137 * @brief Enumeration for state.
138 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
141 STT_STATE_CREATED = 0, /**< 'CREATED' state */
142 STT_STATE_READY = 1, /**< 'READY' state */
143 STT_STATE_RECORDING = 2, /**< 'RECORDING' state */
144 STT_STATE_PROCESSING = 3 /**< 'PROCESSING' state*/
148 * @brief Enumeration for result event.
149 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
152 STT_RESULT_EVENT_FINAL_RESULT = 0, /**< Event when the recognition full or last result is ready */
153 STT_RESULT_EVENT_PARTIAL_RESULT, /**< Event when the recognition partial result is ready */
154 STT_RESULT_EVENT_ERROR /**< Event when the recognition has failed */
155 } stt_result_event_e;
158 * @brief Enumeration for result time callback event.
159 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
162 STT_RESULT_TIME_EVENT_BEGINNING = 0, /**< Event when the token is beginning type */
163 STT_RESULT_TIME_EVENT_MIDDLE = 1, /**< Event when the token is middle type */
164 STT_RESULT_TIME_EVENT_END = 2 /**< Event when the token is end type */
165 } stt_result_time_event_e;
168 * @brief Enumeration for silence detection type.
169 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
172 STT_OPTION_SILENCE_DETECTION_FALSE = 0, /**< Silence detection type - False */
173 STT_OPTION_SILENCE_DETECTION_TRUE = 1, /**< Silence detection type - True */
174 STT_OPTION_SILENCE_DETECTION_AUTO = 2 /**< Silence detection type - Auto */
175 } stt_option_silence_detection_e;
178 * @brief A structure of STT handler.
179 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
181 typedef struct stt_s *stt_h;
184 * @brief Called to get the engine information.
185 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
187 * @param[in] engine_id Engine id
188 * @param[in] engine_name Engine name
189 * @param[in] user_data User data passed from the stt_setting_foreach_supported_engines()
191 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
192 * @pre stt_foreach_supported_engines() will invoke this callback.
194 * @see stt_foreach_supported_engines()
196 typedef bool(*stt_supported_engine_cb)(stt_h stt, const char* engine_id, const char* engine_name, void* user_data);
199 * @brief Called when STT gets the recognition result from the engine.
200 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
202 * @remarks After stt_stop() is called, silence is detected from recording, or partial result is occured,
203 * this function is called.
205 * @param[in] stt The STT handle
206 * @param[in] event The result event
207 * @param[in] data Result texts
208 * @param[in] data_count Result text count
209 * @param[in] msg Engine message (e.g. #STT_RESULT_MESSAGE_NONE, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
210 * @param[in] user_data The user data passed from the callback registration function
212 * @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
213 * @post If this function is called and event is #STT_RESULT_EVENT_FINAL_RESULT, the STT state will be #STT_STATE_READY.
216 * @see stt_set_recognition_result_cb()
217 * @see stt_unset_recognition_result_cb()
219 typedef void (*stt_recognition_result_cb)(stt_h stt, stt_result_event_e event, const char** data, int data_count,
220 const char* msg, void *user_data);
223 * @brief Called when STT get the result time stamp in free partial type.
224 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
226 * @param[in] stt The STT handle
227 * @param[in] index The result index
228 * @param[in] event The token event
229 * @param[in] text The result text
230 * @param[in] start_time The start time of result text
231 * @param[in] end_time The end time of result text
232 * @param[in] user_data The user data passed from the foreach function
234 * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
236 * @pre stt_recognition_result_cb() should be called.
238 * @see stt_recognition_result_cb()
240 typedef bool (*stt_result_time_cb)(stt_h stt, int index, stt_result_time_event_e event, const char* text,
241 long start_time, long end_time, void* user_data);
244 * @brief Called when the state of STT is changed.
245 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
247 * @param[in] stt The STT handle
248 * @param[in] previous A previous state
249 * @param[in] current A current state
250 * @param[in] user_data The user data passed from the callback registration function
252 * @pre An application registers this callback using stt_set_state_changed_cb() to detect changing state.
254 * @see stt_set_state_changed_cb()
255 * @see stt_unset_state_changed_cb()
257 typedef void (*stt_state_changed_cb)(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
260 * @brief Called when an error occurs.
261 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
263 * @param[in] stt The STT handle
264 * @param[in] reason The error type (e.g. #STT_ERROR_OUT_OF_NETWORK, #STT_ERROR_IO_ERROR)
265 * @param[in] user_data The user data passed from the callback registration function
267 * @pre An application registers this callback using stt_set_error_cb() to detect error.
269 * @see stt_set_error_cb()
270 * @see stt_unset_error_cb()
272 typedef void (*stt_error_cb)(stt_h stt, stt_error_e reason, void *user_data);
275 * @brief Called to retrieve the supported languages.
276 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
277 * @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.
279 * @param[in] stt The STT handle
280 * @param[in] language The language
281 * @param[in] user_data The user data passed from the foreach function
283 * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
284 * @pre stt_foreach_supported_languages() will invoke this callback.
286 * @see stt_foreach_supported_languages()
288 typedef bool (*stt_supported_language_cb)(stt_h stt, const char* language, void* user_data);
291 * @brief Called when the default language is changed.
292 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
294 * @param[in] stt The STT handle
295 * @param[in] previous_language A previous language
296 * @param[in] current_language A current language
297 * @param[in] user_data The user data passed from the callback registration function
299 * @see stt_set_default_language_changed_cb()
301 typedef void (*stt_default_language_changed_cb)(stt_h stt, const char* previous_language,
302 const char* current_language, void* user_data);
305 * @brief Called when the engine is changed.
308 * @param[in] stt The STT handle
309 * @param[in] engine_id Engine id
310 * @param[in] language The default language
311 * @param[in] support_silence support silence detection
312 * @param[in] need_credential necessity of credential
313 * @param[in] user_data The user data passed from the callback registration function
315 * @see stt_set_engine_changed_cb()
317 typedef bool (*stt_engine_changed_cb)(stt_h stt, const char* engine_id, const char* language,
318 bool support_silence, bool need_credential, void* user_data);
321 * @brief Creates a STT handle.
322 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
324 * @privilege %http://tizen.org/privilege/recorder
326 * @remarks If the function succeeds, @a stt handle must be released with stt_destroy().
328 * @param[out] stt The STT handle
330 * @return 0 on success, otherwise a negative error value
331 * @retval #STT_ERROR_NONE Successful
332 * @retval #STT_ERROR_OUT_OF_MEMORY Out of memory
333 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
334 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
335 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
337 * @post If this function is called, the STT state will be #STT_STATE_CREATED.
341 int stt_create(stt_h* stt);
344 * @brief Destroys a STT handle.
345 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
347 * @privilege %http://tizen.org/privilege/recorder
349 * @param[in] stt The STT handle
351 * @return 0 on success, otherwise a negative error value
352 * @retval #STT_ERROR_NONE Successful
353 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
354 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
355 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
359 int stt_destroy(stt_h stt);
362 * @brief Retrieves supported engine information using a callback function.
363 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
365 * @privilege %http://tizen.org/privilege/recorder
367 * @param[in] stt The STT handle
368 * @param[in] callback The callback function to invoke
369 * @param[in] user_data The user data to be passed to the callback function
371 * @return 0 on success, otherwise a negative error value
372 * @retval #STT_ERROR_NONE Success
373 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
374 * @retval #STT_ERROR_INVALID_STATE STT Not initialized
375 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
376 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
378 * @pre The state should be #STT_STATE_CREATED.
379 * @post This function invokes stt_supported_engine_cb() repeatedly for getting engine information.
381 * @see stt_supported_engine_cb()
383 int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data);
386 * @brief Gets the current engine id.
387 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
389 * @privilege %http://tizen.org/privilege/recorder
391 * @remarks If the function is success, @a engine_id must be released using free().
393 * @param[in] stt The STT handle
394 * @param[out] engine_id Engine id
396 * @return 0 on success, otherwise a negative error value
397 * @retval #STT_ERROR_NONE Success
398 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
399 * @retval #STT_ERROR_INVALID_STATE STT Not initialized
400 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
401 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
403 * @pre The state should be #STT_STATE_CREATED.
405 * @see stt_set_engine()
407 int stt_get_engine(stt_h stt, char** engine_id);
410 * @brief Sets the engine id.
411 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
413 * @privilege %http://tizen.org/privilege/recorder
415 * @param[in] stt The STT handle
416 * @param[in] engine_id Engine id
418 * @return 0 on success, otherwise a negative error value
419 * @retval #STT_ERROR_NONE Success
420 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
421 * @retval #STT_ERROR_INVALID_STATE STT Not initialized
422 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
423 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
425 * @pre The state should be #STT_STATE_CREATED.
427 * @see stt_get_engine()
429 int stt_set_engine(stt_h stt, const char* engine_id);
432 * @brief Sets the app credential.
435 * @privilege %http://tizen.org/privilege/recorder
437 * @param[in] stt The STT handle
438 * @param[in] credential The app credential
440 * @return 0 on success, otherwise a negative error value
441 * @retval #STT_ERROR_NONE Success
442 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
443 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
445 * @pre The state should be #STT_STATE_CREATED or #STT_STATE_READY.
450 int stt_set_credential(stt_h stt, const char* credential);
453 * @brief Sets the private data to stt engine.
456 * @param[in] stt The STT handle
457 * @param[in] key The field name of private data
458 * @param[in] data The data for set
460 * @return 0 on success, otherwise a negative error value
461 * @retval #STT_ERROR_NONE Successful
462 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
463 * @retval #STT_ERROR_INVALID_STATE Invalid state
464 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
465 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
466 * @retval #STT_ERROR_TIMED_OUT No answer from the daemon
468 * @pre The state should be #STT_STATE_READY.
470 * @see stt_get_private_data()
472 int stt_set_private_data(stt_h stt, const char* key, const char* data);
475 * @brief Gets the private data from stt engine.
478 * @param[in] stt The STT handle
479 * @param[in] key The field name of private data
480 * @param[out] data The data
482 * @return 0 on success, otherwise a negative error value
483 * @retval #STT_ERROR_NONE Successful
484 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
485 * @retval #STT_ERROR_INVALID_STATE Invalid state
486 * @retval #STT_ERROR_PERMISSION_DENIED Permission denied
487 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
488 * @retval #STT_ERROR_TIMED_OUT No answer from the daemon
490 * @pre The state should be #STT_STATE_READY.
492 * @see stt_set_private_data()
494 int stt_get_private_data(stt_h stt, const char* key, char** data);
497 * @brief Connects the daemon asynchronously.
498 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
500 * @privilege %http://tizen.org/privilege/recorder
502 * @param[in] stt The STT handle
504 * @return 0 on success, otherwise a negative error value
505 * @retval #STT_ERROR_NONE Successful
506 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
507 * @retval #STT_ERROR_INVALID_STATE Invalid state
508 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
510 * @pre The state should be #STT_STATE_CREATED.
511 * @post If this function is successful, the STT state will be #STT_STATE_READY. \n
512 * If this function is failed, the error callback is called. (e.g. #STT_ERROR_ENGINE_NOT_FOUND)
514 * @see stt_unprepare()
516 int stt_prepare(stt_h stt);
519 * @brief Disconnects the daemon.
520 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
522 * @privilege %http://tizen.org/privilege/recorder
524 * @param[in] stt The STT handle
526 * @return 0 on success, otherwise a negative error value
527 * @retval #STT_ERROR_NONE Successful
528 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
529 * @retval #STT_ERROR_INVALID_STATE Invalid state
530 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
532 * @pre The state should be #STT_STATE_READY.
533 * @post If this function is called, the STT state will be #STT_STATE_CREATED.
537 int stt_unprepare(stt_h stt);
540 * @brief Retrieves all supported languages of current engine using callback function.
541 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
543 * @privilege %http://tizen.org/privilege/recorder
545 * @param[in] stt The STT handle
546 * @param[in] callback The callback function to invoke
547 * @param[in] user_data The user data to be passed to the callback function
549 * @return 0 on success, otherwise a negative error value
550 * @retval #STT_ERROR_NONE Successful
551 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
552 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
553 * @retval #STT_ERROR_ENGINE_NOT_FOUND No available engine
554 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
556 * @post This function invokes stt_supported_language_cb() repeatedly for getting languages.
558 * @see stt_supported_language_cb()
559 * @see stt_get_default_language()
561 int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data);
564 * @brief Gets the default language set by the user.
565 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
567 * @privilege %http://tizen.org/privilege/recorder
568 * @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
569 * For example, "ko_KR" for Korean, "en_US" for American English. \n
570 * If the function succeeds, @a language must be released using free() when it is no longer required.
572 * @param[in] stt The STT handle
573 * @param[out] language The language
575 * @return 0 on success, otherwise a negative error value
576 * @retval #STT_ERROR_NONE Successful
577 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
578 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
579 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
581 * @see stt_foreach_supported_languages()
583 int stt_get_default_language(stt_h stt, char** language);
586 * @brief Gets the current STT state.
587 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
589 * @privilege %http://tizen.org/privilege/recorder
591 * @param[in] stt The STT handle
592 * @param[out] state The current STT state
594 * @return 0 on success, otherwise a negative error value
595 * @retval #STT_ERROR_NONE Successful
596 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
597 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
602 * @see stt_state_changed_cb()
604 int stt_get_state(stt_h stt, stt_state_e* state);
607 * @brief Gets the current error message.
610 * @privilege %http://tizen.org/privilege/recorder
611 * @remarks This function should be called during an stt error callback. If not, the error as operation failure will be returned. \n
612 * If the function succeeds, @a err_msg must be released using free() when it is no longer required.
614 * @param[in] stt The STT handle
615 * @param[out] err_msg The current error message
617 * @return 0 on success, otherwise a negative error value
618 * @retval #STT_ERROR_NONE Successful
619 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
620 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
621 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
623 * @see stt_set_error_cb()
624 * @see stt_unset_error_cb()
626 int stt_get_error_message(stt_h stt, char** err_msg);
629 * @brief Checks whether the recognition type is supported.
630 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
632 * @privilege %http://tizen.org/privilege/recorder
634 * @param[in] stt The STT handle
635 * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
636 * @param[out] support The result status @c true = supported, @c false = not supported
638 * @return 0 on success, otherwise a negative error value
639 * @retval #STT_ERROR_NONE Successful
640 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
641 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
642 * @retval #STT_ERROR_INVALID_STATE Invalid state
643 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
645 * @pre The state should be #STT_STATE_READY.
647 int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support);
650 * @brief Sets the silence detection.
651 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
653 * @privilege %http://tizen.org/privilege/recorder
655 * @param[in] stt The STT handle
656 * @param[in] type The option type
658 * @return 0 on success, otherwise a negative error value
659 * @retval #STT_ERROR_NONE Successful
660 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
661 * @retval #STT_ERROR_INVALID_STATE Invalid state
662 * @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
663 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
665 * @pre The state should be #STT_STATE_READY.
667 int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
670 * @brief Sets the sound to start recording.
671 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
673 * @privilege %http://tizen.org/privilege/recorder
675 * @remarks Sound file type should be wav type.
677 * @param[in] stt The STT handle
678 * @param[in] filename The sound file path
680 * @return 0 on success, otherwise a negative error value
681 * @retval #STT_ERROR_NONE Successful
682 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
683 * @retval #STT_ERROR_INVALID_STATE Invalid state
684 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
685 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
687 * @pre The state should be #STT_STATE_READY.
689 int stt_set_start_sound(stt_h stt, const char* filename);
692 * @brief Unsets the sound to start recording.
693 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
695 * @privilege %http://tizen.org/privilege/recorder
697 * @param[in] stt The STT handle
699 * @return 0 on success, otherwise a negative error value
700 * @retval #STT_ERROR_NONE Successful
701 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
702 * @retval #STT_ERROR_INVALID_STATE Invalid state
703 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
704 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
706 * @pre The state should be #STT_STATE_READY.
708 int stt_unset_start_sound(stt_h stt);
711 * @brief Sets the sound to stop recording.
712 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
714 * @privilege %http://tizen.org/privilege/recorder
716 * @remarks Sound file type should be wav type.
718 * @param[in] stt The STT handle
719 * @param[in] filename The sound file path
721 * @return 0 on success, otherwise a negative error value
722 * @retval #STT_ERROR_NONE Successful
723 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
724 * @retval #STT_ERROR_INVALID_STATE Invalid state
725 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
726 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
728 * @pre The state should be #STT_STATE_READY.
730 int stt_set_stop_sound(stt_h stt, const char* filename);
733 * @brief Unsets the sound to stop recording.
734 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
736 * @privilege %http://tizen.org/privilege/recorder
738 * @param[in] stt The STT handle
740 * @return 0 on success, otherwise a negative error value
741 * @retval #STT_ERROR_NONE Successful
742 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
743 * @retval #STT_ERROR_INVALID_STATE Invalid state
744 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
745 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
747 * @pre The state should be #STT_STATE_READY.
749 int stt_unset_stop_sound(stt_h stt);
752 * @brief Starts recording and recognition asynchronously.
753 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
755 * @privilege %http://tizen.org/privilege/recorder
757 * @remarks This function starts recording in the daemon and sending recording data to engine. \n
758 * This work continues until stt_stop(), stt_cancel() or silence detected by engine.
760 * @param[in] stt The STT handle
761 * @param[in] language The language selected from stt_foreach_supported_languages()
762 * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
764 * @return 0 on success, otherwise a negative error value
765 * @retval #STT_ERROR_NONE Successful
766 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
767 * @retval #STT_ERROR_INVALID_STATE Invalid state
768 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
769 * @retval #STT_ERROR_RECORDER_BUSY Recorder busy
770 * @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
771 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
772 * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
774 * @pre The state should be #STT_STATE_READY.
775 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
776 * If this function succeeds, the STT state will be #STT_STATE_RECORDING.
777 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_RECORDING.
781 * @see stt_state_changed_cb()
783 int stt_start(stt_h stt, const char* language, const char* type);
786 * @brief Finishes the recording and starts recognition processing in engine asynchronously.
787 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
789 * @privilege %http://tizen.org/privilege/recorder
791 * @param[in] stt The STT handle
793 * @return 0 on success, otherwise a negative error value
794 * @retval #STT_ERROR_NONE Successful
795 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
796 * @retval #STT_ERROR_INVALID_STATE Invalid state
797 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
798 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
799 * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
800 * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
801 * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
803 * @pre The state should be #STT_STATE_RECORDING.
804 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
805 * If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
806 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_PROCESSING.
807 * After processing of engine, stt_result_cb() is called.
811 * @see stt_state_changed_cb()
813 int stt_stop(stt_h stt);
816 * @brief Cancels processing recognition and recording asynchronously.
817 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
819 * @privilege %http://tizen.org/privilege/recorder
821 * @remarks This function cancels recording and engine cancels recognition processing. \n
822 * After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
824 * @param[in] stt The STT handle
826 * @return 0 on success, otherwise a negative error value
827 * @retval #STT_ERROR_NONE Successful
828 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
829 * @retval #STT_ERROR_INVALID_STATE Invalid state
830 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
831 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
832 * @retval #STT_ERROR_IN_PROGRESS_TO_READY Progress to ready is not finished
833 * @retval #STT_ERROR_IN_PROGRESS_TO_RECORDING Progress to recording is not finished
834 * @retval #STT_ERROR_IN_PROGRESS_TO_PROCESSING Progress to processing is not finished
836 * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
837 * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
838 * If this function succeeds, the STT state will be #STT_STATE_READY.
839 * If you call this function again before state changes, you will receive STT_ERROR_IN_PROGRESS_TO_READY.
843 * @see stt_state_changed_cb()
845 int stt_cancel(stt_h stt);
848 * @brief Gets the microphone volume during recording.
849 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
851 * @privilege %http://tizen.org/privilege/recorder
853 * @param[in] stt The STT handle
854 * @param[out] volume Recording volume
856 * @return 0 on success, otherwise a negative error value
857 * @retval #STT_ERROR_NONE Successful
858 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
859 * @retval #STT_ERROR_INVALID_STATE Invalid state
860 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
861 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
863 * @pre The state should be #STT_STATE_RECORDING.
867 int stt_get_recording_volume(stt_h stt, float* volume);
870 * @brief Retrieves the time stamp of the current recognition result using the callback function.
871 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
873 * @privilege %http://tizen.org/privilege/recorder
875 * @remarks This function should be called in stt_recognition_result_cb().
876 * After stt_recognition_result_cb(), result data is NOT valid.
878 * @param[in] stt The STT handle
879 * @param[in] callback The callback function to invoke
880 * @param[in] user_data The user data to be passed to the callback function
882 * @return 0 on success, otherwise a negative error value
883 * @retval #STT_ERROR_NONE Successful
884 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
885 * @retval #STT_ERROR_OPERATION_FAILED Operation failure
886 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
888 * @pre This function should be called in stt_recognition_result_cb().
889 * @post This function invokes stt_result_time_cb() repeatedly for getting time information.
891 * @see stt_result_time_cb()
892 * @see stt_recognition_result_cb()
894 int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data);
897 * @brief Registers a callback function to get the recognition result.
898 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
900 * @privilege %http://tizen.org/privilege/recorder
902 * @param[in] stt The STT handle
903 * @param[in] callback The callback function to register
904 * @param[in] user_data The user data to be passed to the callback function
906 * @return 0 on success, otherwise a negative error value
907 * @retval #STT_ERROR_NONE Successful
908 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
909 * @retval #STT_ERROR_INVALID_STATE Invalid state
910 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
912 * @pre The state should be #STT_STATE_CREATED.
914 * @see stt_recognition_result_cb()
915 * @see stt_unset_recognition_result_cb()
917 int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data);
920 * @brief Unregisters the callback function.
921 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
923 * @privilege %http://tizen.org/privilege/recorder
925 * @param[in] stt The STT handle
927 * @return 0 on success, otherwise a negative error value
928 * @retval #STT_ERROR_NONE Successful
929 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
930 * @retval #STT_ERROR_INVALID_STATE Invalid state
931 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
933 * @pre The state should be #STT_STATE_CREATED.
935 * @see stt_set_recognition_result_cb()
937 int stt_unset_recognition_result_cb(stt_h stt);
940 * @brief Registers a callback function to be called when STT state changes.
941 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
943 * @privilege %http://tizen.org/privilege/recorder
945 * @param[in] stt The STT handle
946 * @param[in] callback The callback function to register
947 * @param[in] user_data The user data to be passed to the callback function
949 * @return 0 on success, otherwise a negative error value
950 * @retval #STT_ERROR_NONE Successful
951 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
952 * @retval #STT_ERROR_INVALID_STATE Invalid state
953 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
955 * @pre The state should be #STT_STATE_CREATED.
957 * @see stt_state_changed_cb()
958 * @see stt_unset_state_changed_cb()
960 int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data);
963 * @brief Unregisters the callback function.
964 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
966 * @privilege %http://tizen.org/privilege/recorder
968 * @param[in] stt The STT handle
970 * @return 0 on success, otherwise a negative error value
971 * @retval #STT_ERROR_NONE Successful
972 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
973 * @retval #STT_ERROR_INVALID_STATE Invalid state
974 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
976 * @pre The state should be #STT_STATE_CREATED.
978 * @see stt_set_state_changed_cb()
980 int stt_unset_state_changed_cb(stt_h stt);
983 * @brief Registers a callback function to be called when an error occurred.
984 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
986 * @privilege %http://tizen.org/privilege/recorder
988 * @param[in] stt The STT handle
989 * @param[in] callback The callback function to register
990 * @param[in] user_data The user data to be passed to the callback function
992 * @return 0 on success, otherwise a negative error value
993 * @retval #STT_ERROR_NONE Successful
994 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
995 * @retval #STT_ERROR_INVALID_STATE Invalid state
996 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
998 * @pre The state should be #STT_STATE_CREATED.
1000 * @see stt_error_cb()
1001 * @see stt_unset_error_cb()
1003 int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data);
1006 * @brief Unregisters the callback function.
1007 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1009 * @privilege %http://tizen.org/privilege/recorder
1011 * @param[in] stt The STT handle
1013 * @return 0 on success, otherwise a negative error value
1014 * @retval #STT_ERROR_NONE Successful
1015 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
1016 * @retval #STT_ERROR_INVALID_STATE Invalid state
1017 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
1019 * @pre The state should be #STT_STATE_CREATED.
1021 * @see stt_set_error_cb()
1023 int stt_unset_error_cb(stt_h stt);
1026 * @brief Registers a callback function to detect the default language change.
1027 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1029 * @privilege %http://tizen.org/privilege/recorder
1031 * @param[in] stt The STT handle
1032 * @param[in] callback The callback function to register
1033 * @param[in] user_data The user data to be passed to the callback function
1035 * @return 0 on success, otherwise a negative error value
1036 * @retval #STT_ERROR_NONE Successful
1037 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
1038 * @retval #STT_ERROR_INVALID_STATE Invalid state
1039 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
1041 * @pre The state should be #STT_STATE_CREATED.
1043 * @see stt_default_language_changed_cb()
1044 * @see stt_unset_default_language_changed_cb()
1046 int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data);
1049 * @brief Unregisters the callback function.
1050 * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
1052 * @privilege %http://tizen.org/privilege/recorder
1054 * @param[in] stt The STT handle
1056 * @return 0 on success, otherwise a negative error value
1057 * @retval #STT_ERROR_NONE Successful
1058 * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
1059 * @retval #STT_ERROR_INVALID_STATE Invalid state
1060 * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
1062 * @pre The state should be #STT_STATE_CREATED.
1064 * @see stt_set_default_language_changed_cb()
1066 int stt_unset_default_language_changed_cb(stt_h stt);
1076 #endif /* __STT_H__ */