| Asterisk - The Open Source Telephony Project GIT-master-27fb039
    | 
Generic Speech Recognition API. More...
#include "asterisk.h"#include "asterisk/channel.h"#include "asterisk/module.h"#include "asterisk/lock.h"#include "asterisk/linkedlists.h"#include "asterisk/cli.h"#include "asterisk/term.h"#include "asterisk/speech.h"#include "asterisk/format_cache.h"#include "asterisk/translate.h"
Go to the source code of this file.
| Data Structures | |
| struct | engines | 
| Functions | |
| static void | __reg_module (void) | 
| static void | __unreg_module (void) | 
| struct ast_module * | AST_MODULE_SELF_SYM (void) | 
| int | ast_speech_change (struct ast_speech *speech, const char *name, const char *value) | 
| Change an engine specific attribute. | |
| int | ast_speech_change_results_type (struct ast_speech *speech, enum ast_speech_results_type results_type) | 
| Change the type of results we want. | |
| int | ast_speech_change_state (struct ast_speech *speech, int state) | 
| Change state of a speech structure. | |
| int | ast_speech_destroy (struct ast_speech *speech) | 
| Destroy a speech structure. | |
| int | ast_speech_dtmf (struct ast_speech *speech, const char *dtmf) | 
| Signal to the engine that DTMF was received. | |
| struct ast_speech_engine * | ast_speech_find_engine (const char *engine_name) | 
| Find a speech recognition engine of specified name, if NULL then use the default one. | |
| int | ast_speech_get_setting (struct ast_speech *speech, const char *name, char *buf, size_t len) | 
| Get an engine specific attribute. | |
| int | ast_speech_grammar_activate (struct ast_speech *speech, const char *grammar_name) | 
| Activate a loaded (either local or global) grammar. | |
| int | ast_speech_grammar_deactivate (struct ast_speech *speech, const char *grammar_name) | 
| Deactivate a loaded grammar on a speech structure. | |
| int | ast_speech_grammar_load (struct ast_speech *speech, const char *grammar_name, const char *grammar) | 
| Load a local grammar on a speech structure. | |
| int | ast_speech_grammar_unload (struct ast_speech *speech, const char *grammar_name) | 
| Unload a local grammar from a speech structure. | |
| struct ast_speech * | ast_speech_new (const char *engine_name, const struct ast_format_cap *cap) | 
| Create a new speech structure using the engine specified. | |
| int | ast_speech_register (struct ast_speech_engine *engine) | 
| Register a speech recognition engine. | |
| int | ast_speech_results_free (struct ast_speech_result *result) | 
| Free a list of results. | |
| struct ast_speech_result * | ast_speech_results_get (struct ast_speech *speech) | 
| Return the results of a recognition from the speech structure. | |
| const char * | ast_speech_results_type_to_string (enum ast_speech_results_type type) | 
| Convert a speech results type to a string. | |
| void | ast_speech_start (struct ast_speech *speech) | 
| Start speech recognition on a speech structure. | |
| int | ast_speech_unregister (const char *engine_name) | 
| Unregister a speech recognition engine. | |
| struct ast_speech_engine * | ast_speech_unregister2 (const char *engine_name) | 
| Unregister a speech recognition engine. | |
| void | ast_speech_unregister_engines (int(*should_unregister)(const struct ast_speech_engine *engine, void *data), void *data, void(*on_unregistered)(void *obj)) | 
| Unregister all speech recognition engines told to by callback. | |
| int | ast_speech_write (struct ast_speech *speech, void *data, int len) | 
| Write in signed linear audio to be recognized. | |
| static int | load_module (void) | 
| static int | unload_module (void) | 
| Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Generic Speech Recognition API" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_APP_DEPEND - 1, } | 
| static const struct ast_module_info * | ast_module_info = &__mod_info | 
| static struct ast_speech_engine * | default_engine = NULL | 
| static struct engines | engines = AST_RWLIST_HEAD_INIT_VALUE | 
Generic Speech Recognition API.
Definition in file res_speech.c.
| 
 | static | 
Definition at line 426 of file res_speech.c.
| 
 | static | 
Definition at line 426 of file res_speech.c.
| struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) | 
Definition at line 426 of file res_speech.c.
| int ast_speech_change | ( | struct ast_speech * | speech, | 
| const char * | name, | ||
| const char * | value | ||
| ) | 
Change an engine specific attribute.
Definition at line 169 of file res_speech.c.
References ast_speech_engine::change, ast_speech::engine, name, and value.
Referenced by AST_TEST_DEFINE(), handle_speechset(), and speech_engine_write().
| int ast_speech_change_results_type | ( | struct ast_speech * | speech, | 
| enum ast_speech_results_type | results_type | ||
| ) | 
Change the type of results we want.
Definition at line 308 of file res_speech.c.
References ast_speech_engine::change_results_type, ast_speech::engine, and ast_speech::results_type.
Referenced by AST_TEST_DEFINE(), and speech_results_type_write().
| int ast_speech_change_state | ( | struct ast_speech * | speech, | 
| int | state | ||
| ) | 
Change state of a speech structure.
Definition at line 278 of file res_speech.c.
References ast_set_flag, AST_SPEECH_SPOKE, AST_SPEECH_STATE_WAIT, and ast_speech::state.
Referenced by ast_aeap_speech_on_error(), ast_speech_new(), handle_request_set(), handle_speechrecognize(), speech_aeap_engine_start(), and speech_background().
| int ast_speech_destroy | ( | struct ast_speech * | speech | ) | 
Destroy a speech structure.
Definition at line 251 of file res_speech.c.
References ao2_ref, ast_free, ast_mutex_destroy, ast_speech_results_free(), ast_speech_engine::destroy, ast_speech::engine, ast_speech::format, ast_speech::lock, ast_speech::processing_sound, and ast_speech::results.
Referenced by AST_TEST_DEFINE(), destroy_callback(), handle_speechdestroy(), launch_asyncagi(), run_agi(), and speech_create().
| int ast_speech_dtmf | ( | struct ast_speech * | speech, | 
| const char * | dtmf | ||
| ) | 
Signal to the engine that DTMF was received.
Definition at line 154 of file res_speech.c.
References AST_SPEECH_STATE_READY, ast_speech_engine::dtmf, ast_speech::engine, NULL, and ast_speech::state.
Referenced by AST_TEST_DEFINE(), and speech_background().
| struct ast_speech_engine * ast_speech_find_engine | ( | const char * | engine_name | ) | 
Find a speech recognition engine of specified name, if NULL then use the default one.
Retrieve a speech recognition engine.
Definition at line 46 of file res_speech.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_strlen_zero(), default_engine, ast_speech_engine::name, NULL, and ast_speech_engine::start.
Referenced by ast_speech_new(), ast_speech_register(), and load_engine().
| int ast_speech_get_setting | ( | struct ast_speech * | speech, | 
| const char * | name, | ||
| char * | buf, | ||
| size_t | len | ||
| ) | 
Get an engine specific attribute.
Definition at line 175 of file res_speech.c.
References buf, ast_speech::engine, ast_speech_engine::get_setting, len(), and name.
Referenced by AST_TEST_DEFINE(), and speech_engine_read().
| int ast_speech_grammar_activate | ( | struct ast_speech * | speech, | 
| const char * | grammar_name | ||
| ) | 
Activate a loaded (either local or global) grammar.
Activate a grammar on a speech structure.
Definition at line 66 of file res_speech.c.
References ast_speech_engine::activate, ast_speech::engine, and ast_speech_engine::start.
Referenced by handle_speechactivategrammar(), and speech_activate().
| int ast_speech_grammar_deactivate | ( | struct ast_speech * | speech, | 
| const char * | grammar_name | ||
| ) | 
Deactivate a loaded grammar on a speech structure.
Deactivate a grammar on a speech structure.
Definition at line 72 of file res_speech.c.
References ast_speech_engine::deactivate, ast_speech::engine, and ast_speech_engine::start.
Referenced by handle_speechdeactivategrammar(), and speech_deactivate().
| int ast_speech_grammar_load | ( | struct ast_speech * | speech, | 
| const char * | grammar_name, | ||
| const char * | grammar | ||
| ) | 
Load a local grammar on a speech structure.
Load a grammar on a speech structure (not globally)
Definition at line 78 of file res_speech.c.
References ast_speech::engine, ast_speech_engine::load, and ast_speech_engine::start.
Referenced by handle_speechloadgrammar(), and speech_load().
| int ast_speech_grammar_unload | ( | struct ast_speech * | speech, | 
| const char * | grammar_name | ||
| ) | 
Unload a local grammar from a speech structure.
Unload a grammar.
Definition at line 84 of file res_speech.c.
References ast_speech::engine, ast_speech_engine::start, and ast_speech_engine::unload.
Referenced by handle_speechunloadgrammar(), and speech_unload().
| struct ast_speech * ast_speech_new | ( | const char * | engine_name, | 
| const struct ast_format_cap * | cap | ||
| ) | 
Create a new speech structure using the engine specified.
Create a new speech structure.
Definition at line 181 of file res_speech.c.
References ao2_bump, ao2_cleanup, ao2_ref, ast_calloc, ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, ast_format_cap_get_compatible(), ast_format_cap_get_format(), ast_format_cap_iscompatible_format(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_slin, ast_free, ast_mutex_destroy, ast_mutex_init, ast_speech_change_state(), ast_speech_find_engine(), AST_SPEECH_STATE_NOT_READY, ast_translator_best_choice(), ast_speech_engine::create, ast_speech::engine, ast_speech::format, ast_speech_engine::formats, ast_speech::lock, NULL, RAII_VAR, and ast_speech::results.
Referenced by AST_TEST_DEFINE(), handle_speechcreate(), and speech_create().
| int ast_speech_register | ( | struct ast_speech_engine * | engine | ) | 
Register a speech recognition engine.
Definition at line 316 of file res_speech.c.
References ast_log, AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_speech_find_engine(), ast_verb, ast_speech_engine::create, default_engine, ast_speech_engine::destroy, LOG_WARNING, ast_speech_engine::name, and ast_speech_engine::write.
Referenced by speech_engine_alloc_and_register().
| int ast_speech_results_free | ( | struct ast_speech_result * | result | ) | 
Free a list of results.
Free a set of results.
Definition at line 96 of file res_speech.c.
References ast_free, AST_LIST_NEXT, ast_speech_result::grammar, NULL, result, and ast_speech_result::text.
Referenced by ast_speech_destroy(), ast_speech_start(), and AST_TEST_DEFINE().
| struct ast_speech_result * ast_speech_results_get | ( | struct ast_speech * | speech | ) | 
Return the results of a recognition from the speech structure.
Get speech recognition results.
Definition at line 90 of file res_speech.c.
References ast_speech::engine, ast_speech_engine::get, and NULL.
Referenced by AST_TEST_DEFINE(), handle_speechrecognize(), and speech_background().
| const char * ast_speech_results_type_to_string | ( | enum ast_speech_results_type | type | ) | 
Convert a speech results type to a string.
Definition at line 294 of file res_speech.c.
References ast_assert, AST_SPEECH_RESULTS_TYPE_NBEST, AST_SPEECH_RESULTS_TYPE_NORMAL, and type.
Referenced by speech_aeap_engine_change_results_type().
| void ast_speech_start | ( | struct ast_speech * | speech | ) | 
Start speech recognition on a speech structure.
Indicate to the speech engine that audio is now going to start being written.
Definition at line 122 of file res_speech.c.
References ast_clear_flag, AST_SPEECH_HAVE_RESULTS, AST_SPEECH_QUIET, ast_speech_results_free(), AST_SPEECH_SPOKE, ast_speech::engine, NULL, ast_speech::results, and ast_speech_engine::start.
Referenced by AST_TEST_DEFINE(), handle_speechrecognize(), speech_background(), and speech_start().
| int ast_speech_unregister | ( | const char * | engine_name | ) | 
Unregister a speech recognition engine.
Definition at line 347 of file res_speech.c.
References ast_speech_unregister2(), and NULL.
| struct ast_speech_engine * ast_speech_unregister2 | ( | const char * | engine_name | ) | 
Unregister a speech recognition engine.
Definition at line 352 of file res_speech.c.
References AST_RWLIST_FIRST, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_verb, default_engine, ast_speech_engine::name, NULL, and ast_speech_engine::start.
Referenced by ast_speech_unregister(), load_engine(), unload_engine(), and unload_module().
| void ast_speech_unregister_engines | ( | int(*)(const struct ast_speech_engine *engine, void *data) | should_unregister, | 
| void * | data, | ||
| void(*)(void *obj) | on_unregistered | ||
| ) | 
Unregister all speech recognition engines told to by callback.
Definition at line 380 of file res_speech.c.
References AST_RWLIST_FIRST, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verb, default_engine, ast_speech_engine::name, NULL, should_unregister(), and ast_speech_engine::start.
Referenced by speech_observer_loaded().
| int ast_speech_write | ( | struct ast_speech * | speech, | 
| void * | data, | ||
| int | len | ||
| ) | 
Write in signed linear audio to be recognized.
Write audio to the speech engine.
Definition at line 144 of file res_speech.c.
References AST_SPEECH_STATE_READY, ast_speech::engine, len(), ast_speech::state, and ast_speech_engine::write.
Referenced by handle_speechrecognize(), and speech_background().
| 
 | static | 
| 
 | static | 
Definition at line 410 of file res_speech.c.
| 
 | static | 
Definition at line 426 of file res_speech.c.
| 
 | static | 
Definition at line 426 of file res_speech.c.
| 
 | static | 
Definition at line 43 of file res_speech.c.
Referenced by ast_speech_find_engine(), ast_speech_register(), ast_speech_unregister2(), and ast_speech_unregister_engines().
| 
 | static |