00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _ASTERISK_SPEECH_H
00024 #define _ASTERISK_SPEECH_H
00025
00026 #if defined(__cplusplus) || defined(c_plusplus)
00027 extern "C" {
00028 #endif
00029
00030
00031 enum ast_speech_flags {
00032 AST_SPEECH_QUIET = (1 << 0),
00033 AST_SPEECH_SPOKE = (1 << 1),
00034 AST_SPEECH_HAVE_RESULTS = (1 << 2),
00035 };
00036
00037
00038 enum ast_speech_states {
00039 AST_SPEECH_STATE_NOT_READY = 0,
00040 AST_SPEECH_STATE_READY,
00041 AST_SPEECH_STATE_WAIT,
00042 AST_SPEECH_STATE_DONE,
00043 };
00044
00045 enum ast_speech_results_type {
00046 AST_SPEECH_RESULTS_TYPE_NORMAL = 0,
00047 AST_SPEECH_RESULTS_TYPE_NBEST,
00048 };
00049
00050
00051 struct ast_speech {
00052
00053 ast_mutex_t lock;
00054
00055 unsigned int flags;
00056
00057 char *processing_sound;
00058
00059 int state;
00060
00061 int format;
00062
00063 void *data;
00064
00065 struct ast_speech_result *results;
00066
00067 enum ast_speech_results_type results_type;
00068
00069 struct ast_speech_engine *engine;
00070 };
00071
00072
00073 struct ast_speech_engine {
00074
00075 char *name;
00076
00077 int (*create)(struct ast_speech *speech, int format);
00078
00079 int (*destroy)(struct ast_speech *speech);
00080
00081 int (*load)(struct ast_speech *speech, const char *grammar_name, const char *grammar);
00082
00083 int (*unload)(struct ast_speech *speech, const char *grammar_name);
00084
00085 int (*activate)(struct ast_speech *speech, const char *grammar_name);
00086
00087 int (*deactivate)(struct ast_speech *speech, const char *grammar_name);
00088
00089 int (*write)(struct ast_speech *speech, void *data, int len);
00090
00091 int (*dtmf)(struct ast_speech *speech, const char *dtmf);
00092
00093 int (*start)(struct ast_speech *speech);
00094
00095 int (*change)(struct ast_speech *speech, const char *name, const char *value);
00096
00097 int (*change_results_type)(struct ast_speech *speech, enum ast_speech_results_type results_type);
00098
00099 struct ast_speech_result *(*get)(struct ast_speech *speech);
00100
00101 int formats;
00102 AST_LIST_ENTRY(ast_speech_engine) list;
00103 };
00104
00105
00106 struct ast_speech_result {
00107
00108 char *text;
00109
00110 int score;
00111
00112 int nbest_num;
00113
00114 char *grammar;
00115
00116 AST_LIST_ENTRY(ast_speech_result) list;
00117 };
00118
00119
00120 int ast_speech_grammar_activate(struct ast_speech *speech, const char *grammar_name);
00121
00122 int ast_speech_grammar_deactivate(struct ast_speech *speech, const char *grammar_name);
00123
00124 int ast_speech_grammar_load(struct ast_speech *speech, const char *grammar_name, const char *grammar);
00125
00126 int ast_speech_grammar_unload(struct ast_speech *speech, const char *grammar_name);
00127
00128 struct ast_speech_result *ast_speech_results_get(struct ast_speech *speech);
00129
00130 int ast_speech_results_free(struct ast_speech_result *result);
00131
00132 void ast_speech_start(struct ast_speech *speech);
00133
00134 struct ast_speech *ast_speech_new(const char *engine_name, int formats);
00135
00136 int ast_speech_destroy(struct ast_speech *speech);
00137
00138 int ast_speech_write(struct ast_speech *speech, void *data, int len);
00139
00140 int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf);
00141
00142 int ast_speech_change(struct ast_speech *speech, const char *name, const char *value);
00143
00144 int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type);
00145
00146 int ast_speech_change_state(struct ast_speech *speech, int state);
00147
00148 int ast_speech_register(struct ast_speech_engine *engine);
00149
00150 int ast_speech_unregister(const char *engine_name);
00151
00152 #if defined(__cplusplus) || defined(c_plusplus)
00153 }
00154 #endif
00155
00156 #endif