|
|
|
@ -137,8 +137,9 @@ static struct ast_speech_result *find_result(struct ast_speech_result *results,
|
|
|
|
|
char *tmp = NULL;
|
|
|
|
|
int nbest_num = 0, wanted_num = 0, i = 0;
|
|
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
|
if (!result) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((tmp = strchr(result_num, '/'))) {
|
|
|
|
|
*tmp++ = '\0';
|
|
|
|
@ -167,8 +168,9 @@ static int speech_score(struct ast_channel *chan, const char *cmd, char *data,
|
|
|
|
|
struct ast_speech *speech = find_speech(chan);
|
|
|
|
|
char tmp[128] = "";
|
|
|
|
|
|
|
|
|
|
if (data == NULL || speech == NULL || !(result = find_result(speech->results, data)))
|
|
|
|
|
if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
snprintf(tmp, sizeof(tmp), "%d", result->score);
|
|
|
|
|
|
|
|
|
@ -194,11 +196,13 @@ static int speech_text(struct ast_channel *chan, const char *cmd, char *data,
|
|
|
|
|
struct ast_speech_result *result = NULL;
|
|
|
|
|
struct ast_speech *speech = find_speech(chan);
|
|
|
|
|
|
|
|
|
|
if (data == NULL || speech == NULL || !(result = find_result(speech->results, data)))
|
|
|
|
|
if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result->text != NULL)
|
|
|
|
|
if (result->text != NULL) {
|
|
|
|
|
ast_copy_string(buf, result->text, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -220,11 +224,13 @@ static int speech_grammar(struct ast_channel *chan, const char *cmd, char *data,
|
|
|
|
|
struct ast_speech_result *result = NULL;
|
|
|
|
|
struct ast_speech *speech = find_speech(chan);
|
|
|
|
|
|
|
|
|
|
if (data == NULL || speech == NULL || !(result = find_result(speech->results, data)))
|
|
|
|
|
if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (result->grammar != NULL)
|
|
|
|
|
if (result->grammar != NULL) {
|
|
|
|
|
ast_copy_string(buf, result->grammar, len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
@ -244,8 +250,9 @@ static int speech_engine_write(struct ast_channel *chan, const char *cmd, char *
|
|
|
|
|
{
|
|
|
|
|
struct ast_speech *speech = find_speech(chan);
|
|
|
|
|
|
|
|
|
|
if (data == NULL || speech == NULL)
|
|
|
|
|
if (data == NULL || speech == NULL) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ast_speech_change(speech, data, value);
|
|
|
|
|
|
|
|
|
|