diff options
author | Joshua Colp <jcolp@digium.com> | 2006-04-13 00:18:52 +0000 |
---|---|---|
committer | Joshua Colp <jcolp@digium.com> | 2006-04-13 00:18:52 +0000 |
commit | 5e43f18529690f085617618e1a7b6b1c4a71dd3a (patch) | |
tree | 2df79ba8d344f5eecd8d06832c818a799f7e4492 /res/res_speech.c | |
parent | e95c757521ef6b0f1f292e27373753a13aaaf752 (diff) |
Updates to speech recognition API and dialplan utilities. Moved to using dialplan functions, and some other misc things.
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@19645 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_speech.c')
-rw-r--r-- | res/res_speech.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/res/res_speech.c b/res/res_speech.c index a1857688a..58ef56447 100644 --- a/res/res_speech.c +++ b/res/res_speech.c @@ -141,6 +141,10 @@ int ast_speech_results_free(struct ast_speech_result *result) free(current_result->text); current_result->text = NULL; } + if (current_result->grammar != NULL) { + free(current_result->grammar); + current_result->grammar = NULL; + } /* Move on and then free ourselves */ current_result = current_result->next; free(prev_result); @@ -153,6 +157,16 @@ int ast_speech_results_free(struct ast_speech_result *result) /*! \brief Start speech recognition on a speech structure */ void ast_speech_start(struct ast_speech *speech) { + + /* Clear any flags that may affect things */ + ast_clear_flag(speech, AST_SPEECH_SPOKE); + + /* If results are on the structure, free them since we are starting again */ + if (speech->results != NULL) { + ast_speech_results_free(speech->results); + speech->results = NULL; + } + /* If the engine needs to start stuff up, do it */ if (speech->engine->start != NULL) { speech->engine->start(speech); @@ -201,6 +215,9 @@ struct ast_speech *ast_speech_new(char *engine_name, int format) /* Initialize the lock */ ast_mutex_init(&new_speech->lock); + /* Make sure no results are present */ + new_speech->results = NULL; + /* Copy over our engine pointer */ new_speech->engine = engine; @@ -224,6 +241,12 @@ int ast_speech_destroy(struct ast_speech *speech) /* Deinitialize the lock */ ast_mutex_destroy(&speech->lock); + /* If results exist on the speech structure, destroy them */ + if (speech->results != NULL) { + ast_speech_results_free(speech->results); + speech->results = NULL; + } + /* If a processing sound is set - free the memory used by it */ if (speech->processing_sound != NULL) { free(speech->processing_sound); @@ -242,7 +265,14 @@ int ast_speech_change_state(struct ast_speech *speech, int state) { int res = 0; - speech->state = state; + switch (state) { + case AST_SPEECH_STATE_WAIT: + /* The engine heard audio, so they spoke */ + ast_set_flag(speech, AST_SPEECH_SPOKE); + default: + speech->state = state; + break; + } return res; } |