2 * Copyright (c) 2011-2015 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.
18 #ifndef __VOICE_CONTROL_H__
19 #define __VOICE_CONTROL_H__
21 #include <voice_control_command.h>
22 #include <voice_control_common.h>
25 * @addtogroup CAPI_UIX_VOICE_CONTROL_MODULE
35 * @file voice_control.h
36 * @brief This file contains the voice control client API and related callback definitions and enums.
40 * @file voice_control_command.h
41 * @brief This file contains the command list and command API and related handle definitions and enums.
45 * @file voice_control_common.h
46 * @brief This file contains the callback function definitions and enums.
50 * @brief Definitions for foreground command type.
51 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
53 #define VC_COMMAND_TYPE_FOREGROUND 1
56 * @brief Definitions for background command type.
57 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
59 #define VC_COMMAND_TYPE_BACKGROUND 2
62 * @brief Definitions for ended dialog.
65 #define VC_DIALOG_END 0
68 * @brief Definitions for continued dialog.
71 #define VC_DIALOG_CONTINUE 1
75 * @brief Initializes voice control.
76 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
78 * @privilege %http://tizen.org/privilege/recorder
80 * @remarks If the function succeeds, @a vc must be released with vc_deinitialize().
82 * @return 0 on success, otherwise a negative error value
83 * @retval #VC_ERROR_NONE Successful
84 * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory
85 * @retval #VC_ERROR_OPERATION_FAILED Operation failure
86 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
87 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
89 * @post If this function is called, the state will be #VC_STATE_INITIALIZED.
91 * @see vc_deinitialize()
93 int vc_initialize(void);
96 * @brief Deinitializes voice control.
97 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
99 * @privilege %http://tizen.org/privilege/recorder
101 * @return 0 on success, otherwise a negative error value
102 * @retval #VC_ERROR_NONE Successful
103 * @retval #VC_ERROR_INVALID_STATE Invalid state
104 * @retval #VC_ERROR_OPERATION_FAILED Operation failure
105 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
106 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
108 * @see vc_deinitialize()
110 int vc_deinitialize(void);
113 * @brief Connects the voice control service.
114 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
116 * @privilege %http://tizen.org/privilege/recorder
118 * @return 0 on success, otherwise a negative error value
119 * @retval #VC_ERROR_NONE Successful
120 * @retval #VC_ERROR_INVALID_STATE Invalid state
121 * @retval #VC_ERROR_OPERATION_FAILED Operation failure
122 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
123 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
125 * @pre The state should be #VC_STATE_INITIALIZED.
126 * @post If this function is called, the state will be #VC_STATE_READY.
128 * @see vc_unprepare()
130 int vc_prepare(void);
133 * @brief Disconnects the voice control service.
134 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
136 * @privilege %http://tizen.org/privilege/recorder
138 * @return 0 on success, otherwise a negative error value
139 * @retval #VC_ERROR_NONE Successful
140 * @retval #VC_ERROR_INVALID_STATE Invalid state
141 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
142 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
144 * @pre The state should be #VC_STATE_READY.
145 * @post If this function is called, the state will be #VC_STATE_INITIALIZED.
149 int vc_unprepare(void);
152 * @brief Retrieves all supported languages using callback function.
153 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
155 * @privilege %http://tizen.org/privilege/recorder
157 * @param[in] callback Callback function to invoke
158 * @param[in] user_data The user data to be passed to the callback function
160 * @return 0 on success, otherwise a negative error value
161 * @retval #VC_ERROR_NONE Successful
162 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
163 * @retval #VC_ERROR_OPERATION_FAILED Operation failure
164 * @retval #VC_ERROR_INVALID_STATE Invalid state
165 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
166 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
168 * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY.
169 * @post This function invokes vc_supported_language_cb() repeatedly for getting languages.
171 * @see vc_supported_language_cb()
172 * @see vc_get_current_language()
174 int vc_foreach_supported_languages(vc_supported_language_cb callback, void* user_data);
177 * @brief Gets current language.
178 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
180 * @privilege %http://tizen.org/privilege/recorder
182 * @remark If the function succeeds, @a language must be released with free() by you when you no longer need it.
184 * @param[out] language A language is specified as an ISO 3166 alpha-2 two letter country-code \n
185 * followed by ISO 639-1 for the two-letter language code. \n
186 * For example, "ko_KR" for Korean, "en_US" for American English.
188 * @return 0 on success, otherwise a negative error value
189 * @retval #VC_ERROR_NONE Successful
190 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
191 * @retval #VC_ERROR_OUT_OF_MEMORY Out of memory
192 * @retval #VC_ERROR_OPERATION_FAILED Operation failure
193 * @retval #VC_ERROR_INVALID_STATE Invalid state
194 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
195 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
197 * @pre The state should be #VC_STATE_INITIALIZED or #VC_STATE_READY.
199 * @see vc_foreach_supported_languages()
201 int vc_get_current_language(char** language);
204 * @brief Gets current state of voice control client.
205 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
207 * @privilege %http://tizen.org/privilege/recorder
209 * @param[out] state The current state
211 * @return 0 on success, otherwise a negative error value
212 * @retval #VC_ERROR_NONE Successful
213 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
214 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
215 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
217 * @see vc_state_changed_cb()
218 * @see vc_set_state_changed_cb()
220 int vc_get_state(vc_state_e* state);
223 * @brief Gets current state of voice control service.
224 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
226 * @privilege %http://tizen.org/privilege/recorder
228 * @param[out] state The current state
230 * @return 0 on success, otherwise a negative error value
231 * @retval #VC_ERROR_NONE Successful
232 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
233 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
234 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
236 * @pre The state should be #VC_STATE_READY.
238 * @see vc_request_start()
239 * @see vc_request_stop()
240 * @see vc_request_cancel()
241 * @see vc_set_service_state_changed_cb()
242 * @see vc_unset_service_state_changed_cb()
244 int vc_get_service_state(vc_service_state_e* state);
247 * @brief Get system command list.
250 * @privilege %http://tizen.org/privilege/recorder
252 * @remarks If system command is set by system voice app, the system command list can be retreived.
254 * @param[out] vc_sys_cmd_list System command list handle
256 * @return 0 on success, otherwise a negative error value
257 * @retval #VC_ERROR_NONE Successful
258 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
259 * @retval #VC_ERROR_INVALID_STATE Invalid state
260 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
261 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
263 * @pre The service state should be #VC_SERVICE_STATE_READY.
265 * @see vc_unset_command_list()
267 int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list);
270 * @brief Sets invocation name.
273 * @privilege %http://tizen.org/privilege/recorder
275 * @remarks The invocation name will be combined with background command.
276 * This function should be called before vc_set_command_list() or vc_set_command_list_from_file().
278 * @param[in] name App name that wants to be invoked
280 * @return 0 on success, otherwise a negative error value
281 * @retval #VC_ERROR_NONE Successful
282 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
283 * @retval #VC_ERROR_INVALID_STATE Invalid state
284 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
285 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
287 * @pre The state should be #VC_STATE_READY.
289 * @see vc_set_command_list()
290 * @see vc_set_command_list_from_file()
292 int vc_set_invocation_name(const char* name);
295 * @brief Request to display text and to speak text what app want.
298 * @privilege %http://tizen.org/privilege/recorder
300 * @remarks If continue is true, the recognition will start again. In this case, 4 times can be restarted.
302 * @param[in] disp_text Text hat wants to be displayed
303 * @param[in] utt_text Text that wants to be spoken
304 * @param[in] continue Continue dialog session
306 * @return 0 on success, otherwise a negative error value
307 * @retval #VC_ERROR_NONE Successful
308 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
309 * @retval #VC_ERROR_INVALID_STATE Invalid state
310 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
311 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
313 * @pre The service state should be #VC_SERVICE_STATE_READY.
315 int vc_dialog(const char* disp_text, const char* utt_text, bool continuous);
318 * @brief Sets command list.
319 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
321 * @privilege %http://tizen.org/privilege/recorder
323 * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n
324 * The matched commands of command list should be set and they should include type and command text at least.
326 * @param[in] vc_cmd_list Command list handle
327 * @param[in] type Command type
329 * @return 0 on success, otherwise a negative error value
330 * @retval #VC_ERROR_NONE Successful
331 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
332 * @retval #VC_ERROR_INVALID_STATE Invalid state
333 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
334 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
336 * @pre The state should be #VC_STATE_READY.
338 * @see vc_unset_command_list()
340 int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type);
343 * @brief Sets command list from file.
346 * @privilege %http://tizen.org/privilege/recorder
348 * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n
349 * The matched commands of command list should be set and they should include type and command text at least.
351 * @param[in] file_path The file path including commands
352 * @param[in] type Command type
354 * @return 0 on success, otherwise a negative error value
355 * @retval #VC_ERROR_NONE Successful
356 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
357 * @retval #VC_ERROR_INVALID_STATE Invalid state
358 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
359 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
361 * @pre The state should be #VC_STATE_READY.
363 * @see vc_unset_command_list()
365 int vc_set_command_list_from_file(const char* file_path, int type);
368 * @brief Unsets command list.
369 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
371 * @privilege %http://tizen.org/privilege/recorder
373 * @param[in] type Command type
375 * @return 0 on success, otherwise a negative error value
376 * @retval #VC_ERROR_NONE Successful
377 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
378 * @retval #VC_ERROR_INVALID_STATE Invalid state
379 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
380 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
382 * @pre The state should be #VC_STATE_READY.
384 * @see vc_set_command_list()
385 * @see vc_set_command_list_from_file
387 int vc_unset_command_list(int type);
390 * @brief Get recognition result using a callback function.
393 * @privilege %http://tizen.org/privilege/recorder
395 * @param[in] callback Callback function to get recognition result
396 * @param[in] user_data The user data to be passed to the callback function
398 * @return 0 on success, otherwise a negative error value
399 * @retval #VC_ERROR_NONE Successful
400 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
401 * @retval #VC_ERROR_INVALID_STATE Invalid state
402 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
404 * @pre The state should be #VC_STATE_READY.
406 * @see vc_result_cb()
408 int vc_get_result(vc_result_cb callback, void* user_data);
411 * @brief Registers a callback function for getting recognition result.
412 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
414 * @privilege %http://tizen.org/privilege/recorder
416 * @param[in] callback Callback function to register
417 * @param[in] user_data The user data to be passed to the callback function
419 * @return 0 on success, otherwise a negative error value
420 * @retval #VC_ERROR_NONE Successful
421 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
422 * @retval #VC_ERROR_INVALID_STATE Invalid state
423 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
424 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
426 * @pre The state should be #VC_STATE_INITIALIZED.
428 * @see vc_result_cb()
429 * @see vc_unset_result_cb()
431 int vc_set_result_cb(vc_result_cb callback, void* user_data);
434 * @brief Unregisters the callback function.
435 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
437 * @privilege %http://tizen.org/privilege/recorder
439 * @return 0 on success, otherwise a negative error value
440 * @retval #VC_ERROR_NONE Successful
441 * @retval #VC_ERROR_INVALID_STATE Invalid state
442 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
444 * @pre The state should be #VC_STATE_INITIALIZED.
446 * @see vc_set_result_cb()
448 int vc_unset_result_cb(void);
451 * @brief Registers a callback function to be called when state is changed.
452 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
454 * @privilege %http://tizen.org/privilege/recorder
456 * @param[in] callback Callback function to register
457 * @param[in] user_data The user data to be passed to the callback function
459 * @return 0 on success, otherwise a negative error value
460 * @retval #VC_ERROR_NONE Successful
461 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
462 * @retval #VC_ERROR_INVALID_STATE Invalid state
463 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
464 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
466 * @pre The state should be #VC_STATE_INITIALIZED.
468 * @see vc_service_state_changed_cb()
469 * @see vc_unset_service_state_changed_cb()
471 int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data);
474 * @brief Unregisters the callback function.
475 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
477 * @privilege %http://tizen.org/privilege/recorder
479 * @return 0 on success, otherwise a negative error value
480 * @retval #VC_ERROR_NONE Successful
481 * @retval #VC_ERROR_INVALID_STATE Invalid state
482 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
483 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
485 * @pre The state should be #VC_STATE_INITIALIZED.
487 * @see vc_set_service_state_changed_cb()
489 int vc_unset_service_state_changed_cb(void);
492 * @brief Registers a callback function to be called when state is changed.
493 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
495 * @privilege %http://tizen.org/privilege/recorder
497 * @param[in] callback Callback function to register
498 * @param[in] user_data The user data to be passed to the callback function
500 * @return 0 on success, otherwise a negative error value
501 * @retval #VC_ERROR_NONE Successful
502 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
503 * @retval #VC_ERROR_INVALID_STATE Invalid state
504 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
505 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
507 * @pre The state should be #VC_STATE_INITIALIZED.
509 * @see vc_state_changed_cb()
510 * @see vc_unset_state_changed_cb()
512 int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data);
515 * @brief Unregisters the callback function.
516 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
518 * @privilege %http://tizen.org/privilege/recorder
520 * @return 0 on success, otherwise a negative error value
521 * @retval #VC_ERROR_NONE Successful
522 * @retval #VC_ERROR_INVALID_STATE Invalid state
523 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
524 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
526 * @pre The state should be #VC_STATE_INITIALIZED.
528 * @see vc_set_state_changed_cb()
530 int vc_unset_state_changed_cb(void);
533 * @brief Registers a callback function to be called when current language is changed.
534 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
536 * @privilege %http://tizen.org/privilege/recorder
538 * @param[in] callback Callback function to register
539 * @param[in] user_data The user data to be passed to the callback function
541 * @return 0 on success, otherwise a negative error value
542 * @retval #VC_ERROR_NONE Successful
543 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
544 * @retval #VC_ERROR_INVALID_STATE Invalid state
545 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
546 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
548 * @pre The state should be #VC_STATE_INITIALIZED.
550 * @see vc_current_language_changed_cb()
551 * @see vc_unset_current_language_changed_cb()
553 int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data);
556 * @brief Unregisters the callback function.
557 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
559 * @privilege %http://tizen.org/privilege/recorder
561 * @return 0 on success, otherwise a negative error value
562 * @retval #VC_ERROR_NONE Successful
563 * @retval #VC_ERROR_INVALID_STATE Invalid state
564 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
565 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
567 * @pre The state should be #VC_STATE_INITIALIZED.
569 * @see vc_set_current_language_changed_cb()
571 int vc_unset_current_language_changed_cb(void);
574 * @brief Registers a callback function to be called when an error occurred.
575 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
577 * @privilege %http://tizen.org/privilege/recorder
579 * @param[in] callback Callback function to register
580 * @param[in] user_data The user data to be passed to the callback function
582 * @return 0 on success, otherwise a negative error value
583 * @retval #VC_ERROR_NONE Successful
584 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
585 * @retval #VC_ERROR_INVALID_STATE Invalid state
586 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
587 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
589 * @pre The state should be #VC_STATE_INITIALIZED.
592 * @see vc_unset_error_cb()
594 int vc_set_error_cb(vc_error_cb callback, void* user_data);
597 * @brief Unregisters the callback function.
598 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
600 * @privilege %http://tizen.org/privilege/recorder
602 * @return 0 on success, otherwise a negative error value
603 * @retval #VC_ERROR_NONE Successful
604 * @retval #VC_ERROR_INVALID_STATE Invalid state
605 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
606 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
608 * @pre The state should be #VC_STATE_INITIALIZED.
610 * @see vc_set_error_cb()
612 int vc_unset_error_cb(void);
623 #endif /* __VOICE_CONTROL_H__ */