diff options
author | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-10 23:29:50 +0000 |
---|---|---|
committer | file <file@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-04-10 23:29:50 +0000 |
commit | 483e826311511fc52ec00a0155582a73fd2db625 (patch) | |
tree | 165b92004e41c726c99721800866bd38eb63faf7 /include | |
parent | 31b2a51bfb374fb3789b8b69abf2e0f428935d3c (diff) |
Presenting a revised data stores and oh my, a generic speech recognition API! I wonder what we can do with this now...
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@18979 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk/channel.h | 38 | ||||
-rw-r--r-- | include/asterisk/speech.h | 125 |
2 files changed, 163 insertions, 0 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 44f70aa1e..4d1826e6e 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -144,6 +144,26 @@ struct ast_generator { int (*generate)(struct ast_channel *chan, void *data, int len, int samples); }; +/*! Structure for a data store type */ +struct ast_datastore_info { + /*! Type of data store */ + const char *type; + /*! Destroy function */ + void (*destroy)(void *data); +}; + +/*! Structure for a channel data store */ +struct ast_datastore { + /*! Unique data store identifier */ + char *uid; + /*! Contained data */ + void *data; + /*! Data store type information */ + const struct ast_datastore_info *info; + /*! Used for easy linking */ + AST_LIST_ENTRY(ast_datastore) list; +}; + /*! Structure for all kinds of caller ID identifications */ struct ast_callerid { /*! Malloc'd Dialed Number Identifier */ @@ -423,6 +443,9 @@ struct ast_channel { /*! Chan Spy stuff */ struct ast_channel_spy_list *spies; + /*! Data stores on the channel */ + AST_LIST_HEAD(datastores, ast_datastore) datastores; + /*! For easy linking */ AST_LIST_ENTRY(ast_channel) chan_list; }; @@ -553,6 +576,21 @@ enum channelreloadreason { CHANNEL_MANAGER_RELOAD, }; +/*! \brief Create a channel datastore structure */ +struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, char *uid); + +/*! \brief Free a channel datastore structure */ +int ast_channel_datastore_free(struct ast_datastore *datastore); + +/*! \brief Add a datastore to a channel */ +int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore); + +/*! \brief Remove a datastore from a channel */ +int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore); + +/*! \brief Find a datastore on a channel */ +struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, char *uid); + /*! \brief Change the state of a channel */ int ast_setstate(struct ast_channel *chan, int state); diff --git a/include/asterisk/speech.h b/include/asterisk/speech.h new file mode 100644 index 000000000..f6aa2b0dc --- /dev/null +++ b/include/asterisk/speech.h @@ -0,0 +1,125 @@ +/* + * Asterisk -- An open source telephony toolkit. + * + * Copyright (C) 2006, Digium, Inc. + * + * Joshua Colp <jcolp@digium.com> + * + * See http://www.asterisk.org for more information about + * the Asterisk project. Please do not directly contact + * any of the maintainers of this project for assistance; + * the project provides a web site, mailing lists and IRC + * channels for your use. + * + * This program is free software, distributed under the terms of + * the GNU General Public License Version 2. See the LICENSE file + * at the top of the source tree. + */ + +/*! \file + * \brief Generic Speech Recognition API + */ + +#ifndef _ASTERISK_SPEECH_H +#define _ASTERISK_SPEECH_H + +#if defined(__cplusplus) || defined(c_plusplus) +extern "C" { +#endif + +/* Speech structure flags */ +#define AST_SPEECH_QUIET (1 << 0) /* Quiet down output... they are talking */ + +/* Speech structure states - in order of expected change */ +#define AST_SPEECH_STATE_NOT_READY 0 /* Not ready to accept audio */ +#define AST_SPEECH_STATE_READY 1 /* Accepting audio */ +#define AST_SPEECH_STATE_WAIT 2 /* Wait for results to become available */ +#define AST_SPEECH_STATE_DONE 3 /* Processing is done */ + +/* Speech structure */ +struct ast_speech { + /*! Structure lock */ + ast_mutex_t lock; + /*! Set flags */ + unsigned int flags; + /*! Processing sound (used when engine is processing audio and getting results) */ + char *processing_sound; + /*! Current state of structure */ + int state; + /*! Expected write format */ + int format; + /*! Data for speech engine */ + void *data; + /*! Pointer to the engine used by this speech structure */ + struct ast_speech_engine *engine; +}; + +/* Speech recognition engine structure */ +struct ast_speech_engine { + /*! Name of speech engine */ + char *name; + /*! Set up the speech structure within the engine */ + int (*new)(struct ast_speech *speech); + /*! Destroy any data set on the speech structure by the engine */ + int (*destroy)(struct ast_speech *speech); + /*! Load a local grammar on the speech structure */ + int (*load)(struct ast_speech *speech, char *grammar_name, char *grammar); + /*! Unload a local grammar */ + int (*unload)(struct ast_speech *speech, char *grammar_name); + /*! Activate a loaded grammar */ + int (*activate)(struct ast_speech *speech, char *grammar_name); + /*! Deactivate a loaded grammar */ + int (*deactivate)(struct ast_speech *speech, char *grammar_name); + /*! Write audio to the speech engine */ + int (*write)(struct ast_speech *speech, void *data, int len); + /*! Prepare engine to accept audio */ + int (*start)(struct ast_speech *speech); + /*! Try to get results */ + struct ast_speech_result *(*get)(struct ast_speech *speech); + /*! Accepted formats by the engine */ + int formats; + AST_LIST_ENTRY(ast_speech_engine) list; +}; + +/* Result structure */ +struct ast_speech_result { + /*! Recognized text */ + char *text; + /*! Result score */ + int score; + /*! Next result (may not always be present) */ + struct ast_speech_result *next; +}; + +/*! \brief Activate a grammar on a speech structure */ +int ast_speech_grammar_activate(struct ast_speech *speech, char *grammar_name); +/*! \brief Deactivate a grammar on a speech structure */ +int ast_speech_grammar_deactivate(struct ast_speech *speech, char *grammar_name); +/*! \brief Load a grammar on a speech structure (not globally) */ +int ast_speech_grammar_load(struct ast_speech *speech, char *grammar_name, char *grammar); +/*! \brief Unload a grammar */ +int ast_speech_grammar_unload(struct ast_speech *speech, char *grammar_name); +/*! \brief Get speech recognition results */ +struct ast_speech_result *ast_speech_results_get(struct ast_speech *speech); +/*! \brief Free a set of results */ +int ast_speech_results_free(struct ast_speech_result *result); +/*! \brief Indicate to the speech engine that audio is now going to start being written */ +void ast_speech_start(struct ast_speech *speech); +/*! \brief Create a new speech structure */ +struct ast_speech *ast_speech_new(char *engine_name, int format); +/*! \brief Destroy a speech structure */ +int ast_speech_destroy(struct ast_speech *speech); +/*! \brief Write audio to the speech engine */ +int ast_speech_write(struct ast_speech *speech, void *data, int len); +/*! \brief Change state of a speech structure */ +int ast_speech_change_state(struct ast_speech *speech, int state); +/*! \brief Register a speech recognition engine */ +int ast_speech_register(struct ast_speech_engine *engine); +/*! \brief Unregister a speech recognition engine */ +int ast_speech_unregister(char *engine_name); + +#if defined(__cplusplus) || defined(c_plusplus) +} +#endif + +#endif /* _ASTERISK_SPEECH_H */ |