mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
res_speech: Add a type conversion, and new engine unregister methods
Add a new function that converts a speech results type to a string. Also add another function to unregister an engine, but returns a pointer to the unregistered engine object instead of a success/fail integer. Change-Id: I0f7de17cb411021c09fb03988bc2b904e1380192
This commit is contained in:
committed by
Kevin Harwell
parent
99a1a427a9
commit
8beac820c0
@@ -47,6 +47,9 @@ enum ast_speech_results_type {
|
|||||||
AST_SPEECH_RESULTS_TYPE_NBEST,
|
AST_SPEECH_RESULTS_TYPE_NBEST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*! \brief Convert a speech results type to a string */
|
||||||
|
const char *ast_speech_results_type_to_string(enum ast_speech_results_type type);
|
||||||
|
|
||||||
/* Speech structure */
|
/* Speech structure */
|
||||||
struct ast_speech {
|
struct ast_speech {
|
||||||
/*! Structure lock */
|
/*! Structure lock */
|
||||||
@@ -152,6 +155,9 @@ int ast_speech_change_state(struct ast_speech *speech, int state);
|
|||||||
int ast_speech_register(struct ast_speech_engine *engine);
|
int ast_speech_register(struct ast_speech_engine *engine);
|
||||||
/*! \brief Unregister a speech recognition engine */
|
/*! \brief Unregister a speech recognition engine */
|
||||||
int ast_speech_unregister(const char *engine_name);
|
int ast_speech_unregister(const char *engine_name);
|
||||||
|
/*! \brief Unregister a speech recognition engine */
|
||||||
|
struct ast_speech_engine *ast_speech_unregister2(const char *engine_name);
|
||||||
|
|
||||||
|
|
||||||
#if defined(__cplusplus) || defined(c_plusplus)
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
}
|
}
|
||||||
|
@@ -280,6 +280,19 @@ int ast_speech_change_state(struct ast_speech *speech, int state)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *ast_speech_results_type_to_string(enum ast_speech_results_type type)
|
||||||
|
{
|
||||||
|
switch (type) {
|
||||||
|
case AST_SPEECH_RESULTS_TYPE_NORMAL:
|
||||||
|
return "normal";
|
||||||
|
case AST_SPEECH_RESULTS_TYPE_NBEST:
|
||||||
|
return "nbest";
|
||||||
|
default:
|
||||||
|
ast_assert(0);
|
||||||
|
return "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*! \brief Change the type of results we want */
|
/*! \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)
|
int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type)
|
||||||
{
|
{
|
||||||
@@ -322,11 +335,16 @@ int ast_speech_register(struct ast_speech_engine *engine)
|
|||||||
/*! \brief Unregister a speech recognition engine */
|
/*! \brief Unregister a speech recognition engine */
|
||||||
int ast_speech_unregister(const char *engine_name)
|
int ast_speech_unregister(const char *engine_name)
|
||||||
{
|
{
|
||||||
struct ast_speech_engine *engine = NULL;
|
return ast_speech_unregister2(engine_name) == NULL ? -1 : 0;
|
||||||
int res = -1;
|
}
|
||||||
|
|
||||||
if (ast_strlen_zero(engine_name))
|
struct ast_speech_engine *ast_speech_unregister2(const char *engine_name)
|
||||||
return -1;
|
{
|
||||||
|
struct ast_speech_engine *engine = NULL;
|
||||||
|
|
||||||
|
if (ast_strlen_zero(engine_name)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
AST_RWLIST_WRLOCK(&engines);
|
AST_RWLIST_WRLOCK(&engines);
|
||||||
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&engines, engine, list) {
|
AST_RWLIST_TRAVERSE_SAFE_BEGIN(&engines, engine, list) {
|
||||||
@@ -339,14 +357,13 @@ int ast_speech_unregister(const char *engine_name)
|
|||||||
}
|
}
|
||||||
ast_verb(2, "Unregistered speech recognition engine '%s'\n", engine_name);
|
ast_verb(2, "Unregistered speech recognition engine '%s'\n", engine_name);
|
||||||
/* All went well */
|
/* All went well */
|
||||||
res = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
AST_RWLIST_TRAVERSE_SAFE_END;
|
AST_RWLIST_TRAVERSE_SAFE_END;
|
||||||
AST_RWLIST_UNLOCK(&engines);
|
AST_RWLIST_UNLOCK(&engines);
|
||||||
|
|
||||||
return res;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int unload_module(void)
|
static int unload_module(void)
|
||||||
|
Reference in New Issue
Block a user