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 #define AST_SPEECH_QUIET (1 << 0)
00032 #define AST_SPEECH_SPOKE (1 << 1)
00033 #define AST_SPEECH_HAVE_RESULTS (1 << 2)
00034
00035
00036 #define AST_SPEECH_STATE_NOT_READY 0
00037 #define AST_SPEECH_STATE_READY 1
00038 #define AST_SPEECH_STATE_WAIT 2
00039 #define AST_SPEECH_STATE_DONE 3
00040
00041 enum ast_speech_results_type {
00042 AST_SPEECH_RESULTS_TYPE_NORMAL = 0,
00043 AST_SPEECH_RESULTS_TYPE_NBEST,
00044 };
00045
00046
00047 struct ast_speech {
00048
00049 ast_mutex_t lock;
00050
00051 unsigned int flags;
00052
00053 char *processing_sound;
00054
00055 int state;
00056
00057 int format;
00058
00059 void *data;
00060
00061 struct ast_speech_result *results;
00062
00063 enum ast_speech_results_type results_type;
00064
00065 struct ast_speech_engine *engine;
00066 };
00067
00068
00069 struct ast_speech_engine {
00070
00071 char *name;
00072
00073 int (*create)(struct ast_speech *speech);
00074
00075 int (*destroy)(struct ast_speech *speech);
00076
00077 int (*load)(struct ast_speech *speech, char *grammar_name, char *grammar);
00078
00079 int (*unload)(struct ast_speech *speech, char *grammar_name);
00080
00081 int (*activate)(struct ast_speech *speech, char *grammar_name);
00082
00083 int (*deactivate)(struct ast_speech *speech, char *grammar_name);
00084
00085 int (*write)(struct ast_speech *speech, void *data, int len);
00086
00087 int (*start)(struct ast_speech *speech);
00088
00089 int (*change)(struct ast_speech *speech, char *name, const char *value);
00090
00091 int (*change_results_type)(struct ast_speech *speech, enum ast_speech_results_type results_type);
00092
00093 struct ast_speech_result *(*get)(struct ast_speech *speech);
00094
00095 int formats;
00096 AST_LIST_ENTRY(ast_speech_engine) list;
00097 };
00098
00099
00100 struct ast_speech_result {
00101
00102 char *text;
00103
00104 int score;
00105
00106 int nbest_num;
00107
00108 char *grammar;
00109
00110 struct ast_speech_result *next;
00111 };
00112
00113
00114 int ast_speech_grammar_activate(struct ast_speech *speech, char *grammar_name);
00115
00116 int ast_speech_grammar_deactivate(struct ast_speech *speech, char *grammar_name);
00117
00118 int ast_speech_grammar_load(struct ast_speech *speech, char *grammar_name, char *grammar);
00119
00120 int ast_speech_grammar_unload(struct ast_speech *speech, char *grammar_name);
00121
00122 struct ast_speech_result *ast_speech_results_get(struct ast_speech *speech);
00123
00124 int ast_speech_results_free(struct ast_speech_result *result);
00125
00126 void ast_speech_start(struct ast_speech *speech);
00127
00128 struct ast_speech *ast_speech_new(char *engine_name, int format);
00129
00130 int ast_speech_destroy(struct ast_speech *speech);
00131
00132 int ast_speech_write(struct ast_speech *speech, void *data, int len);
00133
00134 int ast_speech_change(struct ast_speech *speech, char *name, const char *value);
00135
00136 int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type);
00137
00138 int ast_speech_change_state(struct ast_speech *speech, int state);
00139
00140 int ast_speech_register(struct ast_speech_engine *engine);
00141
00142 int ast_speech_unregister(char *engine_name);
00143
00144 #if defined(__cplusplus) || defined(c_plusplus)
00145 }
00146 #endif
00147
00148 #endif