Tizen Native API
5.0
|
The Voice control engine APIs provide functions to operate Voice-Control Engine.
#include <vce.h>
Voice-Control-Engine (below VCE) is an engine for recognize the sound data recorded by the user and send the result as a predefined command. Using the Voice control engine APIs, VCE developers can provide VCE service users, who want to apply VCE, with functions necessary to operate the engine. According to the indispensability of VCE services, there are two ways to provide them to the users.
A. Required VCE services
These services are indispensable to operate VCE. Therefore, the VCE developers MUST implement callback functions corresponding to the required VCE services. The following is a list of the callback functions.
vce_get_info_cb() | Called when the engine service user requests the basic information of VCE. |
vce_get_recording_format_cb() | Called when the engine service user requests the recording format of VCE. |
vce_foreach_supported_languages_cb() | Called when the engine service user retrieves all supported languages of VC engine. |
vce_is_language_supported_cb() | Called when the engine service user retrieves all supported languages of VCE. |
vce_initialize_cb() | Called when the engine service user initializes VCE. |
vce_deinitialize_cb() | Called when the engine service user deinitializes VCE. |
vce_set_language_cb() | Called when the engine service user sets language. |
vce_set_commands_cb() | Called when the engine service user sets command list before recognition. |
vce_unset_commands_cb() | Called when the engine service user unsets command list for reset. |
vce_start_cb() | Called when the engine service user starts recognition. |
vce_set_recording_data_cb() | Called when the engine service user sets recording data for speech recognition from recorder. |
vce_stop_cb() | Called when the engine service user stops to get the result of recognition. |
vce_cancel_cb() | Called when the engine service user cancels the recognition process. |
vce_set_audio_type_cb() | Called when the engine service user sets audio recording type. |
vce_set_server_dialog_cb() | Called when the engine service user sets app id which is want to ask server dialog. |
vce_set_domain_cb() | Called when the engine service user sets domain (agent or device type). |
vce_process_text_cb() | Called when the engine service user requests process text. |
vce_process_list_event_cb() | Called when the engine service user requests list event. |
vce_process_haptic_event_cb() | Called when the engine service user requests haptic event. |
The VCE developers can register the above callback functions at a time with using a structure 'vce_request_callback_s' and an API 'vce_main()'. To operate VCE, the following steps should be used:
1. Create a structure 'vce_request_callback_s' 2. Implement callback functions. (NOTE that the callback functions should return appropriate values in accordance with the instruction. If the callback function returns an unstated value, VCE framework will handle it as VCE_ERROR_OPERATION_FAILED.)
3. Register callback functions using 'vce_main()'. (The registered callback functions will be invoked when the VCE service users request the VCE services.)
4. Use 'service_app_main()' for working VCE.
B. Optional VCE services
Unlike the required VCE services, these services are optional to operate VCE. The followings are optional VCE services.
If the VCE developers want to provide the above services, use the following APIs and implement the corresponding callback functions:
FUNCTION | DESCRIPTION | CORRESPONDING CALLBACK |
---|---|---|
vce_set_private_data_set_cb() | Sets a callback function for setting the private data to the engine service. | vce_private_data_set_cb() |
vce_set_private_data_requested_cb() | Sets a callback function for requesting the private data to the engine service. | vce_private_data_requested_cb() |
vce_set_nlu_base_info_requested_cb() | Sets a callback function for requesting the NLU base information to the engine service. | vce_nlu_base_info_requested_cb() |
Using the above APIs, the VCE developers can register the optional callback functions respectively. (For normal operation, put those APIs before 'service_app_main()' starts.)
Unlike callback functions, the following APIs are functions for getting and sending data. The VCE developers can use these APIs when they implement VCE services:
FUNCTION | DESCRIPTION |
---|---|
vce_send_result() | Sends the results to the engine service user. |
vce_send_asr_result() | Sends the ASR result to the engine service user. |
vce_send_nlg_result() | Sends the NLG (Natural Language Generation) result to the engine service user. |
vce_send_error() | Sends the error to the engine service user. |
vce_get_foreach_command() | Retrieves all commands using callback function. |
vce_get_command_count() | Gets command length. |
vce_get_audio_type() | Gets current audio type. |
vce_set_private_data() | Sets private data to a voice manager client. |
vce_get_private_data() | Gets private data from a voice manager client. |
vce_start_recording() | Starts recording voice. |
vce_stop_recording() | Stops recording voice. |
This API is related with the following features:
Functions | |
int | vce_main (int argc, char **argv, vce_request_callback_s *callback) |
Starts the main function for Voice Control (VC) engine. | |
int | vce_send_result (vce_result_event_e event, int *result_id, int count, const char *all_result, const char *non_fixed_result, const char *nlu_result, const char *msg, int *user_info, void *user_data) |
Sends the results to the engine service user. | |
int | vce_send_asr_result (vce_asr_result_event_e event, const char *asr_result, void *user_data) |
Sends the ASR result to the engine service user. | |
int | vce_send_nlg_result (const char *nlg_result, void *user_data) |
Sends the NLG (Natural Language Generation) result to the engine service user. | |
int | vce_send_specific_engine_result (const char *engine_app_id, const char *event, const char *result, void *user_info) |
Sends the specific engine result to the engine service user. | |
int | vce_send_error (vce_error_e error, const char *msg, void *user_data) |
Sends the error to the engine service user. | |
int | vce_set_private_data_set_cb (vce_private_data_set_cb callback_func) |
Sets a callback function for setting the private data to the engine service. | |
int | vce_set_private_data_requested_cb (vce_private_data_requested_cb callback_func) |
Sets a callback function for requesting the private data to the engine service. | |
int | vce_set_nlu_base_info_requested_cb (vce_nlu_base_info_requested_cb callback_func) |
Sets a callback function for requesting the NLU base information to the engine service. | |
int | vce_set_specific_engine_request_cb (vce_specific_engine_request_cb callback_func) |
Sets a callback function for getting the engine service request. | |
int | vce_unset_specific_engine_request_cb (void) |
Unsets the engine service request callback function. | |
int | vce_get_foreach_command (vce_cmd_h vce_command, vce_command_cb callback, void *user_data) |
Retrieves all commands using callback function. | |
int | vce_get_command_count (vce_cmd_h vce_command, int *count) |
Gets command length. | |
int | vce_get_audio_type (char **audio_type) |
Gets current audio type. | |
int | vce_set_private_data (const char *key, const char *data) |
Sets private data to a voice manager client. | |
int | vce_get_private_data (const char *key, char **data) |
Gets private data from a voice manager client. | |
int | vce_start_recording (void) |
Starts recording voice. | |
int | vce_stop_recording (void) |
Stops recording voice. | |
int | vce_send_feedback_audio_format (int rate, vce_audio_channel_e channel, vce_audio_type_e audio_type) |
Sends audio formats necessary for playing TTS feedback. | |
int | vce_send_feedback_streaming (vce_feedback_event_e event, char *buffer, int len) |
Sends audio streaming necessary for playing TTS feedback. | |
int | vce_set_request_tts_cb (vce_request_tts_cb callback_func, void *user_data) |
Sets a callback function for getting the request of sending TTS feedback from the engine service user. | |
int | vce_unset_request_tts_cb (void) |
Unsets the TTS feedback request callback function. | |
int | vce_set_cancel_tts_cb (vce_cancel_tts_cb callback_func, void *user_data) |
Sets a callback function for getting the request of canceling TTS feedback from the engine service user. | |
int | vce_unset_cancel_tts_cb (void) |
Unsets the TTS feedback cancellation callback function. | |
int | vce_set_tts_audio_format_request_cb (vce_tts_audio_format_request_cb callback_func, void *user_data) |
Sets a callback function for sending TTS audio format to the engine service user. | |
int | vce_unset_get_tts_audio_format_cb (void) |
Unsets the TTS audio format request callback function. | |
Typedefs | |
typedef struct vce_cmd_s * | vce_cmd_h |
A structure of handle for VC command. | |
typedef bool(* | vce_supported_language_cb )(const char *language, void *user_data) |
Called when VC engine informs the engine service user about whole supported languages. | |
typedef int(* | vce_initialize_cb )(void) |
Called when the engine service user initializes Voice Control (VC) engine. | |
typedef int(* | vce_deinitialize_cb )(void) |
Called when the engine service user deinitializes VC engine. | |
typedef int(* | vce_get_recording_format_cb )(const char *audio_id, vce_audio_type_e *types, int *rate, int *channels) |
Called when the engine service user requests the recording format of VC engine. | |
typedef int(* | vce_foreach_supported_languages_cb )(vce_supported_language_cb callback, void *user_data) |
Called when the engine service user retrieves all supported languages of VC engine. | |
typedef bool(* | vce_is_language_supported_cb )(const char *language) |
Called when the engine service user checks whether a language is supported or not. | |
typedef int(* | vce_set_language_cb )(const char *language) |
Called when the engine service user sets language. | |
typedef int(* | vce_set_commands_cb )(vce_cmd_h vc_command) |
Called when the engine service user sets command list before recognition. | |
typedef int(* | vce_unset_commands_cb )(void) |
Called when the engine service user unsets command list for reset. | |
typedef int(* | vce_start_cb )(bool stop_by_silence) |
Called when the engine service user starts recognition. | |
typedef int(* | vce_set_recording_data_cb )(const void *data, unsigned int length, vce_speech_detect_e *speech_detected) |
Called when the engine service user sets recording data for speech recognition from recorder. | |
typedef int(* | vce_stop_cb )(void) |
Called when the engine service user stops to get the result of recognition. | |
typedef int(* | vce_cancel_cb )(void) |
Called when the engine service user cancels the recognition process. | |
typedef int(* | vce_set_audio_type_cb )(const char *audio_type) |
Called when the engine service user sets audio recording type. | |
typedef int(* | vce_set_server_dialog_cb )(const char *app_id, const char *credential) |
Called when the engine service user sets app id which is want to ask server dialog. | |
typedef int(* | vce_set_domain_cb )(const char *domain) |
Called when the engine service user sets domain (agent or device type). | |
typedef int(* | vce_nlu_base_info_requested_cb )(const char *key, char **value) |
Called when the engine service user requests essential value from NLU result. | |
typedef int(* | vce_specific_engine_request_cb )(const char *engine_app_id, const char *event, const char *request) |
Called when client gets the specific engine's request from the engine service user. | |
typedef int(* | vce_private_data_set_cb )(const char *key, const char *data) |
Called when the engine service user sets private data between app and engine. | |
typedef int(* | vce_private_data_requested_cb )(const char *key, char **data) |
Called when the engine service user requests private data between app and engine. | |
typedef int(* | vce_process_text_cb )(const char *text) |
Called when the engine service user requests process text. | |
typedef int(* | vce_process_list_event_cb )(const char *event) |
Called when the engine service user requests list event. | |
typedef int(* | vce_process_haptic_event_cb )(const char *event) |
Called when the engine service user requests haptic event. | |
typedef int(* | vce_get_info_cb )(char **engine_uuid, char **engine_name, char **engine_settings_app_id, bool *use_network) |
Called when the engine service user requests the base information of VC engine. | |
typedef bool(* | vce_command_cb )(int id, int type, int format, const char *command, const char *param, int domain, void *user_data) |
Called to retrieve the commands. | |
typedef int(* | vce_request_tts_cb )(int pid, int utt_id, const char *text, const char *language, void *user_data) |
Called when the engine service user (voice control client) requests to send TTS feedback. | |
typedef int(* | vce_cancel_tts_cb )(int pid, int utt_id, void *user_data) |
Called when the engine service user cancels TTS feedback. | |
typedef int(* | vce_tts_audio_format_request_cb )(int *rate, int *channel, int *audio_type, void *user_data) |
Called when the engine service user requests TTS audio format. | |
Defines | |
#define | VCE_COMMAND_TYPE_FOREGROUND 1 |
Definition for foreground command type. | |
#define | VCE_COMMAND_TYPE_BACKGROUND 2 |
Definition for background command type. | |
#define | VCE_COMMAND_TYPE_WIDGET 3 |
Definition for widget command type. | |
#define | VCE_COMMAND_TYPE_SYSTEM 4 |
Definition for system command type. | |
#define | VCE_COMMAND_TYPE_SYSTEM_BACKGROUND 5 |
Definition for system background command type. | |
#define | VCE_COMMAND_TYPE_EXCLUSIVE 6 |
Definitions for exclusive command type. | |
#define | VCE_AUDIO_ID_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" |
Definition of bluetooth audio id. | |
#define | VCE_AUDIO_ID_WIFI "VC_AUDIO_ID_WIFI" |
Definition of Wi-Fi audio id. | |
#define | VC_RESULT_MESSAGE_NONE "vc.result.message.none" |
Definition for none message. | |
#define | VC_RESULT_MESSAGE_ERROR_TOO_LOUD "vc.result.message.error.too.loud" |
Definition for failed recognition because the speech is too loud to listen. |
#define VC_RESULT_MESSAGE_ERROR_TOO_LOUD "vc.result.message.error.too.loud" |
Definition for failed recognition because the speech is too loud to listen.
#define VC_RESULT_MESSAGE_NONE "vc.result.message.none" |
Definition for none message.
#define VCE_AUDIO_ID_BLUETOOTH "VC_AUDIO_ID_BLUETOOTH" |
Definition of bluetooth audio id.
#define VCE_AUDIO_ID_WIFI "VC_AUDIO_ID_WIFI" |
Definition of Wi-Fi audio id.
#define VCE_COMMAND_TYPE_BACKGROUND 2 |
Definition for background command type.
#define VCE_COMMAND_TYPE_EXCLUSIVE 6 |
Definitions for exclusive command type.
#define VCE_COMMAND_TYPE_FOREGROUND 1 |
Definition for foreground command type.
#define VCE_COMMAND_TYPE_SYSTEM 4 |
Definition for system command type.
#define VCE_COMMAND_TYPE_SYSTEM_BACKGROUND 5 |
Definition for system background command type.
#define VCE_COMMAND_TYPE_WIDGET 3 |
Definition for widget command type.
typedef int(* vce_cancel_cb)(void) |
Called when the engine service user cancels the recognition process.
VCE_ERROR_NONE | Successful. |
VCE_ERROR_INVALID_STATE | Invalid state. |
typedef int(* vce_cancel_tts_cb)(int pid, int utt_id, void *user_data) |
Called when the engine service user cancels TTS feedback.
[in] | pid | The process id of the engine service user |
[in] | utt_id | The utterance id corresponding to the text |
[in] | user_data | The user data passed from the callback setter function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
typedef struct vce_cmd_s* vce_cmd_h |
A structure of handle for VC command.
typedef bool(* vce_command_cb)(int id, int type, int format, const char *command, const char *param, int domain, void *user_data) |
Called to retrieve the commands.
[in] | id | command id |
[in] | type | command type |
[in] | format | command format |
[in] | command | command text |
[in] | param | parameter text |
[in] | domain | command domain |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop, false
to break out of the loop. typedef int(* vce_deinitialize_cb)(void) |
Called when the engine service user deinitializes VC engine.
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_STATE | Not initialized |
typedef int(* vce_foreach_supported_languages_cb)(vce_supported_language_cb callback, void *user_data) |
Called when the engine service user retrieves all supported languages of VC engine.
[in] | callback | a callback function |
[in] | user_data | The user data to be passed to the callback function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Not initialized |
typedef int(* vce_get_info_cb)(char **engine_uuid, char **engine_name, char **engine_settings_app_id, bool *use_network) |
Called when the engine service user requests the base information of VC engine.
[out] | engine_uuid | The engine id |
[out] | engine_name | The engine name |
[out] | engine_settings_app_id | The ID of the engine settings application (the UI application) |
[out] | use_network | true to need network false not to need network. |
0
on success, otherwise a negative error code on failure VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
typedef int(* vce_get_recording_format_cb)(const char *audio_id, vce_audio_type_e *types, int *rate, int *channels) |
Called when the engine service user requests the recording format of VC engine.
[in] | audio_id | The audio device id. (e.g. VCE_AUDIO_ID_BLUETOOTH or VCE_AUDIO_ID_WIFI) |
[out] | types | The format used by the recorder. |
[out] | rate | The sample rate used by the recorder. |
[out] | channels | The number of channels used by the recorder. |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Not initialized |
typedef int(* vce_initialize_cb)(void) |
Called when the engine service user initializes Voice Control (VC) engine.
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Already initialized |
VCE_ERROR_OPERATION_FAILED | Operation failed |
typedef bool(* vce_is_language_supported_cb)(const char *language) |
Called when the engine service user checks whether a language is supported or not.
[in] | language | A language |
true
= supported, false
= not supported. typedef int(* vce_nlu_base_info_requested_cb)(const char *key, char **value) |
Called when the engine service user requests essential value from NLU result.
[in] | key | NLU base info key. |
[out] | value | NLU base info value. |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_private_data_requested_cb)(const char *key, char **data) |
Called when the engine service user requests private data between app and engine.
[in] | key | Private key. |
[out] | data | Private data. |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_private_data_set_cb)(const char *key, const char *data) |
Called when the engine service user sets private data between app and engine.
[in] | key | Private key. |
[in] | data | Private data. |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_process_haptic_event_cb)(const char *event) |
Called when the engine service user requests haptic event.
[in] | event | Requested haptic event |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_process_list_event_cb)(const char *event) |
Called when the engine service user requests list event.
[in] | event | Requested list event |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_process_text_cb)(const char *text) |
Called when the engine service user requests process text.
[in] | text | Requested text |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_request_tts_cb)(int pid, int utt_id, const char *text, const char *language, void *user_data) |
Called when the engine service user (voice control client) requests to send TTS feedback.
[in] | pid | The process id of the engine service user (voice control client) |
[in] | utt_id | The utterance id |
[in] | text | The text for TTS feedback |
[in] | language | The language |
[in] | user_data | The user data passed from the callback setter function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
typedef int(* vce_set_audio_type_cb)(const char *audio_type) |
Called when the engine service user sets audio recording type.
[in] | audio_type | Current audio type (e.g. VCE_AUDIO_ID_BLUETOOTH or VCE_AUDIO_ID_WIFI) |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
typedef int(* vce_set_commands_cb)(vce_cmd_h vc_command) |
Called when the engine service user sets command list before recognition.
[in] | vc_command | command handle. The vc_command can be used only in the callback. To use outside, make a copy. |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_OPERATION_FAILED | Operation failed |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported command type |
typedef int(* vce_set_domain_cb)(const char *domain) |
Called when the engine service user sets domain (agent or device type).
[in] | domain | Agent (e.g. "music", "news", etc) or device type (e.g. "tv", "mobile", etc) corresponding to the command |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature |
typedef int(* vce_set_language_cb)(const char *language) |
Called when the engine service user sets language.
[in] | language | A language. |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_LANGUAGE | Invalid language |
VCE_ERROR_INVALID_STATE | Not initialized |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature |
typedef int(* vce_set_recording_data_cb)(const void *data, unsigned int length, vce_speech_detect_e *speech_detected) |
Called when the engine service user sets recording data for speech recognition from recorder.
[in] | data | A recording data |
[in] | length | A length of recording data |
[out] | speech_detected | The status of speech (e.g. VCE_SPEECH_DETECT_BEGIN or VCE_SPEECH_DETECT_END). The speech_detected can be used only in the callback. To use outside, make a copy. |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_OPERATION_FAILED | Operation failed |
typedef int(* vce_set_server_dialog_cb)(const char *app_id, const char *credential) |
Called when the engine service user sets app id which is want to ask server dialog.
[in] | app_id | App id which is to want to ask server dialog. |
[in] | credential | Credential key. |
VCE_ERROR_NONE | Successful. |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature. |
VCE_ERROR_PERMISSION_DENIED | Permission denied. |
typedef int(* vce_specific_engine_request_cb)(const char *engine_app_id, const char *event, const char *request) |
Called when client gets the specific engine's request from the engine service user.
[in] | engine_app_id | The specific engine's app id |
[in] | event | The specific engine event type |
[in] | request | The specific engine request |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
typedef int(* vce_start_cb)(bool stop_by_silence) |
Called when the engine service user starts recognition.
[in] | stop_by_silence | Silence detection option. true to detect the silence, false not to detect the silence |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_INVALID_LANGUAGE | Invalid language |
VCE_ERROR_OUT_OF_NETWORK | Out of network |
VCE_ERROR_OPERATION_FAILED | Operation failed |
typedef int(* vce_stop_cb)(void) |
Called when the engine service user stops to get the result of recognition.
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_OPERATION_FAILED | Operation failed |
VCE_ERROR_OUT_OF_NETWORK | Out of network |
typedef bool(* vce_supported_language_cb)(const char *language, void *user_data) |
Called when VC engine informs the engine service user about whole supported languages.
This callback function is implemented by the engine service user. Therefore, the engine developer does NOT have to implement this callback function.
[in] | language | A 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. |
[in] | user_data | The user data passed from the foreach function |
true
to continue with the next iteration of the loop false
to break out of the loop typedef int(* vce_tts_audio_format_request_cb)(int *rate, int *channel, int *audio_type, void *user_data) |
Called when the engine service user requests TTS audio format.
[out] | rate | The audio sample rate |
[out] | channel | The audio channel |
[out] | audio_type | The audio type |
[in] | user_data | The user data passed from the callback setter function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
typedef int(* vce_unset_commands_cb)(void) |
Called when the engine service user unsets command list for reset.
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_OPERATION_FAILED | Operation failed |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature |
Enumerations of ASR result events.
enum vce_audio_channel_e |
enum vce_audio_type_e |
enum vce_command_format_e |
Enumerations of command type.
enum vce_error_e |
Enumerations of error codes.
enum vce_feedback_event_e |
enum vce_result_event_e |
enum vce_speech_detect_e |
int vce_get_audio_type | ( | char ** | audio_type | ) |
Gets current audio type.
[in] | audio_type | Current audio type (e.g. VCE_AUDIO_ID_BLUETOOTH or VCE_AUDIO_ID_WIFI) |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
int vce_get_command_count | ( | vce_cmd_h | vce_command, |
int * | count | ||
) |
Gets command length.
[in] | vce_command | The handle to be passed to the vce_set_commands() function |
[out] | count | The command count value |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_get_foreach_command | ( | vce_cmd_h | vce_command, |
vce_command_cb | callback, | ||
void * | user_data | ||
) |
Retrieves all commands using callback function.
[in] | vce_command | The handle to be passed to the vce_set_commands() function |
[in] | callback | The callback function to invoke |
[in] | user_data | The user data to be passed to the callback function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
VCE_ERROR_INVALID_STATE | Invalid state |
int vce_get_private_data | ( | const char * | key, |
char ** | data | ||
) |
Gets private data from a voice manager client.
[in] | key | Private key |
[out] | data | Private data |
VCE_ERROR_NONE | Successful |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_OPERATION_FAILED | Operation failed |
int vce_main | ( | int | argc, |
char ** | argv, | ||
vce_request_callback_s * | callback | ||
) |
Starts the main function for Voice Control (VC) engine.
This function is the main function for operating VC engine.
[in] | argc | The argument count(original) |
[in] | argv | The argument(original) |
[in] | callback | The structure of engine request callback function |
zero
on success, or negative with error code on failure VCE_ERROR_NONE | Successful |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_OPERATION_FAILED | Operation failed |
#include <vce.h> // Required callback functions - MUST BE IMPLEMENTED static int vce_default_initialize(); static int vce_default_deinitialize(void); static int vce_default_get_info(char** engine_uuid, char** engine_name, char** engine_setting, bool* use_network); static int vce_default_get_recording_format(const char* audio_id, vce_audio_type_e* types, int* rate, int* channels); static int vce_default_foreach_langs(vce_supported_language_cb callback, void* user_data); static bool vce_default_is_lang_supported(const char* lang); static int vce_default_set_language(const char* language); static int vce_default_set_commands(vce_cmd_h vc_command); static int vce_default_unset_commands(); static int vce_default_start(bool stop_by_silence); static int vce_default_set_recording(const void* data, unsigned int length, vce_speech_detect_e* silence_detected); static int vce_default_stop(); static int vce_default_cancel(void); static int vce_default_set_audio_type(const char* audio_type); static int vce_default_set_domain(const char* domain); static int vce_default_process_text(const char* text); static int vce_default_process_list_event(const char* event); static int vce_default_process_haptic_event(const char* event); // Optional callback function static int vce_default_private_data_set_cb(const char* key, const char* data); int main(int argc, char* argv[]) { // 1. Create a structure 'vce_request_callback_s' vce_request_callback_s callback = {0,}; callback.version = 1; callback.initialize = vce_default_initialize; callback.deinitialize = vce_default_deinitialize; callback.get_info = vce_default_get_info; callback.get_recording_format = vce_default_get_recording_format; callback.foreach_langs = vce_default_foreach_langs; callback.is_lang_supported = vce_default_is_lang_supported; callback.set_language = vce_default_set_language; callback.set_commands = vce_default_set_commands; callback.unset_commands = vce_default_unset_commands; callback.start = vce_default_start; callback.set_recording = vce_default_set_recording; callback.stop = vce_default_stop; callback.cancel = vce_default_cancel; callback.set_audio_type = vce_default_set_audio_type; callback.set_domain = vce_default_set_domain; callback.process_text = vce_default_process_text; callback.process_list_event = vce_default_process_list_event; callback.process_haptic_event = vce_default_process_haptic_event; // 2. Run 'vce_main()' if (0 != vce_main(argc, argv, &callback)) { SLOG(LOG_ERROR, TAG_VCE, "[ERROR] Fail to vce main"); return -1; } // Optional vce_set_private_data_set_cb(vce_default_private_data_set_cb); // 3. Set event callbacks for service app and Run 'service_app_main()' char ad[50] = {0,}; service_app_lifecycle_callback_s event_callback; app_event_handler_h handlers[5] = {NULL, }; event_callback.create = service_app_create; event_callback.terminate = service_app_terminate; event_callback.app_control = service_app_control; service_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, service_app_low_battery, &ad); service_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, service_app_low_memory, &ad); service_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, service_app_lang_changed, &ad); service_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, service_app_region_changed, &ad); return service_app_main(argc, argv, &event_callback, ad); }
int vce_send_asr_result | ( | vce_asr_result_event_e | event, |
const char * | asr_result, | ||
void * | user_data | ||
) |
Sends the ASR result to the engine service user.
[in] | event | A asr result event |
[in] | asr_result | A asr result text |
[in] | user_data | The user data passed from the start |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_send_error | ( | vce_error_e | error, |
const char * | msg, | ||
void * | user_data | ||
) |
Sends the error to the engine service user.
The following error codes can be delivered.
VCE_ERROR_NONE,
VCE_ERROR_OUT_OF_MEMORY,
VCE_ERROR_IO_ERROR,
VCE_ERROR_INVALID_PARAMETER,
VCE_ERROR_OUT_OF_NETWORK,
VCE_ERROR_RECORDER_BUSY,
VCE_ERROR_NOT_SUPPORTED,
VCE_ERROR_INVALID_STATE,
VCE_ERROR_INVALID_LANGUAGE,
VCE_ERROR_OPERATION_FAILED,
VCE_ERROR_PERMISSION_DENIED,
VCE_ERROR_NOT_SUPPORTED_FEATURE.
[in] | error | Error type |
[in] | msg | Error message |
[in] | user_data | The user data passed from set callback function |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_send_feedback_audio_format | ( | int | rate, |
vce_audio_channel_e | channel, | ||
vce_audio_type_e | audio_type | ||
) |
Sends audio formats necessary for playing TTS feedback.
[in] | rate | A sampling rate |
[in] | channel | The audio channel |
[in] | audio_type | The audio type |
VCE_ERROR_NONE | Successful |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
int vce_send_feedback_streaming | ( | vce_feedback_event_e | event, |
char * | buffer, | ||
int | len | ||
) |
Sends audio streaming necessary for playing TTS feedback.
[in] | event | A feedback event |
[in] | buffer | The feedback data |
[in] | len | The length of the feedback data |
VCE_ERROR_NONE | Successful |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
int vce_send_nlg_result | ( | const char * | nlg_result, |
void * | user_data | ||
) |
Sends the NLG (Natural Language Generation) result to the engine service user.
[in] | nlg_result | A nlg result |
[in] | user_data | The user data passed from the start |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_send_result | ( | vce_result_event_e | event, |
int * | result_id, | ||
int | count, | ||
const char * | all_result, | ||
const char * | non_fixed_result, | ||
const char * | nlu_result, | ||
const char * | msg, | ||
int * | user_info, | ||
void * | user_data | ||
) |
Sends the results to the engine service user.
[in] | event | A result event |
[in] | result_id | Result ids |
[in] | count | Result count |
[in] | all_result | All result text |
[in] | non_fixed_result | Non-fixed command result text |
[in] | nlu_result | NLU result text |
[in] | msg | Engine message (e.g. VC_RESULT_MESSAGE_NONE, VC_RESULT_MESSAGE_ERROR_TOO_LOUD) |
[out] | user_info | A user info (e.g. If ASR result is consumed, the value is 0x01. If not, the value is 0x00.) |
[in] | user_data | The user data passed from set callback function |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_send_specific_engine_result | ( | const char * | engine_app_id, |
const char * | event, | ||
const char * | result, | ||
void * | user_info | ||
) |
Sends the specific engine result to the engine service user.
[in] | engine_app_id | A specific engine's app id |
[in] | event | A specific engine result event |
[in] | result | A specific engine result text |
[in] | user_info | The user info passed from the start |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_set_cancel_tts_cb | ( | vce_cancel_tts_cb | callback_func, |
void * | user_data | ||
) |
Sets a callback function for getting the request of canceling TTS feedback from the engine service user.
[in] | callback_func | Callback function to be registered |
[in] | user_data | The user data passed to the callback function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_NOT_SUPPORTED | Not supported |
int vce_set_nlu_base_info_requested_cb | ( | vce_nlu_base_info_requested_cb | callback_func | ) |
Sets a callback function for requesting the NLU base information to the engine service.
[in] | callback_func | vce_nlu_base_info_requested event callback function |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_OPERATION_FAILED | Operation failure |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature |
int vce_set_private_data | ( | const char * | key, |
const char * | data | ||
) |
Sets private data to a voice manager client.
[in] | key | Private key |
[in] | data | Private data |
VCE_ERROR_NONE | Successful |
VCE_ERROR_OUT_OF_MEMORY | Out of Memory |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_INVALID_STATE | Invalid state |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_OPERATION_FAILED | Operation failed |
int vce_set_private_data_requested_cb | ( | vce_private_data_requested_cb | callback_func | ) |
Sets a callback function for requesting the private data to the engine service.
[in] | callback_func | vce_private_data_requested event callback function |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_set_private_data_set_cb | ( | vce_private_data_set_cb | callback_func | ) |
Sets a callback function for setting the private data to the engine service.
[in] | callback_func | vce_private_data_set event callback function |
0
on success, otherwise a negative error value VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_OPERATION_FAILED | Operation failure |
VCE_ERROR_NOT_SUPPORTED_FEATURE | Not supported feature |
int vce_set_request_tts_cb | ( | vce_request_tts_cb | callback_func, |
void * | user_data | ||
) |
Sets a callback function for getting the request of sending TTS feedback from the engine service user.
[in] | callback_func | Callback function to be registered |
[in] | user_data | The user data passed to the callback function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_NOT_SUPPORTED | Not supported |
int vce_set_specific_engine_request_cb | ( | vce_specific_engine_request_cb | callback_func | ) |
Sets a callback function for getting the engine service request.
[in] | callback_func | Callback function to register |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_NOT_SUPPORTED | Not supported |
int vce_set_tts_audio_format_request_cb | ( | vce_tts_audio_format_request_cb | callback_func, |
void * | user_data | ||
) |
Sets a callback function for sending TTS audio format to the engine service user.
[in] | callback_func | Callback function to be registered |
[in] | user_data | The user data passed to the callback function |
VCE_ERROR_NONE | Successful |
VCE_ERROR_INVALID_PARAMETER | Invalid parameter |
VCE_ERROR_NOT_SUPPORTED | Not supported |
int vce_start_recording | ( | void | ) |
Starts recording voice.
VCE_ERROR_NONE | Successful |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_OPERATION_FAILED | Operation failure |
VCE_ERROR_RECORDER_BUSY | Busy recorder |
int vce_stop_recording | ( | void | ) |
Stops recording voice.
VCE_ERROR_NONE | Successful |
VCE_ERROR_PERMISSION_DENIED | Permission denied |
VCE_ERROR_NOT_SUPPORTED | Not supported |
VCE_ERROR_OPERATION_FAILED | Operation failure |
int vce_unset_cancel_tts_cb | ( | void | ) |
Unsets the TTS feedback cancellation callback function.
VC_ERROR_NONE | Successful |
VC_ERROR_NOT_SUPPORTED | Not supported |
int vce_unset_get_tts_audio_format_cb | ( | void | ) |
Unsets the TTS audio format request callback function.
VC_ERROR_NONE | Successful |
VC_ERROR_NOT_SUPPORTED | Not supported |
int vce_unset_request_tts_cb | ( | void | ) |
Unsets the TTS feedback request callback function.
VC_ERROR_NONE | Successful |
VC_ERROR_NOT_SUPPORTED | Not supported |
int vce_unset_specific_engine_request_cb | ( | void | ) |
Unsets the engine service request callback function.
VC_ERROR_NONE | Successful |
VC_ERROR_NOT_SUPPORTED | Not supported |