Main Page | Modules | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

ASR/TTS Functions
[Core Library]


Functions

switch_status_t switch_core_speech_open (_In_ switch_speech_handle_t *sh, const char *module_name, const char *voice_name, _In_ unsigned int rate, _In_ unsigned int interval, switch_speech_flag_t *flags, _In_ switch_memory_pool_t *pool)
 Open a speech handle.
switch_status_t switch_core_speech_feed_tts (switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
 Feed text to the TTS module.
void switch_core_speech_flush_tts (switch_speech_handle_t *sh)
 Flush TTS audio on a given handle.
void switch_core_speech_text_param_tts (switch_speech_handle_t *sh, char *param, const char *val)
 Set a text parameter on a TTS handle.
void switch_core_speech_numeric_param_tts (switch_speech_handle_t *sh, char *param, int val)
 Set a numeric parameter on a TTS handle.
void switch_core_speech_float_param_tts (switch_speech_handle_t *sh, char *param, double val)
 Set a float parameter on a TTS handle.
switch_status_t switch_core_speech_read_tts (switch_speech_handle_t *sh, void *data, switch_size_t *datalen, uint32_t *rate, switch_speech_flag_t *flags)
 Read rendered audio from the TTS module.
switch_status_t switch_core_speech_close (switch_speech_handle_t *sh, switch_speech_flag_t *flags)
 Close an open speech handle.
switch_status_t switch_core_asr_open (switch_asr_handle_t *ah, const char *module_name, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags, switch_memory_pool_t *pool)
 Open an asr handle.
switch_status_t switch_core_asr_close (switch_asr_handle_t *ah, switch_asr_flag_t *flags)
 Close an asr handle.
switch_status_t switch_core_asr_feed (switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags)
 Feed audio data to an asr handle.
switch_status_t switch_core_asr_check_results (switch_asr_handle_t *ah, switch_asr_flag_t *flags)
 Check an asr handle for results.
switch_status_t switch_core_asr_get_results (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags)
 Get results from an asr handle.
switch_status_t switch_core_asr_load_grammar (switch_asr_handle_t *ah, const char *grammar, const char *path)
 Load a grammar to an asr handle.
switch_status_t switch_core_asr_unload_grammar (switch_asr_handle_t *ah, const char *grammar)
 Unload a grammar from an asr handle.
switch_status_t switch_core_asr_pause (switch_asr_handle_t *ah)
 Pause detection on an asr handle.
switch_status_t switch_core_asr_resume (switch_asr_handle_t *ah)
 Resume detection on an asr handle.


Function Documentation

switch_status_t switch_core_asr_check_results switch_asr_handle_t ah,
switch_asr_flag_t flags
 

Check an asr handle for results.

Parameters:
ah the handle to check
flags flags to influence behaviour
Returns:
SWITCH_STATUS_SUCCESS
00146 {
00147         switch_assert(ah != NULL);
00148 
00149         return ah->asr_interface->asr_check_results(ah, flags);
00150 }

switch_status_t switch_core_asr_close switch_asr_handle_t ah,
switch_asr_flag_t flags
 

Close an asr handle.

Parameters:
ah the handle to close
flags flags to influence behaviour
Returns:
SWITCH_STATUS_SUCCESS
00124 {
00125         switch_status_t status;
00126 
00127         switch_assert(ah != NULL);
00128 
00129         status = ah->asr_interface->asr_close(ah, flags);
00130 
00131         if (switch_test_flag(ah, SWITCH_ASR_FLAG_FREE_POOL)) {
00132                 switch_core_destroy_memory_pool(&ah->memory_pool);
00133         }
00134 
00135         return status;
00136 }

switch_status_t switch_core_asr_feed switch_asr_handle_t ah,
void *  data,
unsigned int  len,
switch_asr_flag_t flags
 

Feed audio data to an asr handle.

Parameters:
ah the handle to feed data to
data a pointer to the data
len the size in bytes of the data
flags flags to influence behaviour
Returns:
SWITCH_STATUS_SUCCESS
00139 {
00140         switch_assert(ah != NULL);
00141 
00142         return ah->asr_interface->asr_feed(ah, data, len, flags);
00143 }

switch_status_t switch_core_asr_get_results switch_asr_handle_t ah,
char **  xmlstr,
switch_asr_flag_t flags
 

Get results from an asr handle.

Parameters:
ah the handle to get results from
xmlstr a pointer to dynamically allocate an xml result string to
flags flags to influence behaviour
Returns:
SWITCH_STATUS_SUCCESS
00153 {
00154         switch_assert(ah != NULL);
00155 
00156         return ah->asr_interface->asr_get_results(ah, xmlstr, flags);
00157 }

switch_status_t switch_core_asr_load_grammar switch_asr_handle_t ah,
const char *  grammar,
const char *  path
 

Load a grammar to an asr handle.

Parameters:
ah the handle to load to
grammar the name of the grammar
path the path to the grammaar file
Returns:
SWITCH_STATUS_SUCCESS
00082 {
00083         char *epath = NULL;
00084         switch_status_t status;
00085 
00086         switch_assert(ah != NULL);
00087 
00088         if (!switch_is_file_path(path)) {
00089                 epath = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, path);
00090                 path = epath;
00091         }
00092 
00093         status = ah->asr_interface->asr_load_grammar(ah, grammar, path);
00094         switch_safe_free(epath);
00095 
00096         return status;
00097 }

Here is the call graph for this function:

switch_status_t switch_core_asr_open switch_asr_handle_t ah,
const char *  module_name,
const char *  codec,
int  rate,
const char *  dest,
switch_asr_flag_t flags,
switch_memory_pool_t pool
 

Open an asr handle.

Parameters:
ah the asr handle to open
module_name the name of the asr module
codec the preferred codec
rate the preferred rate
dest the destination address
flags flags to influence behaviour
pool the pool to use (NULL for new pool)
Returns:
SWITCH_STATUS_SUCCESS if the asr handle was opened
00041 {
00042         switch_status_t status;
00043         char buf[256] = "";
00044         char *param = NULL;
00045 
00046         if (strchr(module_name, '@')) {
00047                 switch_set_string(buf, module_name);
00048                 if ((param = strchr(buf, '@'))) {
00049                         *param++ = '\0';
00050                         module_name = buf;
00051                 }
00052         }
00053 
00054         switch_assert(ah != NULL);
00055 
00056         if ((ah->asr_interface = switch_loadable_module_get_asr_interface(module_name)) == 0) {
00057                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "invalid asr module [%s]!\n", module_name);
00058                 return SWITCH_STATUS_GENERR;
00059         }
00060 
00061         ah->flags = *flags;
00062 
00063         if (pool) {
00064                 ah->memory_pool = pool;
00065         } else {
00066                 if ((status = switch_core_new_memory_pool(&ah->memory_pool)) != SWITCH_STATUS_SUCCESS) {
00067                         return status;
00068                 }
00069                 switch_set_flag(ah, SWITCH_ASR_FLAG_FREE_POOL);
00070         }
00071 
00072         if (param) {
00073                 ah->param = switch_core_strdup(ah->memory_pool, param);
00074         }
00075         ah->rate = rate;
00076         ah->name = switch_core_strdup(ah->memory_pool, module_name);
00077 
00078         return ah->asr_interface->asr_open(ah, codec, rate, dest, flags);
00079 }

Here is the call graph for this function:

switch_status_t switch_core_asr_pause switch_asr_handle_t ah  ) 
 

Pause detection on an asr handle.

Parameters:
ah the handle to pause
Returns:
SWITCH_STATUS_SUCCESS
00110 {
00111         switch_assert(ah != NULL);
00112 
00113         return ah->asr_interface->asr_pause(ah);
00114 }

switch_status_t switch_core_asr_resume switch_asr_handle_t ah  ) 
 

Resume detection on an asr handle.

Parameters:
ah the handle to resume
Returns:
SWITCH_STATUS_SUCCESS
00117 {
00118         switch_assert(ah != NULL);
00119 
00120         return ah->asr_interface->asr_resume(ah);
00121 }

switch_status_t switch_core_asr_unload_grammar switch_asr_handle_t ah,
const char *  grammar
 

Unload a grammar from an asr handle.

Parameters:
ah the handle to unload the grammar from
grammar the grammar to unload
Returns:
SWITCH_STATUS_SUCCESS
00100 {
00101         switch_status_t status;
00102 
00103         switch_assert(ah != NULL);
00104         status = ah->asr_interface->asr_unload_grammar(ah, grammar);
00105 
00106         return status;
00107 }

switch_status_t switch_core_speech_close switch_speech_handle_t sh,
switch_speech_flag_t flags
 

Close an open speech handle.

Parameters:
sh the speech handle to close
flags flags in/out for fine tuning
Returns:
SWITCH_STATUS_SUCCESS if the file handle was closed
00139 {
00140         switch_status_t status = sh->speech_interface->speech_close(sh, flags);
00141 
00142         if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL)) {
00143                 switch_core_destroy_memory_pool(&sh->memory_pool);
00144         }
00145 
00146         return status;
00147 }

switch_status_t switch_core_speech_feed_tts switch_speech_handle_t sh,
char *  text,
switch_speech_flag_t flags
 

Feed text to the TTS module.

Parameters:
sh the speech handle to feed
text the buffer to write
flags flags in/out for fine tuning
Returns:
SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
00087 {
00088         switch_assert(sh != NULL);
00089 
00090         return sh->speech_interface->speech_feed_tts(sh, text, flags);
00091 }

void switch_core_speech_float_param_tts switch_speech_handle_t sh,
char *  param,
double  val
 

Set a float parameter on a TTS handle.

Parameters:
sh the speech handle
param the parameter
val the value
00121 {
00122         switch_assert(sh != NULL);
00123 
00124         if (sh->speech_interface->speech_float_param_tts) {
00125                 sh->speech_interface->speech_float_param_tts(sh, param, val);
00126         }
00127 }

void switch_core_speech_flush_tts switch_speech_handle_t sh  ) 
 

Flush TTS audio on a given handle.

Parameters:
sh the speech handle
00094 {
00095         switch_assert(sh != NULL);
00096 
00097         if (sh->speech_interface->speech_flush_tts) {
00098                 sh->speech_interface->speech_flush_tts(sh);
00099         }
00100 }

void switch_core_speech_numeric_param_tts switch_speech_handle_t sh,
char *  param,
int  val
 

Set a numeric parameter on a TTS handle.

Parameters:
sh the speech handle
param the parameter
val the value
00112 {
00113         switch_assert(sh != NULL);
00114 
00115         if (sh->speech_interface->speech_numeric_param_tts) {
00116                 sh->speech_interface->speech_numeric_param_tts(sh, param, val);
00117         }
00118 }

switch_status_t switch_core_speech_open _In_ switch_speech_handle_t sh,
const char *  module_name,
const char *  voice_name,
_In_ unsigned int  rate,
_In_ unsigned int  interval,
switch_speech_flag_t flags,
_In_ switch_memory_pool_t pool
 

Open a speech handle.

Parameters:
sh a speech handle to use
module_name the speech module to use
voice_name the desired voice name
rate the sampling rate
interval the sampling interval
flags tts flags
pool the pool to use (NULL for new pool)
Returns:
SWITCH_STATUS_SUCCESS if the handle is opened

switch_status_t switch_core_speech_read_tts switch_speech_handle_t sh,
void *  data,
switch_size_t datalen,
uint32_t *  rate,
switch_speech_flag_t flags
 

Read rendered audio from the TTS module.

Parameters:
sh the speech handle to read
data the buffer to read to
datalen the max size / written size of the data
rate the rate of the read audio
flags flags in/out for fine tuning
Returns:
SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
00131 {
00132         switch_assert(sh != NULL);
00133 
00134         return sh->speech_interface->speech_read_tts(sh, data, datalen, rate, flags);
00135 }

void switch_core_speech_text_param_tts switch_speech_handle_t sh,
char *  param,
const char *  val
 

Set a text parameter on a TTS handle.

Parameters:
sh the speech handle
param the parameter
val the value
00103 {
00104         switch_assert(sh != NULL);
00105 
00106         if (sh->speech_interface->speech_text_param_tts) {
00107                 sh->speech_interface->speech_text_param_tts(sh, param, val);
00108         }
00109 }


Generated on Fri Oct 10 11:24:33 2008 for FreeSWITCH by  doxygen 1.3.9.1