265 if (speech ==
NULL) {
294 if (datastore ==
NULL) {
297 speech = datastore->
data;
336 int nbest_num = 0, wanted_num = 0, i = 0;
342 if ((tmp = strchr(result_num,
'/'))) {
344 nbest_num = atoi(result_num);
345 wanted_num = atoi(tmp);
347 wanted_num = atoi(result_num);
373 snprintf(tmp,
sizeof(tmp),
"%d", result->
score);
381 .
name =
"SPEECH_SCORE",
407 .
name =
"SPEECH_TEXT",
433 .
name =
"SPEECH_GRAMMAR",
443 if (data ==
NULL || speech ==
NULL) {
457 if (!data || !speech) {
465 .
name =
"SPEECH_ENGINE",
478 if (!strcasecmp(value,
"normal"))
480 else if (!strcasecmp(value,
"nbest"))
487 .
name =
"SPEECH_RESULTS_TYPE",
502 if (!strcasecmp(data,
"status")) {
511 if (speech ==
NULL) {
516 if (!strcasecmp(data,
"spoke")) {
521 }
else if (!strcasecmp(data,
"results")) {
525 snprintf(tmp,
sizeof(tmp),
"%d", results);
550 if (speech ==
NULL) {
557 if (datastore ==
NULL) {
563 datastore->
data = speech;
703 int res = 0,
done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
708 struct timeval start = { 0, 0 }, current;
709 char *
parse, *filename_tmp =
NULL, *filename =
NULL,
tmp[2] =
"", dtmf_terminator =
'#';
710 const char *tmp2 =
NULL;
746 if ((timeout = atof(
args.timeout) * 1000.0) == 0)
755 max_dtmf_len = atoi(tmp2);
761 dtmf_terminator =
'\0';
763 dtmf_terminator = tmp2[0];
805 if ((!quieted || strlen(dtmf)) && started == 1) {
824 switch (speech->
state) {
887 if (dtmf_terminator !=
'\0' && f->
subclass.
integer == dtmf_terminator) {
901 strncat(dtmf, tmp,
sizeof(dtmf) - strlen(dtmf) - 1);
903 if (max_dtmf_len && strlen(dtmf) == max_dtmf_len)
1006 .requires =
"res_speech",
#define ast_channel_lock(chan)
Main Channel structure associated with a channel.
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
static int speech_create(struct ast_channel *chan, const char *data)
SpeechCreate() Dialplan Application.
Generic Speech Recognition API.
static int speech_unload(struct ast_channel *chan, const char *data)
SpeechUnloadGrammar(Grammar Name) Dialplan Application.
int ast_speech_destroy(struct ast_speech *speech)
Destroy a speech structure.
void ast_speech_start(struct ast_speech *speech)
Indicate to the speech engine that audio is now going to start being written.
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
#define ast_test_flag(p, flag)
static struct ast_custom_function speech_engine_function
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the 'standard' argument separation process for an application.
static int speech_background(struct ast_channel *chan, const char *data)
SpeechBackground(Sound File,Timeout) Dialplan Application.
static struct ast_custom_function speech_grammar_function
static int speech_text(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_TEXT() Dialplan Function.
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
static int load_module(void)
Structure for a data store type.
ast_channel_state
ast_channel states
struct ast_speech_result * ast_speech_results_get(struct ast_speech *speech)
Get speech recognition results.
static int speech_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)
Helper function used by speech_background to playback a soundfile.
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
#define ast_mutex_lock(a)
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
#define ast_strdup(str)
A wrapper for strdup()
Structure for a data store object.
static int speech_engine_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_ENGINE() Dialplan Get Function.
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.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
static int speech_load(struct ast_channel *chan, const char *vdata)
SpeechLoadGrammar(Grammar Name,Path) Dialplan Application.
int ast_unregister_application(const char *app)
Unregister an application.
static int speech_destroy(struct ast_channel *chan, const char *data)
SpeechDestroy() 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.
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
const char * pbx_builtin_getvar_helper(struct ast_channel *chan, const char *name)
Return a pointer to the value of the corresponding channel variable.
struct ast_frame_subclass subclass
int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type)
Change the type of results we want.
#define ast_strlen_zero(foo)
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
#define AST_APP_OPTIONS(holder, options...)
Declares an array of options for an application.
int ast_speech_grammar_deactivate(struct ast_speech *speech, const char *grammar_name)
Deactivate a grammar on a speech structure.
int ast_playstream(struct ast_filestream *s)
Play a open stream on a channel.
General Asterisk PBX channel definitions.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
int ast_speech_change_state(struct ast_speech *speech, int state)
Change state of a speech structure.
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
struct ast_pbx * ast_channel_pbx(const struct ast_channel *chan)
Data structure associated with a custom dialplan function.
#define AST_MAX_EXTENSION
static struct ast_custom_function speech_function
static int speech_deactivate(struct ast_channel *chan, const char *data)
SpeechDeactivateGrammar(Grammar Name) Dialplan Application.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_speech_grammar_unload(struct ast_speech *speech, const char *grammar_name)
Unload a grammar.
struct ast_speech_result * results
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.
static struct ast_custom_function speech_results_type_function
Core PBX routines and definitions.
static int speech_activate(struct ast_channel *chan, const char *data)
SpeechActivateGrammar(Grammar Name) Dialplan Application.
static int speech_engine_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
SPEECH_ENGINE() Dialplan Set Function.
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
static int speech_start(struct ast_channel *chan, const char *data)
SpeechStart() Dialplan Application.
int ast_applystream(struct ast_channel *chan, struct ast_filestream *s)
Applys a open stream to a channel.
static void destroy_callback(void *data)
Helper function used by datastores to destroy the speech structure upon hangup.
int ast_channel_streamid(const struct ast_channel *chan)
int ast_speech_grammar_activate(struct ast_speech *speech, const char *grammar_name)
Activate a grammar on a speech structure.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
static struct ast_speech_result * find_result(struct ast_speech_result *results, char *result_num)
static int speech_processing_sound(struct ast_channel *chan, const char *data)
SpeechProcessingSound(Sound File) Dialplan Application.
#define ast_channel_unlock(chan)
static void parse(struct mgcp_request *req)
#define ast_calloc(num, len)
A wrapper for calloc()
struct ast_format * format
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
Structure used to handle boolean flags.
#define ast_clear_flag(p, flag)
static int speech_datastore_destroy(struct ast_channel *chan)
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
struct ast_format_cap * ast_channel_nativeformats(const struct ast_channel *chan)
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...
static const struct ast_datastore_info speech_datastore
Static structure for datastore information.
char * strsep(char **str, const char *delims)
static struct ast_custom_function speech_score_function
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
static struct ast_custom_function speech_text_function
int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf)
Signal to the engine that DTMF was received.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
static const struct ast_app_option speech_background_options[128]
struct ast_speech * ast_speech_new(const char *engine_name, const struct ast_format_cap *formats)
Create a new speech structure.
int ast_answer(struct ast_channel *chan)
Answer a channel.
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.
Data structure associated with a single frame of data.
const char * ast_channel_language(const struct ast_channel *chan)
static int speech_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH() Dialplan Function.
#define ast_datastore_alloc(info, uid)
union ast_frame::@263 data
enum ast_frame_type frametype
#define AST_APP_OPTION(option, flagno)
Declares an application option that does not accept an argument.
int ast_speech_write(struct ast_speech *speech, void *data, int len)
Write audio to the speech engine.
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)
#define ASTERISK_GPL_KEY
The text the key() function should return.
int ast_speech_get_setting(struct ast_speech *speech, const char *name, char *buf, size_t len)
Get an engine specific attribute.
Asterisk module definitions.
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
int ast_speech_change(struct ast_speech *speech, const char *name, const char *value)
Change an engine specific attribute.
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application's arguments.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
#define ast_custom_function_register(acf)
Register a custom function.
static int speech_grammar(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_GRAMMAR() Dialplan Function.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
static int speech_score(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_SCORE() Dialplan Function.
static int unload_module(void)
struct ast_filestream * ast_openstream(struct ast_channel *chan, const char *filename, const char *preflang)
Opens stream for use in seeking, playing.
#define ast_mutex_unlock(a)
#define AST_APP_ARG(name)
Define an application argument.