Conversation module interface.
struct asr_conversation_if asr_conversation_if_t { const char * name ; const char * asr_version ; int localized ; int(* init )(void *module_data, cfg_item_t *asr_config); void(* destroy )(void *module_data); int(* on_asr_step )(asr_step_t step, void *module_data); int(* select_result )(asr_result_t *results, void *module_data, asr_result_t **selected_result); asr_result_action_t(* on_result )(asr_result_t *result, asr_result_t *results, void *module_data); asr_result_action_t(* on_result_data )(void *result, void *module_data, int error); void(* stop )(void); };
The version number is used to prevent newer, incompatible modules from being used with an older build of ASR.
Set to 0 if no localized assets are needed.
Optional. The io-asr service calls init() for each registered module upon startup.
Optional. The io-asr service calls destroy() when shutting down a module that has successfuly initialized via the init() function.
Optional. The io-asr service calls on_asr_step() each time the state of the recognizer changes (see asr_step_t).
Optional. The io-asr service calls select_result() for the current exclusive module if there is one; otherwise, io-asr makes the call for all active registered modules. If a result is selected, it is returned via selected_result.
Optional. The io-asr service calls on_result() for a module only if no other module has a result with a higher confidence level. Results found to be relevant to this module won't be processed if this function isn't defined.
Optional. The io-asr service calls on_result_data() to specify additional parameters or pass additional data that the module requires (i.e., not recognition results). For example, the module may require a vendor-specific data format (e.g., a tracklist generated from a find music command).
Optional. The io-asr service calls stop() if the speech session is canceled before an on_result() callback has completed. This callback can be useful to break out of any function that blocks for an extended period of time in the on_result() callback. A new speech session can't be started until the on_result() callback returns.
This structure defines the interface from io-asr to the conversation modules. Each conversation module's constructor function passes this structure to the asrm_connect() function. The io-asr service invokes the member callback functions depending on the state of the module.