updates codes to sync with the latest 2.4 spin code
[platform/core/uifw/stt.git] / include / stt.h
1 /*
2  * Copyright (c) 2011-2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __STT_H__
18 #define __STT_H__
19
20 #include <tizen.h>
21
22 /**
23  * @file stt.h
24  */
25
26 /**
27 * @addtogroup CAPI_UIX_STT_MODULE
28 * @{
29 */
30
31 #ifdef __cplusplus
32 extern "C"
33 {
34 #endif
35
36 /**
37  * @brief Enumerations for error codes.
38  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
39 */
40 typedef enum {
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_e;
56
57 /**
58  * @brief Definition for free form dictation and default type.
59  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
60 */
61 #define STT_RECOGNITION_TYPE_FREE               "stt.recognition.type.FREE"
62
63 /**
64  * @brief Definition for continuous free dictation.
65  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
66 */
67 #define STT_RECOGNITION_TYPE_FREE_PARTIAL       "stt.recognition.type.FREE.PARTIAL"
68
69 /**
70  * @brief Definition for search.
71  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
72 */
73 #define STT_RECOGNITION_TYPE_SEARCH             "stt.recognition.type.SEARCH"
74
75 /**
76  * @brief Definition for web search.
77  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
78 */
79 #define STT_RECOGNITION_TYPE_WEB_SEARCH         "stt.recognition.type.WEB_SEARCH"
80
81 /**
82  * @brief Definition for map.
83  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
84 */
85 #define STT_RECOGNITION_TYPE_MAP                "stt.recognition.type.MAP"
86
87 /**
88  * @brief Definition for none message.
89  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
90 */
91 #define STT_RESULT_MESSAGE_NONE                 "stt.result.message.none"
92
93 /**
94  * @brief Definition for failed recognition because the speech started too soon.
95  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
96 */
97 #define STT_RESULT_MESSAGE_ERROR_TOO_SOON       "stt.result.message.error.too.soon"
98
99 /**
100  * @brief Definition for failed recognition because the speech is too short.
101  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
102 */
103 #define STT_RESULT_MESSAGE_ERROR_TOO_SHORT      "stt.result.message.error.too.short"
104
105 /**
106  * @brief Definition for failed recognition because the speech is too long.
107  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
108 */
109 #define STT_RESULT_MESSAGE_ERROR_TOO_LONG       "stt.result.message.error.too.long"
110
111 /**
112  * @brief Definition for failed recognition because the speech is too quiet to listen.
113  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
114 */
115 #define STT_RESULT_MESSAGE_ERROR_TOO_QUIET      "stt.result.message.error.too.quiet"
116
117 /**
118  * @brief Definition for failed recognition because the speech is too loud to listen.
119  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
120 */
121 #define STT_RESULT_MESSAGE_ERROR_TOO_LOUD       "stt.result.message.error.too.loud"
122
123 /**
124  * @brief Definition for failed recognition because the speech is too fast to listen.
125  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
126 */
127 #define STT_RESULT_MESSAGE_ERROR_TOO_FAST       "stt.result.message.error.too.fast"
128
129
130 /**
131  * @brief Enumeration for state.
132  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
133 */
134 typedef enum {
135         STT_STATE_CREATED       = 0,            /**< 'CREATED' state */
136         STT_STATE_READY         = 1,            /**< 'READY' state */
137         STT_STATE_RECORDING     = 2,            /**< 'RECORDING' state */
138         STT_STATE_PROCESSING    = 3             /**< 'PROCESSING' state*/
139 }stt_state_e;
140
141 /**
142  * @brief Enumeration for result event.
143  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
144 */
145 typedef enum {
146         STT_RESULT_EVENT_FINAL_RESULT = 0,      /**< Event when the recognition full or last result is ready  */
147         STT_RESULT_EVENT_PARTIAL_RESULT,        /**< Event when the recognition partial result is ready  */
148         STT_RESULT_EVENT_ERROR                  /**< Event when the recognition has failed */
149 }stt_result_event_e;
150
151 /**
152  * @brief Enumeration for result time callback event.
153  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
154 */
155 typedef enum {
156         STT_RESULT_TIME_EVENT_BEGINNING = 0,    /**< Event when the token is beginning type */
157         STT_RESULT_TIME_EVENT_MIDDLE = 1,       /**< Event when the token is middle type */
158         STT_RESULT_TIME_EVENT_END = 2           /**< Event when the token is end type */
159 }stt_result_time_event_e;
160
161 /**
162  * @brief Enumeration for silence detection type.
163  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
164 */
165 typedef enum {
166         STT_OPTION_SILENCE_DETECTION_FALSE = 0, /**< Silence detection type - False */
167         STT_OPTION_SILENCE_DETECTION_TRUE = 1,  /**< Silence detection type - True */
168         STT_OPTION_SILENCE_DETECTION_AUTO = 2   /**< Silence detection type - Auto */
169 }stt_option_silence_detection_e;
170
171 /**
172  * @brief A structure of STT handler.
173  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
174 */
175 typedef struct stt_s *stt_h;
176
177 /**
178  * @brief Called to get the engine information.
179  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
180  *
181  * @param[in] engine_id Engine id
182  * @param[in] engine_name Engine name
183  * @param[in] user_data User data passed from the stt_setting_foreach_supported_engines()
184  *
185  * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
186  * @pre stt_foreach_supported_engines() will invoke this callback.
187  *
188  * @see stt_foreach_supported_engines()
189 */
190 typedef bool(*stt_supported_engine_cb)(stt_h stt, const char* engine_id, const char* engine_name, void* user_data);
191
192 /**
193  * @brief Called when STT gets the recognition result from the engine.
194  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
195  *
196  * @remarks After stt_stop() is called, silence is detected from recording, or partial result is occured,
197  *      this function is called.
198  *
199  * @param[in] stt The STT handle
200  * @param[in] event The result event
201  * @param[in] data Result texts
202  * @param[in] data_count Result text count
203  * @param[in] msg Engine message (e.g. #STT_RESULT_MESSAGE_NONE, #STT_RESULT_MESSAGE_ERROR_TOO_SHORT)
204  * @param[in] user_data The user data passed from the callback registration function
205  *
206  * @pre stt_stop() will invoke this callback if you register it using stt_set_result_cb().
207  * @post If this function is called and event is #STT_RESULT_EVENT_FINAL_RESULT, the STT state will be #STT_STATE_READY.
208  *
209  * @see stt_stop()
210  * @see stt_set_recognition_result_cb()
211  * @see stt_unset_recognition_result_cb()
212 */
213 typedef void (*stt_recognition_result_cb)(stt_h stt, stt_result_event_e event, const char** data, int data_count,
214                                           const char* msg, void *user_data);
215
216 /**
217  * @brief Called when STT get the result time stamp in free partial type.
218  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
219  *
220  * @param[in] stt The STT handle
221  * @param[in] index The result index
222  * @param[in] event The token event
223  * @param[in] text The result text
224  * @param[in] start_time The start time of result text
225  * @param[in] end_time The end time of result text
226  * @param[in] user_data The user data passed from the foreach function
227  *
228  * @return @c true to continue with the next iteration of the loop \n @c false to break out of the loop
229  *
230  * @pre stt_recognition_result_cb() should be called.
231  *
232  * @see stt_recognition_result_cb()
233 */
234 typedef bool (*stt_result_time_cb)(stt_h stt, int index, stt_result_time_event_e event, const char* text,
235                                    long start_time, long end_time, void* user_data);
236
237 /**
238  * @brief Called when the state of STT is changed.
239  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
240  *
241  * @param[in] stt The STT handle
242  * @param[in] previous A previous state
243  * @param[in] current A current state
244  * @param[in] user_data The user data passed from the callback registration function
245  *
246  * @pre An application registers this callback using stt_set_state_changed_cb() to detect changing state.
247  *
248  * @see stt_set_state_changed_cb()
249  * @see stt_unset_state_changed_cb()
250 */
251 typedef void (*stt_state_changed_cb)(stt_h stt, stt_state_e previous, stt_state_e current, void* user_data);
252
253 /**
254  * @brief Called when an error occurs.
255  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
256  *
257  * @param[in] stt The STT handle
258  * @param[in] reason The error type (e.g. #STT_ERROR_OUT_OF_NETWORK, #STT_ERROR_IO_ERROR)
259  * @param[in] user_data The user data passed from the callback registration function
260  *
261  * @pre An application registers this callback using stt_set_error_cb() to detect error.
262  *
263  * @see stt_set_error_cb()
264  * @see stt_unset_error_cb()
265 */
266 typedef void (*stt_error_cb)(stt_h stt, stt_error_e reason, void *user_data);
267
268 /**
269  * @brief Called to retrieve the supported languages.
270  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
271  * @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.
272  *
273  * @param[in] stt The STT handle
274  * @param[in] language The language
275  * @param[in] user_data The user data passed from the foreach function
276  *
277  * @return @c true to continue with the next iteration of the loop, \n @c false to break out of the loop
278  * @pre stt_foreach_supported_languages() will invoke this callback.
279  *
280  * @see stt_foreach_supported_languages()
281 */
282 typedef bool (*stt_supported_language_cb)(stt_h stt, const char* language, void* user_data);
283
284 /**
285  * @brief Called when the default language is changed.
286  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
287  *
288  * @param[in] stt The STT handle
289  * @param[in] previous_language A previous language
290  * @param[in] current_language A current language
291  * @param[in] user_data The user data passed from the callback registration function
292  *
293  * @see stt_set_default_language_changed_cb()
294 */
295 typedef void (*stt_default_language_changed_cb)(stt_h stt, const char* previous_language,
296                                                 const char* current_language, void* user_data);
297
298 /**
299  * @brief Creates a STT handle.
300  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
301  * @privlevel public
302  * @privilege %http://tizen.org/privilege/recorder
303  *
304  * @remarks If the function succeeds, @a stt handle must be released with stt_destroy().
305  *
306  * @param[out] stt The STT handle
307  *
308  * @return 0 on success, otherwise a negative error value
309  * @retval #STT_ERROR_NONE Successful
310  * @retval #STT_ERROR_OUT_OF_MEMORY Out of memory
311  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
312  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
313  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
314  *
315  * @post If this function is called, the STT state will be #STT_STATE_CREATED.
316  *
317  * @see stt_destroy()
318 */
319 int stt_create(stt_h* stt);
320
321 /**
322  * @brief Destroys a STT handle.
323  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
324  * @privlevel public
325  * @privilege %http://tizen.org/privilege/recorder
326  *
327  * @param[in] stt The STT handle
328  *
329  * @return 0 on success, otherwise a negative error value
330  * @retval #STT_ERROR_NONE Successful
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
334  *
335  * @see stt_create()
336 */
337 int stt_destroy(stt_h stt);
338
339 /**
340  * @brief Retrieves supported engine information using a callback function.
341  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
342  * @privlevel public
343  * @privilege %http://tizen.org/privilege/recorder
344  *
345  * @param[in] stt The STT handle
346  * @param[in] callback The callback function to invoke
347  * @param[in] user_data The user data to be passed to the callback function
348  *
349  * @return 0 on success, otherwise a negative error value
350  * @retval #STT_ERROR_NONE Success
351  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
352  * @retval #STT_ERROR_INVALID_STATE STT Not initialized
353  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
354  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
355  *
356  * @pre The state should be #STT_STATE_CREATED.
357  * @post This function invokes stt_supported_engine_cb() repeatedly for getting engine information.
358  *
359  * @see stt_supported_engine_cb()
360 */
361 int stt_foreach_supported_engines(stt_h stt, stt_supported_engine_cb callback, void* user_data);
362
363 /**
364  * @brief Gets the current engine id.
365  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
366  * @privlevel public
367  * @privilege %http://tizen.org/privilege/recorder
368  *
369  * @remarks If the function is success, @a engine_id must be released using free().
370  *
371  * @param[in] stt The STT handle
372  * @param[out] engine_id Engine id
373  *
374  * @return 0 on success, otherwise a negative error value
375  * @retval #STT_ERROR_NONE Success
376  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
377  * @retval #STT_ERROR_INVALID_STATE STT Not initialized
378  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
379  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
380  *
381  * @pre The state should be #STT_STATE_CREATED.
382  *
383  * @see stt_set_engine()
384 */
385 int stt_get_engine(stt_h stt, char** engine_id);
386
387 /**
388  * @brief Sets the engine id.
389  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
390  * @privlevel public
391  * @privilege %http://tizen.org/privilege/recorder
392  *
393  * @param[in] stt The STT handle
394  * @param[in] engine_id Engine id
395  *
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
402  *
403  * @pre The state should be #STT_STATE_CREATED.
404  *
405  * @see stt_get_engine()
406 */
407 int stt_set_engine(stt_h stt, const char* engine_id);
408
409 /**
410  * @brief Connects the daemon asynchronously.
411  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
412  * @privlevel public
413  * @privilege %http://tizen.org/privilege/recorder
414  *
415  * @param[in] stt The STT handle
416  *
417  * @return 0 on success, otherwise a negative error value
418  * @retval #STT_ERROR_NONE Successful
419  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
420  * @retval #STT_ERROR_INVALID_STATE Invalid state
421  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
422  *
423  * @pre The state should be #STT_STATE_CREATED.
424  * @post If this function is successful, the STT state will be #STT_STATE_READY. \n
425  *      If this function is failed, the error callback is called. (e.g. #STT_ERROR_ENGINE_NOT_FOUND)
426  *
427  * @see stt_unprepare()
428 */
429 int stt_prepare(stt_h stt);
430
431 /**
432  * @brief Disconnects the daemon.
433  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
434  * @privlevel public
435  * @privilege %http://tizen.org/privilege/recorder
436  *
437  * @param[in] stt The STT handle
438  *
439  * @return 0 on success, otherwise a negative error value
440  * @retval #STT_ERROR_NONE Successful
441  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
442  * @retval #STT_ERROR_INVALID_STATE Invalid state
443  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
444  *
445  * @pre The state should be #STT_STATE_READY.
446  * @post If this function is called, the STT state will be #STT_STATE_CREATED.
447  *
448  * @see stt_prepare()
449 */
450 int stt_unprepare(stt_h stt);
451
452 /**
453  * @brief Retrieves all supported languages of current engine using callback function.
454  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
455  * @privlevel public
456  * @privilege %http://tizen.org/privilege/recorder
457  *
458  * @param[in] stt The STT handle
459  * @param[in] callback The callback function to invoke
460  * @param[in] user_data The user data to be passed to the callback function
461  *
462  * @return 0 on success, otherwise a negative error value
463  * @retval #STT_ERROR_NONE Successful
464  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
465  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
466  * @retval #STT_ERROR_ENGINE_NOT_FOUND No available engine
467  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
468  *
469  * @post This function invokes stt_supported_language_cb() repeatedly for getting languages.
470  *
471  * @see stt_supported_language_cb()
472  * @see stt_get_default_language()
473 */
474 int stt_foreach_supported_languages(stt_h stt, stt_supported_language_cb callback, void* user_data);
475
476 /**
477  * @brief Gets the default language set by the user.
478  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
479  * @privlevel public
480  * @privilege %http://tizen.org/privilege/recorder
481  * @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
482  * For example, "ko_KR" for Korean, "en_US" for American English. \n
483  * If the function succeeds, @a language must be released using free() when it is no longer required.
484  *
485  * @param[in] stt The STT handle
486  * @param[out] language The language
487  *
488  * @return 0 on success, otherwise a negative error value
489  * @retval #STT_ERROR_NONE Successful
490  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
491  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
492  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
493  *
494  * @see stt_foreach_supported_languages()
495 */
496 int stt_get_default_language(stt_h stt, char** language);
497
498 /**
499  * @brief Gets the current STT state.
500  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
501  * @privlevel public
502  * @privilege %http://tizen.org/privilege/recorder
503  *
504  * @param[in] stt The STT handle
505  * @param[out] state The current STT state
506  *
507  * @return 0 on success, otherwise a negative error value
508  * @retval #STT_ERROR_NONE Successful
509  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
510  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
511  *
512  * @see stt_start()
513  * @see stt_stop()
514  * @see stt_cancel()
515  * @see stt_state_changed_cb()
516 */
517 int stt_get_state(stt_h stt, stt_state_e* state);
518
519 /**
520  * @brief Checks whether the recognition type is supported.
521  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
522  * @privlevel public
523  * @privilege %http://tizen.org/privilege/recorder
524  *
525  * @param[in] stt The STT handle
526  * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
527  * @param[out] support The result status @c true = supported, @c false = not supported
528  *
529  * @return 0 on success, otherwise a negative error value
530  * @retval #STT_ERROR_NONE Successful
531  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
532  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
533  * @retval #STT_ERROR_INVALID_STATE Invalid state
534  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
535  *
536  * @pre The state should be #STT_STATE_READY.
537 */
538 int stt_is_recognition_type_supported(stt_h stt, const char* type, bool* support);
539
540 /**
541  * @brief Sets the silence detection.
542  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
543  * @privlevel public
544  * @privilege %http://tizen.org/privilege/recorder
545  *
546  * @param[in] stt The STT handle
547  * @param[in] type The option type
548  *
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_INVALID_STATE Invalid state
553  * @retval #STT_ERROR_NOT_SUPPORTED_FEATURE Not supported feature of current engine
554  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
555  *
556  * @pre The state should be #STT_STATE_READY.
557 */
558 int stt_set_silence_detection(stt_h stt, stt_option_silence_detection_e type);
559
560 /**
561  * @brief Sets the sound to start recording.
562  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
563  * @privlevel public
564  * @privilege %http://tizen.org/privilege/recorder
565  *
566  * @remarks Sound file type should be wav type.
567  *
568  * @param[in] stt The STT handle
569  * @param[in] filename The sound file path
570  *
571  * @return 0 on success, otherwise a negative error value
572  * @retval #STT_ERROR_NONE Successful
573  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
574  * @retval #STT_ERROR_INVALID_STATE Invalid state
575  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
576  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
577  *
578  * @pre The state should be #STT_STATE_READY.
579 */
580 int stt_set_start_sound(stt_h stt, const char* filename);
581
582 /**
583  * @brief Unsets the sound to start recording.
584  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
585  * @privlevel public
586  * @privilege %http://tizen.org/privilege/recorder
587  *
588  * @param[in] stt The STT handle
589  *
590  * @return 0 on success, otherwise a negative error value
591  * @retval #STT_ERROR_NONE Successful
592  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
593  * @retval #STT_ERROR_INVALID_STATE Invalid state
594  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
595  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
596  *
597  * @pre The state should be #STT_STATE_READY.
598 */
599 int stt_unset_start_sound(stt_h stt);
600
601 /**
602  * @brief Sets the sound to stop recording.
603  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
604  * @privlevel public
605  * @privilege %http://tizen.org/privilege/recorder
606  *
607  * @remarks Sound file type should be wav type.
608  *
609  * @param[in] stt The STT handle
610  * @param[in] filename The sound file path
611  *
612  * @return 0 on success, otherwise a negative error value
613  * @retval #STT_ERROR_NONE Successful
614  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
615  * @retval #STT_ERROR_INVALID_STATE Invalid state
616  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
617  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
618  *
619  * @pre The state should be #STT_STATE_READY.
620 */
621 int stt_set_stop_sound(stt_h stt, const char* filename);
622
623 /**
624  * @brief Unsets the sound to stop recording.
625  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
626  * @privlevel public
627  * @privilege %http://tizen.org/privilege/recorder
628  *
629  * @param[in] stt The STT handle
630  *
631  * @return 0 on success, otherwise a negative error value
632  * @retval #STT_ERROR_NONE Successful
633  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
634  * @retval #STT_ERROR_INVALID_STATE Invalid state
635  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
636  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
637  *
638  * @pre The state should be #STT_STATE_READY.
639 */
640 int stt_unset_stop_sound(stt_h stt);
641
642 /**
643  * @brief Starts recording and recognition asynchronously.
644  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
645  * @privlevel public
646  * @privilege %http://tizen.org/privilege/recorder
647  *
648  * @remarks This function starts recording in the daemon and sending recording data to engine. \n
649  * This work continues until stt_stop(), stt_cancel() or silence detected by engine.
650  *
651  * @param[in] stt The STT handle
652  * @param[in] language The language selected from stt_foreach_supported_languages()
653  * @param[in] type The type for recognition (e.g. #STT_RECOGNITION_TYPE_FREE, #STT_RECOGNITION_TYPE_FREE_PARTIAL)
654  *
655  * @return 0 on success, otherwise a negative error value
656  * @retval #STT_ERROR_NONE Successful
657  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
658  * @retval #STT_ERROR_INVALID_STATE Invalid state
659  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
660  * @retval #STT_ERROR_RECORDER_BUSY Recorder busy
661  * @retval #STT_ERROR_INVALID_LANGUAGE Invalid language
662  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
663  *
664  * @pre The state should be #STT_STATE_READY.
665  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
666  * If this function succeeds, the STT state will be #STT_STATE_RECORDING.
667  *
668  * @see stt_stop()
669  * @see stt_cancel()
670  * @see stt_state_changed_cb()
671 */
672 int stt_start(stt_h stt, const char* language, const char* type);
673
674 /**
675  * @brief Finishes the recording and starts recognition processing in engine asynchronously.
676  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
677  * @privlevel public
678  * @privilege %http://tizen.org/privilege/recorder
679  *
680  * @param[in] stt The STT handle
681  *
682  * @return 0 on success, otherwise a negative error value
683  * @retval #STT_ERROR_NONE Successful
684  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
685  * @retval #STT_ERROR_INVALID_STATE Invalid state
686  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
687  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
688  *
689  * @pre The state should be #STT_STATE_RECORDING.
690  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
691  * If this function succeeds, the STT state will be #STT_STATE_PROCESSING. \n
692  * After processing of engine, stt_result_cb() is called.
693  *
694  * @see stt_start()
695  * @see stt_cancel()
696  * @see stt_state_changed_cb()
697 */
698 int stt_stop(stt_h stt);
699
700 /**
701  * @brief Cancels processing recognition and recording asynchronously.
702  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
703  * @privlevel public
704  * @privilege %http://tizen.org/privilege/recorder
705  *
706  * @remarks This function cancels recording and engine cancels recognition processing. \n
707  * After successful cancel, stt_state_changed_cb() is called otherwise if error is occurred, stt_error_cb() is called.
708  *
709  * @param[in] stt The STT handle
710  *
711  * @return 0 on success, otherwise a negative error value
712  * @retval #STT_ERROR_NONE Successful
713  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
714  * @retval #STT_ERROR_INVALID_STATE Invalid state
715  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
716  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
717  *
718  * @pre The state should be #STT_STATE_RECORDING or #STT_STATE_PROCESSING.
719  * @post It will invoke stt_state_changed_cb(), if you register a callback with stt_state_changed_cb(). \n
720  * If this function succeeds, the STT state will be #STT_STATE_READY.
721  *
722  * @see stt_start()
723  * @see stt_stop()
724  * @see stt_state_changed_cb()
725 */
726 int stt_cancel(stt_h stt);
727
728 /**
729  * @brief Gets the microphone volume during recording.
730  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
731  * @privlevel public
732  * @privilege %http://tizen.org/privilege/recorder
733  *
734  * @param[in] stt The STT handle
735  * @param[out] volume Recording volume
736  *
737  * @return 0 on success, otherwise a negative error value
738  * @retval #STT_ERROR_NONE Successful
739  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
740  * @retval #STT_ERROR_INVALID_STATE Invalid state
741  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
742  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
743  *
744  * @pre The state should be #STT_STATE_RECORDING.
745  *
746  * @see stt_start()
747 */
748 int stt_get_recording_volume(stt_h stt, float* volume);
749
750 /**
751  * @brief Retrieves the time stamp of the current recognition result using the callback function.
752  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
753  * @privlevel public
754  * @privilege %http://tizen.org/privilege/recorder
755  *
756  * @remarks This function should be called in stt_recognition_result_cb().
757  *      After stt_recognition_result_cb(), result data is NOT valid.
758  *
759  * @param[in] stt The STT handle
760  * @param[in] callback The callback function to invoke
761  * @param[in] user_data The user data to be passed to the callback function
762  *
763  * @return 0 on success, otherwise a negative error value
764  * @retval #STT_ERROR_NONE Successful
765  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
766  * @retval #STT_ERROR_OPERATION_FAILED Operation failure
767  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
768  *
769  * @pre This function should be called in stt_recognition_result_cb().
770  * @post This function invokes stt_result_time_cb() repeatedly for getting time information.
771  *
772  * @see stt_result_time_cb()
773  * @see stt_recognition_result_cb()
774 */
775 int stt_foreach_detailed_result(stt_h stt, stt_result_time_cb callback, void* user_data);
776
777 /**
778  * @brief Registers a callback function to get the recognition result.
779  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
780  * @privlevel public
781  * @privilege %http://tizen.org/privilege/recorder
782  *
783  * @param[in] stt The STT handle
784  * @param[in] callback The callback function to register
785  * @param[in] user_data The user data to be passed to the callback function
786  *
787  * @return 0 on success, otherwise a negative error value
788  * @retval #STT_ERROR_NONE Successful
789  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
790  * @retval #STT_ERROR_INVALID_STATE Invalid state
791  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
792  *
793  * @pre The state should be #STT_STATE_CREATED.
794  *
795  * @see stt_recognition_result_cb()
796  * @see stt_unset_recognition_result_cb()
797 */
798 int stt_set_recognition_result_cb(stt_h stt, stt_recognition_result_cb callback, void* user_data);
799
800 /**
801  * @brief Unregisters the callback function.
802  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
803  * @privlevel public
804  * @privilege %http://tizen.org/privilege/recorder
805  *
806  * @param[in] stt The STT handle
807  *
808  * @return 0 on success, otherwise a negative error value
809  * @retval #STT_ERROR_NONE Successful
810  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
811  * @retval #STT_ERROR_INVALID_STATE Invalid state
812  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
813  *
814  * @pre The state should be #STT_STATE_CREATED.
815  *
816  * @see stt_set_recognition_result_cb()
817 */
818 int stt_unset_recognition_result_cb(stt_h stt);
819
820 /**
821  * @brief Registers a callback function to be called when STT state changes.
822  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
823  * @privlevel public
824  * @privilege %http://tizen.org/privilege/recorder
825  *
826  * @param[in] stt The STT handle
827  * @param[in] callback The callback function to register
828  * @param[in] user_data The user data to be passed to the callback function
829  *
830  * @return 0 on success, otherwise a negative error value
831  * @retval #STT_ERROR_NONE Successful
832  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
833  * @retval #STT_ERROR_INVALID_STATE Invalid state
834  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
835  *
836  * @pre The state should be #STT_STATE_CREATED.
837  *
838  * @see stt_state_changed_cb()
839  * @see stt_unset_state_changed_cb()
840 */
841 int stt_set_state_changed_cb(stt_h stt, stt_state_changed_cb callback, void* user_data);
842
843 /**
844  * @brief Unregisters the callback function.
845  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
846  * @privlevel public
847  * @privilege %http://tizen.org/privilege/recorder
848  *
849  * @param[in] stt The STT handle
850  *
851  * @return 0 on success, otherwise a negative error value
852  * @retval #STT_ERROR_NONE Successful
853  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
854  * @retval #STT_ERROR_INVALID_STATE Invalid state
855  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
856  *
857  * @pre The state should be #STT_STATE_CREATED.
858  *
859  * @see stt_set_state_changed_cb()
860 */
861 int stt_unset_state_changed_cb(stt_h stt);
862
863 /**
864  * @brief Registers a callback function to be called when an error occurred.
865  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
866  * @privlevel public
867  * @privilege %http://tizen.org/privilege/recorder
868  *
869  * @param[in] stt The STT handle
870  * @param[in] callback The callback function to register
871  * @param[in] user_data The user data to be passed to the callback function
872  *
873  * @return 0 on success, otherwise a negative error value
874  * @retval #STT_ERROR_NONE Successful
875  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
876  * @retval #STT_ERROR_INVALID_STATE Invalid state
877  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
878  *
879  * @pre The state should be #STT_STATE_CREATED.
880  *
881  * @see stt_error_cb()
882  * @see stt_unset_error_cb()
883 */
884 int stt_set_error_cb(stt_h stt, stt_error_cb callback, void* user_data);
885
886 /**
887  * @brief Unregisters the callback function.
888  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
889  * @privlevel public
890  * @privilege %http://tizen.org/privilege/recorder
891  *
892  * @param[in] stt The STT handle
893  *
894  * @return 0 on success, otherwise a negative error value
895  * @retval #STT_ERROR_NONE Successful
896  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
897  * @retval #STT_ERROR_INVALID_STATE Invalid state
898  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
899  *
900  * @pre The state should be #STT_STATE_CREATED.
901  *
902  * @see stt_set_error_cb()
903 */
904 int stt_unset_error_cb(stt_h stt);
905
906 /**
907  * @brief Registers a callback function to detect the default language change.
908  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
909  * @privlevel public
910  * @privilege %http://tizen.org/privilege/recorder
911  *
912  * @param[in] stt The STT handle
913  * @param[in] callback The callback function to register
914  * @param[in] user_data The user data to be passed to the callback function
915  *
916  * @return 0 on success, otherwise a negative error value
917  * @retval #STT_ERROR_NONE Successful
918  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
919  * @retval #STT_ERROR_INVALID_STATE Invalid state
920  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
921  *
922  * @pre The state should be #STT_STATE_CREATED.
923  *
924  * @see stt_default_language_changed_cb()
925  * @see stt_unset_default_language_changed_cb()
926 */
927 int stt_set_default_language_changed_cb(stt_h stt, stt_default_language_changed_cb callback, void* user_data);
928
929 /**
930  * @brief Unregisters the callback function.
931  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
932  * @privlevel public
933  * @privilege %http://tizen.org/privilege/recorder
934  *
935  * @param[in] stt The STT handle
936  *
937  * @return 0 on success, otherwise a negative error value
938  * @retval #STT_ERROR_NONE Successful
939  * @retval #STT_ERROR_INVALID_PARAMETER Invalid parameter
940  * @retval #STT_ERROR_INVALID_STATE Invalid state
941  * @retval #STT_ERROR_NOT_SUPPORTED STT NOT supported
942  *
943  * @pre The state should be #STT_STATE_CREATED.
944  *
945  * @see stt_set_default_language_changed_cb()
946 */
947 int stt_unset_default_language_changed_cb(stt_h stt);
948
949 #ifdef __cplusplus
950 }
951 #endif
952
953 /**
954  * @}@}
955  */
956
957 #endif /* __STT_H__ */
958