Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
Enumerations | Functions | Variables
app_speech_utils.c File Reference

Speech Recognition Utility Applications. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "asterisk/lock.h"
#include "asterisk/app.h"
#include "asterisk/speech.h"

Go to the source code of this file.

Enumerations

enum  { SB_OPT_NOANSWER = (1 << 0) }
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static void destroy_callback (void *data)
 Helper function used by datastores to destroy the speech structure upon hangup. More...
 
static struct ast_speech_resultfind_result (struct ast_speech_result *results, char *result_num)
 
static struct ast_speechfind_speech (struct ast_channel *chan)
 Helper function used to find the speech structure attached to a channel. More...
 
static int load_module (void)
 
static int speech_activate (struct ast_channel *chan, const char *data)
 SpeechActivateGrammar(Grammar Name) Dialplan Application. More...
 
static int speech_background (struct ast_channel *chan, const char *data)
 SpeechBackground(Sound File,Timeout) Dialplan Application. More...
 
static int speech_create (struct ast_channel *chan, const char *data)
 SpeechCreate() Dialplan Application. More...
 
static int speech_datastore_destroy (struct ast_channel *chan)
 
static int speech_deactivate (struct ast_channel *chan, const char *data)
 SpeechDeactivateGrammar(Grammar Name) Dialplan Application. More...
 
static int speech_destroy (struct ast_channel *chan, const char *data)
 SpeechDestroy() Dialplan Application. More...
 
static int speech_engine_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 SPEECH_ENGINE() Dialplan Get Function. More...
 
static int speech_engine_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 SPEECH_ENGINE() Dialplan Set Function. More...
 
static int speech_grammar (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 SPEECH_GRAMMAR() Dialplan Function. More...
 
static int speech_load (struct ast_channel *chan, const char *vdata)
 SpeechLoadGrammar(Grammar Name,Path) Dialplan Application. More...
 
static int speech_processing_sound (struct ast_channel *chan, const char *data)
 SpeechProcessingSound(Sound File) Dialplan Application. More...
 
static int speech_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 SPEECH() Dialplan Function. More...
 
static int speech_results_type_write (struct ast_channel *chan, const char *cmd, char *data, const char *value)
 SPEECH_RESULTS_TYPE() Dialplan Function. More...
 
static int speech_score (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 SPEECH_SCORE() Dialplan Function. More...
 
static int speech_start (struct ast_channel *chan, const char *data)
 SpeechStart() Dialplan Application. More...
 
static int speech_streamfile (struct ast_channel *chan, const char *filename, const char *preflang)
 Helper function used by speech_background to playback a soundfile. More...
 
static int speech_text (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 SPEECH_TEXT() Dialplan Function. More...
 
static int speech_unload (struct ast_channel *chan, const char *data)
 SpeechUnloadGrammar(Grammar Name) Dialplan Application. More...
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Dialplan Speech Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_speech", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static const struct ast_app_option speech_background_options [128] = { [ 'n' ] = { .flag = SB_OPT_NOANSWER }, }
 
static const struct ast_datastore_info speech_datastore
 Static structure for datastore information. More...
 
static struct ast_custom_function speech_engine_function
 
static struct ast_custom_function speech_function
 
static struct ast_custom_function speech_grammar_function
 
static struct ast_custom_function speech_results_type_function
 
static struct ast_custom_function speech_score_function
 
static struct ast_custom_function speech_text_function
 

Detailed Description

Speech Recognition Utility Applications.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file app_speech_utils.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
SB_OPT_NOANSWER 

Definition at line 691 of file app_speech_utils.c.

691  {
692  SB_OPT_NOANSWER = (1 << 0),
693 };

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 1007 of file app_speech_utils.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 1007 of file app_speech_utils.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 1007 of file app_speech_utils.c.

◆ destroy_callback()

static void destroy_callback ( void *  data)
static

Helper function used by datastores to destroy the speech structure upon hangup.

Definition at line 261 of file app_speech_utils.c.

References ast_speech_destroy(), and NULL.

262 {
263  struct ast_speech *speech = (struct ast_speech*)data;
264 
265  if (speech == NULL) {
266  return;
267  }
268 
269  /* Deallocate now */
270  ast_speech_destroy(speech);
271 
272  return;
273 }
int ast_speech_destroy(struct ast_speech *speech)
Destroy a speech structure.
Definition: res_speech.c:239
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96

◆ find_result()

static struct ast_speech_result* find_result ( struct ast_speech_result results,
char *  result_num 
)
static

Definition at line 332 of file app_speech_utils.c.

References AST_LIST_NEXT, ast_speech_result::nbest_num, NULL, result, and tmp().

Referenced by speech_grammar(), speech_score(), and speech_text().

333 {
334  struct ast_speech_result *result = results;
335  char *tmp = NULL;
336  int nbest_num = 0, wanted_num = 0, i = 0;
337 
338  if (!result) {
339  return NULL;
340  }
341 
342  if ((tmp = strchr(result_num, '/'))) {
343  *tmp++ = '\0';
344  nbest_num = atoi(result_num);
345  wanted_num = atoi(tmp);
346  } else {
347  wanted_num = atoi(result_num);
348  }
349 
350  do {
351  if (result->nbest_num != nbest_num)
352  continue;
353  if (i == wanted_num)
354  break;
355  i++;
356  } while ((result = AST_LIST_NEXT(result, list)));
357 
358  return result;
359 }
static int tmp()
Definition: bt_open.c:389
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
#define NULL
Definition: resample.c:96
static PGresult * result
Definition: cel_pgsql.c:88

◆ find_speech()

static struct ast_speech* find_speech ( struct ast_channel chan)
static

Helper function used to find the speech structure attached to a channel.

Definition at line 282 of file app_speech_utils.c.

References ast_channel_datastore_find(), ast_channel_lock, ast_channel_unlock, ast_datastore::data, and NULL.

Referenced by speech_activate(), speech_background(), speech_deactivate(), speech_engine_read(), speech_engine_write(), speech_grammar(), speech_load(), speech_processing_sound(), speech_read(), speech_results_type_write(), speech_score(), speech_start(), speech_text(), and speech_unload().

283 {
284  struct ast_speech *speech = NULL;
285  struct ast_datastore *datastore = NULL;
286 
287  if (!chan) {
288  return NULL;
289  }
290 
291  ast_channel_lock(chan);
292  datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
293  ast_channel_unlock(chan);
294  if (datastore == NULL) {
295  return NULL;
296  }
297  speech = datastore->data;
298 
299  return speech;
300 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
Structure for a data store object.
Definition: datastore.h:68
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.
Definition: channel.c:2379
#define NULL
Definition: resample.c:96
#define ast_channel_unlock(chan)
Definition: channel.h:2838
static const struct ast_datastore_info speech_datastore
Static structure for datastore information.
void * data
Definition: datastore.h:70

◆ load_module()

static int load_module ( void  )
static

Definition at line 979 of file app_speech_utils.c.

References ast_custom_function_register, AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ast_register_application_xml, ASTERISK_GPL_KEY, speech_activate(), speech_background(), speech_create(), speech_deactivate(), speech_destroy(), speech_load(), speech_processing_sound(), speech_start(), speech_unload(), and unload_module().

980 {
981  int res = 0;
982 
983  res = ast_register_application_xml("SpeechCreate", speech_create);
984  res |= ast_register_application_xml("SpeechLoadGrammar", speech_load);
985  res |= ast_register_application_xml("SpeechUnloadGrammar", speech_unload);
986  res |= ast_register_application_xml("SpeechActivateGrammar", speech_activate);
987  res |= ast_register_application_xml("SpeechDeactivateGrammar", speech_deactivate);
988  res |= ast_register_application_xml("SpeechStart", speech_start);
989  res |= ast_register_application_xml("SpeechBackground", speech_background);
990  res |= ast_register_application_xml("SpeechDestroy", speech_destroy);
991  res |= ast_register_application_xml("SpeechProcessingSound", speech_processing_sound);
998 
999  return res;
1000 }
static int speech_create(struct ast_channel *chan, const char *data)
SpeechCreate() Dialplan Application.
static int speech_unload(struct ast_channel *chan, const char *data)
SpeechUnloadGrammar(Grammar Name) Dialplan Application.
static struct ast_custom_function speech_engine_function
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_load(struct ast_channel *chan, const char *vdata)
SpeechLoadGrammar(Grammar Name,Path) Dialplan Application.
static int speech_destroy(struct ast_channel *chan, const char *data)
SpeechDestroy() Dialplan Application.
static struct ast_custom_function speech_function
static int speech_deactivate(struct ast_channel *chan, const char *data)
SpeechDeactivateGrammar(Grammar Name) Dialplan Application.
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_processing_sound(struct ast_channel *chan, const char *data)
SpeechProcessingSound(Sound File) Dialplan Application.
static struct ast_custom_function speech_score_function
static struct ast_custom_function speech_text_function
#define ast_custom_function_register(acf)
Register a custom function.
Definition: pbx.h:1504
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:626

◆ speech_activate()

static int speech_activate ( struct ast_channel chan,
const char *  data 
)
static

SpeechActivateGrammar(Grammar Name) Dialplan Application.

Definition at line 628 of file app_speech_utils.c.

References ast_speech_grammar_activate(), find_speech(), and NULL.

Referenced by load_module().

629 {
630  int res = 0;
631  struct ast_speech *speech = find_speech(chan);
632 
633  if (speech == NULL)
634  return -1;
635 
636  /* Activate the grammar on the speech object */
637  res = ast_speech_grammar_activate(speech, data);
638 
639  return res;
640 }
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
int ast_speech_grammar_activate(struct ast_speech *speech, const char *grammar_name)
Activate a grammar on a speech structure.
Definition: res_speech.c:65

◆ speech_background()

static int speech_background ( struct ast_channel chan,
const char *  data 
)
static

SpeechBackground(Sound File,Timeout) Dialplan Application.

Definition at line 700 of file app_speech_utils.c.

References ao2_bump, ao2_cleanup, args, ast_answer(), AST_APP_ARG, ast_app_parse_options(), ast_calloc, ast_channel_language(), ast_channel_lock, ast_channel_pbx(), ast_channel_readformat(), ast_channel_sched(), ast_channel_stream(), ast_channel_streamid(), ast_channel_timingfunc(), ast_channel_unlock, ast_clear_flag, AST_CONTROL_HANGUP, AST_DECLARE_APP_ARGS, AST_FRAME_CONTROL, AST_FRAME_DTMF, AST_FRAME_VOICE, ast_frfree, AST_MAX_EXTENSION, ast_mutex_lock, ast_mutex_unlock, ast_read(), ast_sched_runq(), ast_sched_wait(), ast_set_read_format(), ast_speech_change_state(), ast_speech_dtmf(), AST_SPEECH_QUIET, ast_speech_results_get(), ast_speech_start(), AST_SPEECH_STATE_DONE, AST_SPEECH_STATE_NOT_READY, AST_SPEECH_STATE_READY, AST_SPEECH_STATE_WAIT, ast_speech_write(), AST_STANDARD_APP_ARGS, AST_STATE_UP, ast_stopstream(), ast_strdup, ast_strdupa, ast_strlen_zero, ast_test_flag, ast_tvdiff_ms(), ast_tvnow(), ast_waitfor(), ast_frame::data, ast_frame::datalen, done, ast_pbx::dtimeoutms, find_speech(), ast_speech::format, ast_frame::frametype, ast_speech_result::grammar, ast_frame_subclass::integer, ast_speech::lock, NULL, parse(), pbx_builtin_getvar_helper(), ast_speech::processing_sound, ast_frame::ptr, RAII_VAR, ast_speech::results, SB_OPT_NOANSWER, ast_speech_result::score, speech_background_options, speech_datastore_destroy(), speech_streamfile(), ast_speech::state, strsep(), ast_frame::subclass, ast_speech_result::text, timeout, and tmp().

Referenced by load_module().

701 {
702  unsigned int timeout = 0;
703  int res = 0, done = 0, started = 0, quieted = 0, max_dtmf_len = 0;
704  struct ast_speech *speech = find_speech(chan);
705  struct ast_frame *f = NULL;
706  RAII_VAR(struct ast_format *, oldreadformat, NULL, ao2_cleanup);
707  char dtmf[AST_MAX_EXTENSION] = "";
708  struct timeval start = { 0, 0 }, current;
709  char *parse, *filename_tmp = NULL, *filename = NULL, tmp[2] = "", dtmf_terminator = '#';
710  const char *tmp2 = NULL;
711  struct ast_flags options = { 0 };
713  AST_APP_ARG(soundfile);
714  AST_APP_ARG(timeout);
715  AST_APP_ARG(options);
716  );
717 
718  parse = ast_strdupa(data);
719  AST_STANDARD_APP_ARGS(args, parse);
720 
721  if (speech == NULL)
722  return -1;
723 
724  if (!ast_strlen_zero(args.options)) {
725  char *options_buf = ast_strdupa(args.options);
726  ast_app_parse_options(speech_background_options, &options, NULL, options_buf);
727  }
728 
729  /* If channel is not already answered, then answer it */
730  if (ast_channel_state(chan) != AST_STATE_UP && !ast_test_flag(&options, SB_OPT_NOANSWER)
731  && ast_answer(chan)) {
732  return -1;
733  }
734 
735  /* Record old read format */
736  oldreadformat = ao2_bump(ast_channel_readformat(chan));
737 
738  /* Change read format to be signed linear */
739  if (ast_set_read_format(chan, speech->format))
740  return -1;
741 
742  if (!ast_strlen_zero(args.soundfile)) {
743  /* Yay sound file */
744  filename_tmp = ast_strdupa(args.soundfile);
745  if (!ast_strlen_zero(args.timeout)) {
746  if ((timeout = atof(args.timeout) * 1000.0) == 0)
747  timeout = -1;
748  } else
749  timeout = 0;
750  }
751 
752  /* See if the maximum DTMF length variable is set... we use a variable in case they want to carry it through their entire dialplan */
753  ast_channel_lock(chan);
754  if ((tmp2 = pbx_builtin_getvar_helper(chan, "SPEECH_DTMF_MAXLEN")) && !ast_strlen_zero(tmp2)) {
755  max_dtmf_len = atoi(tmp2);
756  }
757 
758  /* See if a terminator is specified */
759  if ((tmp2 = pbx_builtin_getvar_helper(chan, "SPEECH_DTMF_TERMINATOR"))) {
760  if (ast_strlen_zero(tmp2))
761  dtmf_terminator = '\0';
762  else
763  dtmf_terminator = tmp2[0];
764  }
765  ast_channel_unlock(chan);
766 
767  /* Before we go into waiting for stuff... make sure the structure is ready, if not - start it again */
768  if (speech->state == AST_SPEECH_STATE_NOT_READY || speech->state == AST_SPEECH_STATE_DONE) {
770  ast_speech_start(speech);
771  }
772 
773  /* Ensure no streams are currently running */
774  ast_stopstream(chan);
775 
776  /* Okay it's streaming so go into a loop grabbing frames! */
777  while (done == 0) {
778  /* If the filename is null and stream is not running, start up a new sound file */
779  if (!quieted && (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) && (filename = strsep(&filename_tmp, "&"))) {
780  /* Discard old stream information */
781  ast_stopstream(chan);
782  /* Start new stream */
783  speech_streamfile(chan, filename, ast_channel_language(chan));
784  }
785 
786  /* Run scheduled stuff */
788 
789  /* Yay scheduling */
790  res = ast_sched_wait(ast_channel_sched(chan));
791  if (res < 0)
792  res = 1000;
793 
794  /* If there is a frame waiting, get it - if not - oh well */
795  if (ast_waitfor(chan, res) > 0) {
796  f = ast_read(chan);
797  if (f == NULL) {
798  /* The channel has hung up most likely */
799  done = 3;
800  break;
801  }
802  }
803 
804  /* Do timeout check (shared between audio/dtmf) */
805  if ((!quieted || strlen(dtmf)) && started == 1) {
806  current = ast_tvnow();
807  if ((ast_tvdiff_ms(current, start)) >= timeout) {
808  done = 1;
809  if (f)
810  ast_frfree(f);
811  break;
812  }
813  }
814 
815  /* Do checks on speech structure to see if it's changed */
816  ast_mutex_lock(&speech->lock);
817  if (ast_test_flag(speech, AST_SPEECH_QUIET)) {
818  if (ast_channel_stream(chan))
819  ast_stopstream(chan);
821  quieted = 1;
822  }
823  /* Check state so we can see what to do */
824  switch (speech->state) {
826  /* If audio playback has stopped do a check for timeout purposes */
827  if (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL)
828  ast_stopstream(chan);
829  if (!quieted && ast_channel_stream(chan) == NULL && timeout && started == 0 && !filename_tmp) {
830  if (timeout == -1) {
831  done = 1;
832  if (f)
833  ast_frfree(f);
834  break;
835  }
836  start = ast_tvnow();
837  started = 1;
838  }
839  /* Write audio frame out to speech engine if no DTMF has been received */
840  if (!strlen(dtmf) && f != NULL && f->frametype == AST_FRAME_VOICE) {
841  ast_speech_write(speech, f->data.ptr, f->datalen);
842  }
843  break;
845  /* Cue up waiting sound if not already playing */
846  if (!strlen(dtmf)) {
847  if (ast_channel_stream(chan) == NULL) {
848  if (speech->processing_sound != NULL) {
849  if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) {
851  }
852  }
853  } else if (ast_channel_streamid(chan) == -1 && ast_channel_timingfunc(chan) == NULL) {
854  ast_stopstream(chan);
855  if (speech->processing_sound != NULL) {
856  if (strlen(speech->processing_sound) > 0 && strcasecmp(speech->processing_sound, "none")) {
858  }
859  }
860  }
861  }
862  break;
864  /* Now that we are done... let's switch back to not ready state */
866  if (!strlen(dtmf)) {
867  /* Copy to speech structure the results, if available */
868  speech->results = ast_speech_results_get(speech);
869  /* Break out of our background too */
870  done = 1;
871  /* Stop audio playback */
872  if (ast_channel_stream(chan) != NULL) {
873  ast_stopstream(chan);
874  }
875  }
876  break;
877  default:
878  break;
879  }
880  ast_mutex_unlock(&speech->lock);
881 
882  /* Deal with other frame types */
883  if (f != NULL) {
884  /* Free the frame we received */
885  switch (f->frametype) {
886  case AST_FRAME_DTMF:
887  if (dtmf_terminator != '\0' && f->subclass.integer == dtmf_terminator) {
888  done = 1;
889  } else {
890  quieted = 1;
891  if (ast_channel_stream(chan) != NULL) {
892  ast_stopstream(chan);
893  }
894  if (!started) {
895  /* Change timeout to be 5 seconds for DTMF input */
896  timeout = (ast_channel_pbx(chan) && ast_channel_pbx(chan)->dtimeoutms) ? ast_channel_pbx(chan)->dtimeoutms : 5000;
897  started = 1;
898  }
899  start = ast_tvnow();
900  snprintf(tmp, sizeof(tmp), "%c", f->subclass.integer);
901  strncat(dtmf, tmp, sizeof(dtmf) - strlen(dtmf) - 1);
902  /* If the maximum length of the DTMF has been reached, stop now */
903  if (max_dtmf_len && strlen(dtmf) == max_dtmf_len)
904  done = 1;
905  }
906  break;
907  case AST_FRAME_CONTROL:
908  switch (f->subclass.integer) {
909  case AST_CONTROL_HANGUP:
910  /* Since they hung up we should destroy the speech structure */
911  done = 3;
912  default:
913  break;
914  }
915  default:
916  break;
917  }
918  ast_frfree(f);
919  f = NULL;
920  }
921  }
922 
923  if (!ast_strlen_zero(dtmf)) {
924  /* We sort of make a results entry */
925  speech->results = ast_calloc(1, sizeof(*speech->results));
926  if (speech->results != NULL) {
927  ast_speech_dtmf(speech, dtmf);
928  speech->results->score = 1000;
929  speech->results->text = ast_strdup(dtmf);
930  speech->results->grammar = ast_strdup("dtmf");
931  }
933  }
934 
935  /* See if it was because they hung up */
936  if (done == 3) {
938  } else {
939  /* Channel is okay so restore read format */
940  ast_set_read_format(chan, oldreadformat);
941  }
942 
943  return 0;
944 }
int state
Definition: speech.h:59
#define ast_channel_lock(chan)
Definition: channel.h:2837
void ast_speech_start(struct ast_speech *speech)
Indicate to the speech engine that audio is now going to start being written.
Definition: res_speech.c:121
int ast_sched_runq(struct ast_sched_context *con)
Runs the queue.
Definition: sched.c:755
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
static int timeout
Definition: cdr_mysql.c:86
static int tmp()
Definition: bt_open.c:389
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Definition: channel.c:4251
ast_channel_state
ast_channel states
Definition: channelstate.h:35
struct ast_speech_result * ast_speech_results_get(struct ast_speech *speech)
Get speech recognition results.
Definition: res_speech.c:89
static int speech_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)
Helper function used by speech_background to playback a soundfile.
Definition of a media format.
Definition: format.c:43
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define ast_mutex_lock(a)
Definition: lock.h:187
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:98
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const char * args
#define NULL
Definition: resample.c:96
#define AST_FRAME_DTMF
char * grammar
Definition: speech.h:116
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
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
int done
Definition: test_amihooks.c:48
#define ao2_bump(obj)
Definition: astobj2.h:491
union ast_frame::@255 data
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition: channel.c:5724
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:851
int ast_speech_change_state(struct ast_speech *speech, int state)
Change state of a speech structure.
Definition: res_speech.c:266
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)
#define AST_MAX_EXTENSION
Definition: channel.h:135
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
struct ast_speech_result * results
Definition: speech.h:65
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.
Definition: main/app.c:2829
struct ast_sched_context * ast_channel_sched(const struct ast_channel *chan)
int ast_channel_streamid(const struct ast_channel *chan)
#define ast_strlen_zero(a)
Definition: muted.c:73
#define ast_channel_unlock(chan)
Definition: channel.h:2838
static void parse(struct mgcp_request *req)
Definition: chan_mgcp.c:1872
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
struct ast_format * format
Definition: speech.h:61
struct ast_filestream * ast_channel_stream(const struct ast_channel *chan)
Structure used to handle boolean flags.
Definition: utils.h:199
#define ast_clear_flag(p, flag)
Definition: utils.h:77
static int speech_datastore_destroy(struct ast_channel *chan)
ast_mutex_t lock
Definition: speech.h:53
char * strsep(char **str, const char *delims)
int ast_waitfor(struct ast_channel *chan, int ms)
Wait for input on a channel.
Definition: channel.c:3137
int dtimeoutms
Definition: pbx.h:212
int ast_speech_dtmf(struct ast_speech *speech, const char *dtmf)
Signal to the engine that DTMF was received.
Definition: res_speech.c:153
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
static const struct ast_app_option speech_background_options[128]
#define ast_frfree(fr)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2780
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.
Definition: sched.c:431
Data structure associated with a single frame of data.
const char * ast_channel_language(const struct ast_channel *chan)
char * processing_sound
Definition: speech.h:57
enum ast_frame_type frametype
static struct test_options options
int ast_speech_write(struct ast_speech *speech, void *data, int len)
Write audio to the speech engine.
Definition: res_speech.c:143
ast_timing_func_t ast_channel_timingfunc(const struct ast_channel *chan)
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
int ast_stopstream(struct ast_channel *c)
Stops a stream.
Definition: file.c:187
#define ast_mutex_unlock(a)
Definition: lock.h:188
#define AST_APP_ARG(name)
Define an application argument.

◆ speech_create()

static int speech_create ( struct ast_channel chan,
const char *  data 
)
static

SpeechCreate() Dialplan Application.

Definition at line 543 of file app_speech_utils.c.

References ast_channel_datastore_add(), ast_channel_lock, ast_channel_nativeformats(), ast_channel_unlock, ast_datastore_alloc, ast_speech_destroy(), ast_speech_new(), ast_datastore::data, NULL, and pbx_builtin_setvar_helper().

Referenced by load_module().

544 {
545  struct ast_speech *speech = NULL;
546  struct ast_datastore *datastore = NULL;
547 
548  /* Request a speech object */
550  if (speech == NULL) {
551  /* Not available */
552  pbx_builtin_setvar_helper(chan, "ERROR", "1");
553  return 0;
554  }
555 
557  if (datastore == NULL) {
558  ast_speech_destroy(speech);
559  pbx_builtin_setvar_helper(chan, "ERROR", "1");
560  return 0;
561  }
562  pbx_builtin_setvar_helper(chan, "ERROR", NULL);
563  datastore->data = speech;
564  ast_channel_lock(chan);
565  ast_channel_datastore_add(chan, datastore);
566  ast_channel_unlock(chan);
567 
568  return 0;
569 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
int ast_speech_destroy(struct ast_speech *speech)
Destroy a speech structure.
Definition: res_speech.c:239
Structure for a data store object.
Definition: datastore.h:68
#define NULL
Definition: resample.c:96
#define ast_channel_unlock(chan)
Definition: channel.h:2838
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.
void * data
Definition: datastore.h:70
struct ast_speech * ast_speech_new(const char *engine_name, const struct ast_format_cap *formats)
Create a new speech structure.
Definition: res_speech.c:180
#define ast_datastore_alloc(info, uid)
Definition: datastore.h:89
int ast_channel_datastore_add(struct ast_channel *chan, struct ast_datastore *datastore)
Add a datastore to a channel.
Definition: channel.c:2365

◆ speech_datastore_destroy()

static int speech_datastore_destroy ( struct ast_channel chan)
static

Definition at line 311 of file app_speech_utils.c.

References ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_unlock, ast_datastore_free(), and NULL.

Referenced by speech_background(), and speech_destroy().

312 {
313  struct ast_datastore *datastore;
314  int res;
315 
316  ast_channel_lock(chan);
317  datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
318  if (datastore) {
319  ast_channel_datastore_remove(chan, datastore);
320  }
321  ast_channel_unlock(chan);
322  if (datastore) {
323  ast_datastore_free(datastore);
324  res = 0;
325  } else {
326  res = -1;
327  }
328  return res;
329 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
Structure for a data store object.
Definition: datastore.h:68
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.
Definition: channel.c:2379
#define NULL
Definition: resample.c:96
int ast_datastore_free(struct ast_datastore *datastore)
Free a data store object.
Definition: datastore.c:68
#define ast_channel_unlock(chan)
Definition: channel.h:2838
static const struct ast_datastore_info speech_datastore
Static structure for datastore information.
int ast_channel_datastore_remove(struct ast_channel *chan, struct ast_datastore *datastore)
Remove a datastore from a channel.
Definition: channel.c:2374

◆ speech_deactivate()

static int speech_deactivate ( struct ast_channel chan,
const char *  data 
)
static

SpeechDeactivateGrammar(Grammar Name) Dialplan Application.

Definition at line 613 of file app_speech_utils.c.

References ast_speech_grammar_deactivate(), find_speech(), and NULL.

Referenced by load_module().

614 {
615  int res = 0;
616  struct ast_speech *speech = find_speech(chan);
617 
618  if (speech == NULL)
619  return -1;
620 
621  /* Deactivate the grammar on the speech object */
622  res = ast_speech_grammar_deactivate(speech, data);
623 
624  return res;
625 }
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
int ast_speech_grammar_deactivate(struct ast_speech *speech, const char *grammar_name)
Deactivate a grammar on a speech structure.
Definition: res_speech.c:71
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.

◆ speech_destroy()

static int speech_destroy ( struct ast_channel chan,
const char *  data 
)
static

SpeechDestroy() Dialplan Application.

Definition at line 948 of file app_speech_utils.c.

References speech_datastore_destroy().

Referenced by load_module().

949 {
950  if (!chan) {
951  return -1;
952  }
953  return speech_datastore_destroy(chan);
954 }
static int speech_datastore_destroy(struct ast_channel *chan)

◆ speech_engine_read()

static int speech_engine_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

SPEECH_ENGINE() Dialplan Get Function.

Definition at line 453 of file app_speech_utils.c.

References ast_speech_get_setting(), and find_speech().

454 {
455  struct ast_speech *speech = find_speech(chan);
456 
457  if (!data || !speech) {
458  return -1;
459  }
460 
461  return ast_speech_get_setting(speech, data, buf, len);
462 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void * data
Definition: speech.h:63
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_speech_get_setting(struct ast_speech *speech, const char *name, char *buf, size_t len)
Get an engine specific attribute.
Definition: res_speech.c:174

◆ speech_engine_write()

static int speech_engine_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

SPEECH_ENGINE() Dialplan Set Function.

Definition at line 439 of file app_speech_utils.c.

References ast_speech_change(), find_speech(), and NULL.

440 {
441  struct ast_speech *speech = find_speech(chan);
442 
443  if (data == NULL || speech == NULL) {
444  return -1;
445  }
446 
447  ast_speech_change(speech, data, value);
448 
449  return 0;
450 }
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
int ast_speech_change(struct ast_speech *speech, const char *name, const char *value)
Change an engine specific attribute.
Definition: res_speech.c:168

◆ speech_grammar()

static int speech_grammar ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

SPEECH_GRAMMAR() Dialplan Function.

Definition at line 413 of file app_speech_utils.c.

References ast_copy_string(), find_result(), find_speech(), ast_speech_result::grammar, NULL, result, and ast_speech::results.

415 {
416  struct ast_speech_result *result = NULL;
417  struct ast_speech *speech = find_speech(chan);
418 
419  if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) {
420  return -1;
421  }
422 
423  if (result->grammar != NULL) {
424  ast_copy_string(buf, result->grammar, len);
425  } else {
426  buf[0] = '\0';
427  }
428 
429  return 0;
430 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
char * grammar
Definition: speech.h:116
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
struct ast_speech_result * results
Definition: speech.h:65
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)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static PGresult * result
Definition: cel_pgsql.c:88

◆ speech_load()

static int speech_load ( struct ast_channel chan,
const char *  vdata 
)
static

SpeechLoadGrammar(Grammar Name,Path) Dialplan Application.

Definition at line 572 of file app_speech_utils.c.

References args, AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_speech_grammar_load(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_speech::data, find_speech(), and NULL.

Referenced by load_module().

573 {
574  int res = 0;
575  struct ast_speech *speech = find_speech(chan);
576  char *data;
578  AST_APP_ARG(grammar);
579  AST_APP_ARG(path);
580  );
581 
582  data = ast_strdupa(vdata);
584 
585  if (speech == NULL)
586  return -1;
587 
588  if (args.argc != 2)
589  return -1;
590 
591  /* Load the grammar locally on the object */
592  res = ast_speech_grammar_load(speech, args.grammar, args.path);
593 
594  return res;
595 }
#define AST_STANDARD_APP_ARGS(args, parse)
Performs the &#39;standard&#39; argument separation process for an application.
void * data
Definition: speech.h:63
const char * args
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
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)
Definition: res_speech.c:77
#define AST_DECLARE_APP_ARGS(name, arglist)
Declare a structure to hold an application&#39;s arguments.
#define AST_APP_ARG(name)
Define an application argument.

◆ speech_processing_sound()

static int speech_processing_sound ( struct ast_channel chan,
const char *  data 
)
static

SpeechProcessingSound(Sound File) Dialplan Application.

Definition at line 657 of file app_speech_utils.c.

References ast_free, ast_strdup, find_speech(), NULL, and ast_speech::processing_sound.

Referenced by load_module().

658 {
659  int res = 0;
660  struct ast_speech *speech = find_speech(chan);
661 
662  if (speech == NULL)
663  return -1;
664 
665  if (speech->processing_sound != NULL) {
666  ast_free(speech->processing_sound);
667  speech->processing_sound = NULL;
668  }
669 
670  speech->processing_sound = ast_strdup(data);
671 
672  return res;
673 }
void * data
Definition: speech.h:63
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
#define ast_free(a)
Definition: astmm.h:182
char * processing_sound
Definition: speech.h:57

◆ speech_read()

static int speech_read ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

SPEECH() Dialplan Function.

Definition at line 493 of file app_speech_utils.c.

References ast_copy_string(), AST_LIST_NEXT, AST_SPEECH_SPOKE, ast_test_flag, find_speech(), NULL, result, ast_speech::results, and tmp().

495 {
496  int results = 0;
497  struct ast_speech_result *result = NULL;
498  struct ast_speech *speech = find_speech(chan);
499  char tmp[128] = "";
500 
501  /* Now go for the various options */
502  if (!strcasecmp(data, "status")) {
503  if (speech != NULL)
504  ast_copy_string(buf, "1", len);
505  else
506  ast_copy_string(buf, "0", len);
507  return 0;
508  }
509 
510  /* Make sure we have a speech structure for everything else */
511  if (speech == NULL) {
512  return -1;
513  }
514 
515  /* Check to see if they are checking for silence */
516  if (!strcasecmp(data, "spoke")) {
517  if (ast_test_flag(speech, AST_SPEECH_SPOKE))
518  ast_copy_string(buf, "1", len);
519  else
520  ast_copy_string(buf, "0", len);
521  } else if (!strcasecmp(data, "results")) {
522  /* Count number of results */
523  for (result = speech->results; result; result = AST_LIST_NEXT(result, list))
524  results++;
525  snprintf(tmp, sizeof(tmp), "%d", results);
526  ast_copy_string(buf, tmp, len);
527  } else {
528  buf[0] = '\0';
529  }
530 
531  return 0;
532 }
#define ast_test_flag(p, flag)
Definition: utils.h:63
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int tmp()
Definition: bt_open.c:389
#define AST_LIST_NEXT(elm, field)
Returns the next entry in the list after the given entry.
Definition: linkedlists.h:438
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
struct ast_speech_result * results
Definition: speech.h:65
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static PGresult * result
Definition: cel_pgsql.c:88

◆ speech_results_type_write()

static int speech_results_type_write ( struct ast_channel chan,
const char *  cmd,
char *  data,
const char *  value 
)
static

SPEECH_RESULTS_TYPE() Dialplan Function.

Definition at line 471 of file app_speech_utils.c.

References ast_speech_change_results_type(), AST_SPEECH_RESULTS_TYPE_NBEST, AST_SPEECH_RESULTS_TYPE_NORMAL, find_speech(), and NULL.

472 {
473  struct ast_speech *speech = find_speech(chan);
474 
475  if (data == NULL || speech == NULL)
476  return -1;
477 
478  if (!strcasecmp(value, "normal"))
480  else if (!strcasecmp(value, "nbest"))
482 
483  return 0;
484 }
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_results_type results_type)
Change the type of results we want.
Definition: res_speech.c:283
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.

◆ speech_score()

static int speech_score ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

SPEECH_SCORE() Dialplan Function.

Definition at line 362 of file app_speech_utils.c.

References ast_copy_string(), find_result(), find_speech(), NULL, result, ast_speech::results, ast_speech_result::score, and tmp().

364 {
365  struct ast_speech_result *result = NULL;
366  struct ast_speech *speech = find_speech(chan);
367  char tmp[128] = "";
368 
369  if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) {
370  return -1;
371  }
372 
373  snprintf(tmp, sizeof(tmp), "%d", result->score);
374 
375  ast_copy_string(buf, tmp, len);
376 
377  return 0;
378 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static int tmp()
Definition: bt_open.c:389
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
struct ast_speech_result * results
Definition: speech.h:65
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)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static PGresult * result
Definition: cel_pgsql.c:88

◆ speech_start()

static int speech_start ( struct ast_channel chan,
const char *  data 
)
static

SpeechStart() Dialplan Application.

Definition at line 643 of file app_speech_utils.c.

References ast_speech_start(), find_speech(), and NULL.

Referenced by load_module().

644 {
645  int res = 0;
646  struct ast_speech *speech = find_speech(chan);
647 
648  if (speech == NULL)
649  return -1;
650 
651  ast_speech_start(speech);
652 
653  return res;
654 }
void ast_speech_start(struct ast_speech *speech)
Indicate to the speech engine that audio is now going to start being written.
Definition: res_speech.c:121
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.

◆ speech_streamfile()

static int speech_streamfile ( struct ast_channel chan,
const char *  filename,
const char *  preflang 
)
static

Helper function used by speech_background to playback a soundfile.

Definition at line 676 of file app_speech_utils.c.

References ast_applystream(), ast_openstream(), ast_playstream(), and NULL.

Referenced by speech_background().

677 {
678  struct ast_filestream *fs = NULL;
679 
680  if (!(fs = ast_openstream(chan, filename, preflang)))
681  return -1;
682 
683  if (ast_applystream(chan, fs))
684  return -1;
685 
686  ast_playstream(fs);
687 
688  return 0;
689 }
#define NULL
Definition: resample.c:96
int ast_playstream(struct ast_filestream *s)
Play a open stream on a channel.
Definition: file.c:1026
int ast_applystream(struct ast_channel *chan, struct ast_filestream *s)
Applys a open stream to a channel.
Definition: file.c:1020
char * filename
Definition: mod_format.h:107
This structure is allocated by file.c in one chunk, together with buf_size and desc_size bytes of mem...
Definition: mod_format.h:101
struct ast_filestream * ast_openstream(struct ast_channel *chan, const char *filename, const char *preflang)
Opens stream for use in seeking, playing.
Definition: file.c:755

◆ speech_text()

static int speech_text ( struct ast_channel chan,
const char *  cmd,
char *  data,
char *  buf,
size_t  len 
)
static

SPEECH_TEXT() Dialplan Function.

Definition at line 387 of file app_speech_utils.c.

References ast_copy_string(), find_result(), find_speech(), NULL, result, ast_speech::results, and ast_speech_result::text.

389 {
390  struct ast_speech_result *result = NULL;
391  struct ast_speech *speech = find_speech(chan);
392 
393  if (data == NULL || speech == NULL || !(result = find_result(speech->results, data))) {
394  return -1;
395  }
396 
397  if (result->text != NULL) {
398  ast_copy_string(buf, result->text, len);
399  } else {
400  buf[0] = '\0';
401  }
402 
403  return 0;
404 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
struct ast_speech_result * results
Definition: speech.h:65
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)
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static PGresult * result
Definition: cel_pgsql.c:88

◆ speech_unload()

static int speech_unload ( struct ast_channel chan,
const char *  data 
)
static

SpeechUnloadGrammar(Grammar Name) Dialplan Application.

Definition at line 598 of file app_speech_utils.c.

References ast_speech_grammar_unload(), find_speech(), and NULL.

Referenced by load_module().

599 {
600  int res = 0;
601  struct ast_speech *speech = find_speech(chan);
602 
603  if (speech == NULL)
604  return -1;
605 
606  /* Unload the grammar */
607  res = ast_speech_grammar_unload(speech, data);
608 
609  return res;
610 }
void * data
Definition: speech.h:63
#define NULL
Definition: resample.c:96
static struct ast_speech * find_speech(struct ast_channel *chan)
Helper function used to find the speech structure attached to a channel.
int ast_speech_grammar_unload(struct ast_speech *speech, const char *grammar_name)
Unload a grammar.
Definition: res_speech.c:83

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 956 of file app_speech_utils.c.

References ast_custom_function_unregister(), and ast_unregister_application().

Referenced by load_module().

957 {
958  int res = 0;
959 
960  res = ast_unregister_application("SpeechCreate");
961  res |= ast_unregister_application("SpeechLoadGrammar");
962  res |= ast_unregister_application("SpeechUnloadGrammar");
963  res |= ast_unregister_application("SpeechActivateGrammar");
964  res |= ast_unregister_application("SpeechDeactivateGrammar");
965  res |= ast_unregister_application("SpeechStart");
966  res |= ast_unregister_application("SpeechBackground");
967  res |= ast_unregister_application("SpeechDestroy");
968  res |= ast_unregister_application("SpeechProcessingSound");
975 
976  return res;
977 }
static struct ast_custom_function speech_engine_function
static struct ast_custom_function speech_grammar_function
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392
int ast_custom_function_unregister(struct ast_custom_function *acf)
Unregister a custom function.
static struct ast_custom_function speech_function
static struct ast_custom_function speech_results_type_function
static struct ast_custom_function speech_score_function
static struct ast_custom_function speech_text_function

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Dialplan Speech Applications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .requires = "res_speech", }
static

Definition at line 1007 of file app_speech_utils.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 1007 of file app_speech_utils.c.

◆ speech_background_options

const struct ast_app_option speech_background_options[128] = { [ 'n' ] = { .flag = SB_OPT_NOANSWER }, }
static

Definition at line 697 of file app_speech_utils.c.

Referenced by speech_background().

◆ speech_datastore

const struct ast_datastore_info speech_datastore
static
Initial value:
= {
.type = "speech",
.destroy = destroy_callback
}
static void destroy_callback(void *data)
Helper function used by datastores to destroy the speech structure upon hangup.

Static structure for datastore information.

Definition at line 276 of file app_speech_utils.c.

◆ speech_engine_function

struct ast_custom_function speech_engine_function
static
Initial value:
= {
.name = "SPEECH_ENGINE",
}
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_engine_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
SPEECH_ENGINE() Dialplan Set Function.

Definition at line 464 of file app_speech_utils.c.

◆ speech_function

struct ast_custom_function speech_function
static
Initial value:
= {
.name = "SPEECH",
.read = speech_read,
.write = NULL,
}
#define NULL
Definition: resample.c:96
static int speech_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH() Dialplan Function.

Definition at line 534 of file app_speech_utils.c.

◆ speech_grammar_function

struct ast_custom_function speech_grammar_function
static
Initial value:
= {
.name = "SPEECH_GRAMMAR",
.read = speech_grammar,
.write = NULL,
}
#define NULL
Definition: resample.c:96
static int speech_grammar(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_GRAMMAR() Dialplan Function.

Definition at line 432 of file app_speech_utils.c.

◆ speech_results_type_function

struct ast_custom_function speech_results_type_function
static
Initial value:
= {
.name = "SPEECH_RESULTS_TYPE",
.read = NULL,
}
#define NULL
Definition: resample.c:96
static int speech_results_type_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
SPEECH_RESULTS_TYPE() Dialplan Function.

Definition at line 486 of file app_speech_utils.c.

◆ speech_score_function

struct ast_custom_function speech_score_function
static
Initial value:
= {
.name = "SPEECH_SCORE",
.read = speech_score,
.write = NULL,
}
#define NULL
Definition: resample.c:96
static int speech_score(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_SCORE() Dialplan Function.

Definition at line 380 of file app_speech_utils.c.

◆ speech_text_function

struct ast_custom_function speech_text_function
static
Initial value:
= {
.name = "SPEECH_TEXT",
.read = speech_text,
.write = NULL,
}
static int speech_text(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
SPEECH_TEXT() Dialplan Function.
#define NULL
Definition: resample.c:96

Definition at line 406 of file app_speech_utils.c.