[asterisk-commits] trunk r37881 - in /trunk: apps/ doc/
include/asterisk/ res/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jul 18 09:22:27 MST 2006
Author: file
Date: Tue Jul 18 11:22:26 2006
New Revision: 37881
URL: http://svn.digium.com/view/asterisk?rev=37881&view=rev
Log:
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
Modified:
trunk/apps/app_speech_utils.c
trunk/doc/speechrec.txt
trunk/include/asterisk/speech.h
trunk/res/res_speech.c
Modified: trunk/apps/app_speech_utils.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_speech_utils.c?rev=37881&r1=37880&r2=37881&view=diff
==============================================================================
--- trunk/apps/app_speech_utils.c (original)
+++ trunk/apps/app_speech_utils.c Tue Jul 18 11:22:26 2006
@@ -226,6 +226,29 @@
"Gets the matched grammar of a result if available.\n",
.read = speech_grammar,
.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 */
@@ -746,6 +769,7 @@
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 @@
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;
}
Modified: trunk/doc/speechrec.txt
URL: http://svn.digium.com/view/asterisk/trunk/doc/speechrec.txt?rev=37881&r1=37880&r2=37881&view=diff
==============================================================================
--- trunk/doc/speechrec.txt (original)
+++ trunk/doc/speechrec.txt Tue Jul 18 11:22:26 2006
@@ -108,6 +108,10 @@
- ${SPEECH_GRAMMAR(result number)}:
Returns the matched grammar of the result.
+
+- SPEECH_ENGINE(name)=value
+
+Sets a speech engine specific attribute.
* Dialplan Flow:
-----------------
Modified: trunk/include/asterisk/speech.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/speech.h?rev=37881&r1=37880&r2=37881&view=diff
==============================================================================
--- trunk/include/asterisk/speech.h (original)
+++ trunk/include/asterisk/speech.h Tue Jul 18 11:22:26 2006
@@ -77,6 +77,8 @@
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 @@
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 */
Modified: trunk/res/res_speech.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_speech.c?rev=37881&r1=37880&r2=37881&view=diff
==============================================================================
--- trunk/res/res_speech.c (original)
+++ trunk/res/res_speech.c Tue Jul 18 11:22:26 2006
@@ -191,6 +191,18 @@
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)
{
More information about the asterisk-commits
mailing list