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.
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 Gets the system command list.
250 * @privilege %http://tizen.org/privilege/recorder
252 * @remarks In the system command list, there are system commands predefined by product manufacturers. Those commands have the highest priority.
253 * Therefore, the user can not set any commands same with the system commands. \n
254 * The @a vc_sys_cmd_list must be released using free() when it is no longer required.
256 * @param[out] vc_sys_cmd_list System command list handle
258 * @return 0 on success, otherwise a negative error value
259 * @retval #VC_ERROR_NONE Successful
260 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
261 * @retval #VC_ERROR_INVALID_STATE Invalid state
262 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
263 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
265 * @pre The service state should be #VC_SERVICE_STATE_READY.
267 * @see vc_unset_command_list()
269 int vc_get_system_command_list(vc_cmd_list_h* vc_sys_cmd_list);
272 * @brief Sets the invocation name.
275 * @privilege %http://tizen.org/privilege/recorder
277 * @remarks Invocation name is used to activate background commands. The invocation name can be the same as the application name or any other phrase.
278 * For example, an application "Tizen Sample" has a background command, "Play music", and the invocation name of the application is set to "Tizen Sample".
279 * In order to activate the background command, users can say "Tizen Sample, Play music".
280 * The invocation name is dependent on the current language. For example, if the current language is "en_US"(English), the invocation name is also "en_US".
281 * If the current language is "ja_JP"(Japanese) and the invocation name is "en_US", the invocation name will not be recognized.
282 * This function should be called before vc_set_command_list().
284 * @param[in] name Invocation name that an application wants to be invoked by
286 * @return 0 on success, otherwise a negative error value
287 * @retval #VC_ERROR_NONE Successful
288 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
289 * @retval #VC_ERROR_INVALID_STATE Invalid state
290 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
291 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
293 * @pre The state should be #VC_STATE_READY.
295 * @see vc_set_command_list()
297 int vc_set_invocation_name(const char* name);
300 * @brief Requests to start the dialogue.
301 * @details Using this function, the developer can request starting the dialogue to the framework.
302 * When the developer requests the dialogue, two types of texts, @a disp_text and @a utt_text, can be sent by this function.
303 * @a disp_text is a text for displaying, and @a utt_text is that for uttering.
304 * For example, if @a disp_text is "October 10th" and @a utt_text is "Today is October 10th.", "October 10th" will be displayed on the screen and "Today is October 10th." will be spoken.
305 * Also, the developer can set whether the dialogue starts automatically or not, using @a auto_start.
306 * If the developer sets @a auto_start as @c true, the framework will start to record next speech and continue the dialogue.
310 * @privilege %http://tizen.org/privilege/recorder
312 * @remarks If @a auto_start is @c true, the recognition will start again. In this case, it can be restarted up to 4 times.
314 * @param[in] disp_text Text to be displayed on the screen
315 * @param[in] utt_text Text to be spoken
316 * @param[in] auto_start A variable for setting whether the dialog session will be restarted automatically or not
318 * @return 0 on success, otherwise a negative error value
319 * @retval #VC_ERROR_NONE Successful
320 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
321 * @retval #VC_ERROR_INVALID_STATE Invalid state
322 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
323 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
325 * @pre The service state should be #VC_SERVICE_STATE_READY.
327 int vc_request_dialog(const char* disp_text, const char* utt_text, bool auto_start);
330 * @brief Sets command list.
331 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
333 * @privilege %http://tizen.org/privilege/recorder
335 * @remarks The command type is valid for #VC_COMMAND_TYPE_FOREGROUND or #VC_COMMAND_TYPE_BACKGROUND. \n
336 * The matched commands of command list should be set and they should include type and command text at least.
338 * @param[in] vc_cmd_list Command list handle
339 * @param[in] type Command type
341 * @return 0 on success, otherwise a negative error value
342 * @retval #VC_ERROR_NONE Successful
343 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
344 * @retval #VC_ERROR_INVALID_STATE Invalid state
345 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
346 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
348 * @pre The state should be #VC_STATE_READY.
350 * @see vc_unset_command_list()
352 int vc_set_command_list(vc_cmd_list_h vc_cmd_list, int type);
355 * @brief Unsets command list.
356 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
358 * @privilege %http://tizen.org/privilege/recorder
360 * @param[in] type Command type
362 * @return 0 on success, otherwise a negative error value
363 * @retval #VC_ERROR_NONE Successful
364 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
365 * @retval #VC_ERROR_INVALID_STATE Invalid state
366 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
367 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
369 * @pre The state should be #VC_STATE_READY.
371 * @see vc_set_command_list()
373 int vc_unset_command_list(int type);
376 * @brief Gets the recognition result.
379 * @privilege %http://tizen.org/privilege/recorder
381 * @param[in] callback Callback function to get recognition result
382 * @param[in] user_data The user data to be passed to the callback function
384 * @return 0 on success, otherwise a negative error value
385 * @retval #VC_ERROR_NONE Successful
386 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
387 * @retval #VC_ERROR_INVALID_STATE Invalid state
388 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
390 * @pre The state should be #VC_STATE_READY.
392 * @see vc_result_cb()
394 int vc_get_result(vc_result_cb callback, void* user_data);
397 * @brief Registers a callback function for getting recognition result.
398 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
400 * @privilege %http://tizen.org/privilege/recorder
402 * @param[in] callback Callback function to register
403 * @param[in] user_data The user data to be passed to the callback function
405 * @return 0 on success, otherwise a negative error value
406 * @retval #VC_ERROR_NONE Successful
407 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
408 * @retval #VC_ERROR_INVALID_STATE Invalid state
409 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
410 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
412 * @pre The state should be #VC_STATE_INITIALIZED.
414 * @see vc_result_cb()
415 * @see vc_unset_result_cb()
417 int vc_set_result_cb(vc_result_cb callback, void* user_data);
420 * @brief Unregisters the callback function.
421 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
423 * @privilege %http://tizen.org/privilege/recorder
425 * @return 0 on success, otherwise a negative error value
426 * @retval #VC_ERROR_NONE Successful
427 * @retval #VC_ERROR_INVALID_STATE Invalid state
428 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
430 * @pre The state should be #VC_STATE_INITIALIZED.
432 * @see vc_set_result_cb()
434 int vc_unset_result_cb(void);
437 * @brief Registers a callback function to be called when state is changed.
438 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
440 * @privilege %http://tizen.org/privilege/recorder
442 * @param[in] callback Callback function to register
443 * @param[in] user_data The user data to be passed to the callback function
445 * @return 0 on success, otherwise a negative error value
446 * @retval #VC_ERROR_NONE Successful
447 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
448 * @retval #VC_ERROR_INVALID_STATE Invalid state
449 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
450 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
452 * @pre The state should be #VC_STATE_INITIALIZED.
454 * @see vc_service_state_changed_cb()
455 * @see vc_unset_service_state_changed_cb()
457 int vc_set_service_state_changed_cb(vc_service_state_changed_cb callback, void* user_data);
460 * @brief Unregisters the callback function.
461 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
463 * @privilege %http://tizen.org/privilege/recorder
465 * @return 0 on success, otherwise a negative error value
466 * @retval #VC_ERROR_NONE Successful
467 * @retval #VC_ERROR_INVALID_STATE Invalid state
468 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
469 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
471 * @pre The state should be #VC_STATE_INITIALIZED.
473 * @see vc_set_service_state_changed_cb()
475 int vc_unset_service_state_changed_cb(void);
478 * @brief Registers a callback function to be called when state is changed.
479 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
481 * @privilege %http://tizen.org/privilege/recorder
483 * @param[in] callback Callback function to register
484 * @param[in] user_data The user data to be passed to the callback function
486 * @return 0 on success, otherwise a negative error value
487 * @retval #VC_ERROR_NONE Successful
488 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
489 * @retval #VC_ERROR_INVALID_STATE Invalid state
490 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
491 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
493 * @pre The state should be #VC_STATE_INITIALIZED.
495 * @see vc_state_changed_cb()
496 * @see vc_unset_state_changed_cb()
498 int vc_set_state_changed_cb(vc_state_changed_cb callback, void* user_data);
501 * @brief Unregisters the callback function.
502 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
504 * @privilege %http://tizen.org/privilege/recorder
506 * @return 0 on success, otherwise a negative error value
507 * @retval #VC_ERROR_NONE Successful
508 * @retval #VC_ERROR_INVALID_STATE Invalid state
509 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
510 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
512 * @pre The state should be #VC_STATE_INITIALIZED.
514 * @see vc_set_state_changed_cb()
516 int vc_unset_state_changed_cb(void);
519 * @brief Registers a callback function to be called when current language is changed.
520 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
522 * @privilege %http://tizen.org/privilege/recorder
524 * @param[in] callback Callback function to register
525 * @param[in] user_data The user data to be passed to the callback function
527 * @return 0 on success, otherwise a negative error value
528 * @retval #VC_ERROR_NONE Successful
529 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
530 * @retval #VC_ERROR_INVALID_STATE Invalid state
531 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
532 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
534 * @pre The state should be #VC_STATE_INITIALIZED.
536 * @see vc_current_language_changed_cb()
537 * @see vc_unset_current_language_changed_cb()
539 int vc_set_current_language_changed_cb(vc_current_language_changed_cb callback, void* user_data);
542 * @brief Unregisters the callback function.
543 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
545 * @privilege %http://tizen.org/privilege/recorder
547 * @return 0 on success, otherwise a negative error value
548 * @retval #VC_ERROR_NONE Successful
549 * @retval #VC_ERROR_INVALID_STATE Invalid state
550 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
551 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
553 * @pre The state should be #VC_STATE_INITIALIZED.
555 * @see vc_set_current_language_changed_cb()
557 int vc_unset_current_language_changed_cb(void);
560 * @brief Registers a callback function to be called when an error occurred.
561 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
563 * @privilege %http://tizen.org/privilege/recorder
565 * @param[in] callback Callback function to register
566 * @param[in] user_data The user data to be passed to the callback function
568 * @return 0 on success, otherwise a negative error value
569 * @retval #VC_ERROR_NONE Successful
570 * @retval #VC_ERROR_INVALID_PARAMETER Invalid parameter
571 * @retval #VC_ERROR_INVALID_STATE Invalid state
572 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
573 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
575 * @pre The state should be #VC_STATE_INITIALIZED.
578 * @see vc_unset_error_cb()
580 int vc_set_error_cb(vc_error_cb callback, void* user_data);
583 * @brief Unregisters the callback function.
584 * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif
586 * @privilege %http://tizen.org/privilege/recorder
588 * @return 0 on success, otherwise a negative error value
589 * @retval #VC_ERROR_NONE Successful
590 * @retval #VC_ERROR_INVALID_STATE Invalid state
591 * @retval #VC_ERROR_PERMISSION_DENIED Permission denied
592 * @retval #VC_ERROR_NOT_SUPPORTED Not supported
594 * @pre The state should be #VC_STATE_INITIALIZED.
596 * @see vc_set_error_cb()
598 int vc_unset_error_cb(void);
609 #endif /* __VOICE_CONTROL_H__ */