diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-07-18 16:22:26 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-07-18 16:22:26 +0000 |
commit | 1e12d4e1dfa54ea93e7ed217fc18450c154f7855 (patch) | |
tree | 4867337433a34db5828536cbd38ff14bd22e6c45 | |
parent | 1dc3bbe40360ddc1de994ea234a10b1dfb05c521 (diff) |
Expand speech API so that the developer can interact with the engine more directly and use specific functions of the connector even if a generic API call is not available
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@37881 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r-- | apps/app_speech_utils.c | 25 | ||||
-rw-r--r-- | doc/speechrec.txt | 4 | ||||
-rw-r--r-- | include/asterisk/speech.h | 4 | ||||
-rw-r--r-- | res/res_speech.c | 12 |
4 files changed, 45 insertions, 0 deletions
diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c index c464576f7..a63eee828 100644 --- a/apps/app_speech_utils.c +++ b/apps/app_speech_utils.c @@ -228,6 +228,29 @@ static struct ast_custom_function speech_grammar_function = { .write = NULL, }; +/*! \brief SPEECH_ENGINE() Dialplan Function */ +static int speech_engine_write(struct ast_channel *chan, char *cmd, char *data, const char *value) +{ + struct ast_speech *speech = find_speech(chan); + + if (data == NULL || speech == NULL) + return -1; + + ast_speech_change(speech, data, value); + + return 0; +} + +static struct ast_custom_function speech_engine_function = { + .name = "SPEECH_ENGINE", + .synopsis = "Change a speech engine specific attribute.", + .syntax = "SPEECH_ENGINE(name)=value", + .desc = + "Changes a speech engine specific attribute.\n", + .read = NULL, + .write = speech_engine_write, +}; + /*! \brief SPEECH() Dialplan Function */ static int speech_read(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) @@ -746,6 +769,7 @@ static int unload_module(void *mod) res |= ast_custom_function_unregister(&speech_score_function); res |= ast_custom_function_unregister(&speech_text_function); res |= ast_custom_function_unregister(&speech_grammar_function); + res |= ast_custom_function_unregister(&speech_engine_function); STANDARD_HANGUP_LOCALUSERS; @@ -769,6 +793,7 @@ static int load_module(void *mod) res |= ast_custom_function_register(&speech_score_function); res |= ast_custom_function_register(&speech_text_function); res |= ast_custom_function_register(&speech_grammar_function); + res |= ast_custom_function_register(&speech_engine_function); return res; } diff --git a/doc/speechrec.txt b/doc/speechrec.txt index 7c4960ea3..8aa157de1 100644 --- a/doc/speechrec.txt +++ b/doc/speechrec.txt @@ -109,6 +109,10 @@ Returns the recognized text of a result. Returns the matched grammar of the result. +- SPEECH_ENGINE(name)=value + +Sets a speech engine specific attribute. + * Dialplan Flow: ----------------- diff --git a/include/asterisk/speech.h b/include/asterisk/speech.h index afd12afda..0f1af151f 100644 --- a/include/asterisk/speech.h +++ b/include/asterisk/speech.h @@ -77,6 +77,8 @@ struct ast_speech_engine { int (*write)(struct ast_speech *speech, void *data, int len); /*! Prepare engine to accept audio */ int (*start)(struct ast_speech *speech); + /*! Change an engine specific setting */ + int (*change)(struct ast_speech *speech, char *name, const char *value); /*! Try to get results */ struct ast_speech_result *(*get)(struct ast_speech *speech); /*! Accepted formats by the engine */ @@ -116,6 +118,8 @@ struct ast_speech *ast_speech_new(char *engine_name, int format); int ast_speech_destroy(struct ast_speech *speech); /*! \brief Write audio to the speech engine */ int ast_speech_write(struct ast_speech *speech, void *data, int len); +/*! \brief Change an engine specific attribute */ +int ast_speech_change(struct ast_speech *speech, char *name, const char *value); /*! \brief Change state of a speech structure */ int ast_speech_change_state(struct ast_speech *speech, int state); /*! \brief Register a speech recognition engine */ diff --git a/res/res_speech.c b/res/res_speech.c index 62458173e..f99c352b9 100644 --- a/res/res_speech.c +++ b/res/res_speech.c @@ -191,6 +191,18 @@ int ast_speech_write(struct ast_speech *speech, void *data, int len) return res; } +/*! \brief Change an engine specific attribute */ +int ast_speech_change(struct ast_speech *speech, char *name, const char *value) +{ + int res = 0; + + if (speech->engine->change != NULL) { + res = speech->engine->change(speech, name, value); + } + + return res; +} + /*! \brief Create a new speech structure using the engine specified */ struct ast_speech *ast_speech_new(char *engine_name, int format) { |