diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c index 3e071c07a888d4384fb9f0997bb263d9a2931d28..011d655ea5e5bc88615af607db20478769173ba8 100644 --- a/apps/app_speech_utils.c +++ b/apps/app_speech_utils.c @@ -213,7 +213,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$"); </function> <function name="SPEECH_ENGINE" language="en_US"> <synopsis> - Change a speech engine specific attribute. + Get or change a speech engine specific attribute. </synopsis> <syntax> <parameter name="name" required="true" /> @@ -401,7 +401,7 @@ static struct ast_custom_function speech_grammar_function = { .write = NULL, }; -/*! \brief SPEECH_ENGINE() Dialplan Function */ +/*! \brief SPEECH_ENGINE() Dialplan Set Function */ static int speech_engine_write(struct ast_channel *chan, const char *cmd, char *data, const char *value) { struct ast_speech *speech = find_speech(chan); @@ -415,9 +415,21 @@ static int speech_engine_write(struct ast_channel *chan, const char *cmd, char * return 0; } +/*! \brief SPEECH_ENGINE() Dialplan Get Function */ +static int speech_engine_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) +{ + struct ast_speech *speech = find_speech(chan); + + if (!data || !speech) { + return -1; + } + + return ast_speech_get_setting(speech, data, buf, len); +} + static struct ast_custom_function speech_engine_function = { .name = "SPEECH_ENGINE", - .read = NULL, + .read = speech_engine_read, .write = speech_engine_write, }; diff --git a/include/asterisk/speech.h b/include/asterisk/speech.h index 5397d8aaadf407969f42e7876a92bb1578b9ffa8..a914f4846606e0c218e5819def4f4c4d199071f1 100644 --- a/include/asterisk/speech.h +++ b/include/asterisk/speech.h @@ -93,6 +93,8 @@ struct ast_speech_engine { int (*start)(struct ast_speech *speech); /*! Change an engine specific setting */ int (*change)(struct ast_speech *speech, const char *name, const char *value); + /*! Get an engine specific setting */ + int (*get_setting)(struct ast_speech *speech, const char *name, char *buf, size_t len); /*! Change the type of results we want back */ int (*change_results_type)(struct ast_speech *speech, enum ast_speech_results_type results_type); /*! Try to get results */ @@ -140,6 +142,8 @@ int ast_speech_write(struct ast_speech *speech, void *data, int len); int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf); /*! \brief Change an engine specific attribute */ int ast_speech_change(struct ast_speech *speech, const char *name, const char *value); +/*! \brief Get an engine specific attribute */ +int ast_speech_get_setting(struct ast_speech *speech, const char *name, char *buf, size_t len); /*! \brief Change the type of results we want */ int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type); /*! \brief Change state of a speech structure */ diff --git a/res/res_speech.c b/res/res_speech.c index e6fdab9d09252a824c75450a20e19124bf9514f7..71c283f409bd1f55cf5a63f8c8c898839b248ea4 100644 --- a/res/res_speech.c +++ b/res/res_speech.c @@ -172,6 +172,12 @@ int ast_speech_change(struct ast_speech *speech, const char *name, const char *v return (speech->engine->change ? speech->engine->change(speech, name, value) : -1); } +/*! \brief Get an engine specific attribute */ +int ast_speech_get_setting(struct ast_speech *speech, const char *name, char *buf, size_t len) +{ + return (speech->engine->get_setting ? speech->engine->get_setting(speech, name, buf, len) : -1); +} + /*! \brief Create a new speech structure using the engine specified */ struct ast_speech *ast_speech_new(const char *engine_name, const struct ast_format_cap *cap) {