278 if (speech ==
NULL) {
307 if (datastore ==
NULL) {
310 speech = datastore->
data;
349 int nbest_num = 0, wanted_num = 0, i = 0;
355 if ((
tmp = strchr(result_num,
'/'))) {
358 wanted_num = atoi(
tmp);
360 wanted_num = atoi(result_num);
394 .
name =
"SPEECH_SCORE",
420 .
name =
"SPEECH_TEXT",
446 .
name =
"SPEECH_GRAMMAR",
470 if (!
data || !speech) {
478 .
name =
"SPEECH_ENGINE",
491 if (!strcasecmp(
value,
"normal"))
493 else if (!strcasecmp(
value,
"nbest"))
500 .
name =
"SPEECH_RESULTS_TYPE",
515 if (!strcasecmp(
data,
"status")) {
524 if (speech ==
NULL) {
529 if (!strcasecmp(
data,
"spoke")) {
534 }
else if (!strcasecmp(
data,
"results")) {
563 if (speech ==
NULL) {
570 if (datastore ==
NULL) {
576 datastore->
data = speech;
717 unsigned int timeout = 0;
718 int res = 0,
done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
723 struct timeval start = { 0, 0 },
current;
724 char *parse, *filename_tmp =
NULL, *filename =
NULL,
tmp[2] =
"", dtmf_terminator =
'#';
725 const char *tmp2 =
NULL;
761 if ((timeout = atof(
args.timeout) * 1000.0) == 0)
770 max_dtmf_len = atoi(tmp2);
776 dtmf_terminator =
'\0';
778 dtmf_terminator = tmp2[0];
823 if ((!quieted || strlen(dtmf)) && started == 1) {
842 switch (speech->
state) {
905 if (dtmf_terminator !=
'\0' && f->
subclass.
integer == dtmf_terminator) {
919 strncat(dtmf,
tmp,
sizeof(dtmf) - strlen(dtmf) - 1);
921 if (max_dtmf_len && strlen(dtmf) == max_dtmf_len)
1027 .
requires =
"res_speech",
static int speech_grammar(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_GRAMMAR() Dialplan Function.
static int speech_unload(struct ast_channel *chan, const char *data)
SpeechUnloadGrammar(Grammar Name) Dialplan Application.
static int speech_text(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_TEXT() Dialplan Function.
static struct ast_custom_function speech_engine_function
static struct ast_custom_function speech_score_function
static const struct ast_datastore_info speech_datastore
Static structure for datastore information.
static int speech_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)
Helper function used by speech_background to playback a soundfile.
static const struct ast_app_option speech_background_options[128]
static int speech_create(struct ast_channel *chan, const char *data)
SpeechCreate() Dialplan Application.
static int speech_results_type_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
SPEECH_RESULTS_TYPE() Dialplan Function.
static int speech_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH() Dialplan Function.
static struct ast_speech_result * find_result(struct ast_speech_result *results, char *result_num)
static int speech_score(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_SCORE() Dialplan Function.
static struct ast_custom_function speech_results_type_function
static int speech_activate(struct ast_channel *chan, const char *data)
SpeechActivateGrammar(Grammar Name) Dialplan Application.
static int speech_start(struct ast_channel *chan, const char *data)
SpeechStart() Dialplan Application.
static int speech_datastore_destroy(struct ast_channel *chan)
static int speech_engine_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
SPEECH_ENGINE() Dialplan Set Function.
static int speech_engine_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_ENGINE() Dialplan Get Function.
static int speech_load(struct ast_channel *chan, const char *vdata)
SpeechLoadGrammar(Grammar Name,Path) Dialplan Application.
static struct ast_custom_function speech_function
static int speech_destroy(struct ast_channel *chan, const char *data)
SpeechDestroy() Dialplan Application.
static void destroy_callback(void *data)
Helper function used by datastores to destroy the speech structure upon hangup.
static int load_module(void)
static int unload_module(void)
static int speech_processing_sound(struct ast_channel *chan, const char *data)
SpeechProcessingSound(Sound File) Dialplan Application.
static int speech_background(struct ast_channel *chan, const char *data)
SpeechBackground(Sound File,Timeout) Dialplan Application.
static int speech_deactivate(struct ast_channel *chan, const char *data)
SpeechDeactivateGrammar(Grammar Name) Dialplan Application.
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
static struct ast_custom_function speech_text_function
static struct ast_custom_function speech_grammar_function
Asterisk main include file. File version handling, generic pbx functions.
#define ast_strdup(str)
A wrapper for strdup()
#define ast_strdupa(s)
duplicate a string in memory from the stack
#define ast_calloc(num, len)
A wrapper for calloc()
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
General Asterisk PBX channel definitions.
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_channel_lock(chan)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
int ast_channel_streamid(const struct ast_channel *chan)
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
int ast_answer(struct ast_channel *chan)
Answer a channel.
#define ast_channel_unlock(chan)
#define AST_MAX_EXTENSION
struct ast_datastore * ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, const char *uid)
Find a datastore on a channel.
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
ast_channel_state
ast_channel states
#define ast_datastore_alloc(info, uid)
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Generic File Format Support. Should be included by clients of the file handling routines....
struct ast_filestream * ast_openstream(struct ast_channel *chan, const char *filename, const char *preflang)
Opens stream for use in seeking, playing.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
int ast_applystream(struct ast_channel *chan, struct ast_filestream *s)
Applies a open stream to a channel.
int ast_playstream(struct ast_filestream *s)
Play a open stream on a channel.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
Application convenience functions, designed to give consistent look and feel to Asterisk apps.
#define AST_APP_ARG(name)
Define an application argument.
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_app_parse_options(const struct ast_app_option *options, struct ast_flags *flags, char **args, char *optstr)
Parses a string containing application options and sets flags/arguments.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Asterisk locking-related definitions:
#define ast_mutex_unlock(a)
#define ast_mutex_lock(a)
Asterisk module definitions.
#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)
@ AST_MODULE_SUPPORT_CORE
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Core PBX routines and definitions.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
#define ast_custom_function_register(acf)
Register a custom function.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
int ast_sched_wait(struct ast_sched_context *con) attribute_warn_unused_result
Determines number of seconds until the next outstanding event to take place.
Generic Speech Recognition API.
int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf)
Signal to the engine that DTMF was received.
int ast_speech_grammar_deactivate(struct ast_speech *speech, const char *grammar_name)
Deactivate a grammar on a speech structure.
int ast_speech_grammar_unload(struct ast_speech *speech, const char *grammar_name)
Unload a grammar.
void ast_speech_start(struct ast_speech *speech)
Indicate to the speech engine that audio is now going to start being written.
int ast_speech_write(struct ast_speech *speech, void *data, int len)
Write audio to the speech engine.
int ast_speech_change(struct ast_speech *speech, const char *name, const char *value)
Change an engine specific attribute.
struct ast_speech * ast_speech_new(const char *engine_name, const struct ast_format_cap *formats)
Create a new speech structure.
int ast_speech_destroy(struct ast_speech *speech)
Destroy a speech structure.
int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type)
Change the type of results we want.
int ast_speech_grammar_load(struct ast_speech *speech, const char *grammar_name, const char *grammar)
Load a grammar on a speech structure (not globally)
int ast_speech_grammar_activate(struct ast_speech *speech, const char *grammar_name)
Activate a grammar on a speech structure.
int ast_speech_get_setting(struct ast_speech *speech, const char *name, char *buf, size_t len)
Get an engine specific attribute.
int ast_speech_change_state(struct ast_speech *speech, int state)
Change state of a speech structure.
@ AST_SPEECH_STATE_NOT_READY
@ AST_SPEECH_RESULTS_TYPE_NBEST
@ AST_SPEECH_RESULTS_TYPE_NORMAL
struct ast_speech_result * ast_speech_results_get(struct ast_speech *speech)
Get speech recognition results.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
Main Channel structure associated with a channel.
Data structure associated with a custom dialplan function.
Structure for a data store type.
Structure for a data store object.
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Structure used to handle boolean flags.
Data structure associated with a single frame of data.
struct ast_frame_subclass subclass
union ast_frame::@226 data
enum ast_frame_type frametype
struct ast_format * format
struct ast_speech_result * results
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_test_flag(p, flag)
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
#define ast_clear_flag(p, flag)