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