Collaboration diagram for ASR/TTS Functions:
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_opt_ 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, 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_feed_dtmf (switch_asr_handle_t *ah, const switch_dtmf_t *dtmf, switch_asr_flag_t *flags) |
| Feed DTMF 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 *name) |
| Load a grammar to an asr handle. | |
| switch_status_t | switch_core_asr_unload_grammar (switch_asr_handle_t *ah, const char *name) |
| Unload a grammar from an asr handle. | |
| switch_status_t | switch_core_asr_enable_grammar (switch_asr_handle_t *ah, const char *name) |
| Enable a grammar from an asr handle. | |
| switch_status_t | switch_core_asr_disable_grammar (switch_asr_handle_t *ah, const char *name) |
| Disable a grammar from an asr handle. | |
| switch_status_t | switch_core_asr_disable_all_grammars (switch_asr_handle_t *ah) |
| Disable all grammars 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. | |
| switch_status_t | switch_core_asr_start_input_timers (switch_asr_handle_t *ah) |
| Start input timers on an asr handle. | |
| void | switch_core_asr_text_param (switch_asr_handle_t *ah, char *param, const char *val) |
| Set a text parameter on an asr handle. | |
| void | switch_core_asr_numeric_param (switch_asr_handle_t *ah, char *param, int val) |
| Set a numeric parameter on an asr handle. | |
| void | switch_core_asr_float_param (switch_asr_handle_t *ah, char *param, double val) |
| Set a float parameter on 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.
| ah | the handle to check | |
| flags | flags to influence behaviour |
Definition at line 255 of file switch_core_asr.c.
References switch_assert.
Referenced by speech_callback(), and speech_thread().
00256 { 00257 switch_assert(ah != NULL); 00258 00259 return ah->asr_interface->asr_check_results(ah, flags); 00260 }
| switch_status_t switch_core_asr_close | ( | switch_asr_handle_t * | ah, | |
| switch_asr_flag_t * | flags | |||
| ) |
Close an asr handle.
| ah | the handle to close | |
| flags | flags to influence behaviour |
Definition at line 217 of file switch_core_asr.c.
References SWITCH_ASR_FLAG_CLOSED, SWITCH_ASR_FLAG_FREE_POOL, switch_assert, switch_core_destroy_memory_pool, switch_set_flag, switch_test_flag, and UNPROTECT_INTERFACE.
Referenced by speech_callback(), and switch_ivr_detect_speech().
00218 { 00219 switch_status_t status; 00220 00221 switch_assert(ah != NULL); 00222 00223 status = ah->asr_interface->asr_close(ah, flags); 00224 switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED); 00225 00226 UNPROTECT_INTERFACE(ah->asr_interface); 00227 00228 if (switch_test_flag(ah, SWITCH_ASR_FLAG_FREE_POOL)) { 00229 switch_core_destroy_memory_pool(&ah->memory_pool); 00230 } 00231 00232 return status; 00233 }
| switch_status_t switch_core_asr_disable_all_grammars | ( | switch_asr_handle_t * | ah | ) |
Disable all grammars from an asr handle.
| ah | the handle to disable the grammars from |
Definition at line 190 of file switch_core_asr.c.
References switch_assert, and SWITCH_STATUS_FALSE.
Referenced by switch_ivr_detect_speech_disable_all_grammars().
00191 { 00192 switch_status_t status = SWITCH_STATUS_FALSE; 00193 00194 switch_assert(ah != NULL); 00195 00196 if (ah->asr_interface->asr_disable_all_grammars) { 00197 status = ah->asr_interface->asr_disable_all_grammars(ah); 00198 } 00199 00200 return status; 00201 }
| switch_status_t switch_core_asr_disable_grammar | ( | switch_asr_handle_t * | ah, | |
| const char * | name | |||
| ) |
Disable a grammar from an asr handle.
| ah | the handle to disable the grammar from | |
| name | the name of the grammar to disable |
Definition at line 177 of file switch_core_asr.c.
References switch_assert, and SWITCH_STATUS_FALSE.
Referenced by switch_ivr_detect_speech_disable_grammar().
00178 { 00179 switch_status_t status = SWITCH_STATUS_FALSE; 00180 00181 switch_assert(ah != NULL); 00182 00183 if (ah->asr_interface->asr_disable_grammar) { 00184 status = ah->asr_interface->asr_disable_grammar(ah, name); 00185 } 00186 00187 return status; 00188 }
| switch_status_t switch_core_asr_enable_grammar | ( | switch_asr_handle_t * | ah, | |
| const char * | name | |||
| ) |
Enable a grammar from an asr handle.
| ah | the handle to enable the grammar from | |
| name | the name of the grammar to enable |
Definition at line 164 of file switch_core_asr.c.
References switch_assert, and SWITCH_STATUS_FALSE.
Referenced by switch_ivr_detect_speech_enable_grammar().
00165 { 00166 switch_status_t status = SWITCH_STATUS_FALSE; 00167 00168 switch_assert(ah != NULL); 00169 00170 if (ah->asr_interface->asr_enable_grammar) { 00171 status = ah->asr_interface->asr_enable_grammar(ah, name); 00172 } 00173 00174 return status; 00175 }
| 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.
| 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 |
Definition at line 235 of file switch_core_asr.c.
References switch_assert.
Referenced by speech_callback().
00236 { 00237 switch_assert(ah != NULL); 00238 00239 return ah->asr_interface->asr_feed(ah, data, len, flags); 00240 }
| switch_status_t switch_core_asr_feed_dtmf | ( | switch_asr_handle_t * | ah, | |
| const switch_dtmf_t * | dtmf, | |||
| switch_asr_flag_t * | flags | |||
| ) |
Feed DTMF to an asr handle.
| ah | the handle to feed data to | |
| dtmf | a string of DTMF digits | |
| flags | flags to influence behaviour |
Definition at line 242 of file switch_core_asr.c.
References switch_assert, and SWITCH_STATUS_SUCCESS.
Referenced by speech_on_dtmf().
00243 { 00244 switch_status_t status = SWITCH_STATUS_SUCCESS; 00245 00246 switch_assert(ah != NULL); 00247 00248 if (ah->asr_interface->asr_feed_dtmf) { 00249 status = ah->asr_interface->asr_feed_dtmf(ah, dtmf, flags); 00250 } 00251 00252 return status; 00253 }
| void switch_core_asr_float_param | ( | switch_asr_handle_t * | ah, | |
| char * | param, | |||
| double | val | |||
| ) |
Set a float parameter on an asr handle.
| sh | the asr handle | |
| param | the parameter | |
| val | the value |
Definition at line 300 of file switch_core_asr.c.
References switch_assert.
00301 { 00302 switch_assert(ah != NULL); 00303 00304 if (ah->asr_interface->asr_float_param) { 00305 ah->asr_interface->asr_float_param(ah, param, val); 00306 } 00307 }
| 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.
| ah | the handle to get results from | |
| xmlstr | a pointer to dynamically allocate an xml result string to | |
| flags | flags to influence behaviour |
Definition at line 262 of file switch_core_asr.c.
References switch_assert.
Referenced by speech_thread().
00263 { 00264 switch_assert(ah != NULL); 00265 00266 return ah->asr_interface->asr_get_results(ah, xmlstr, flags); 00267 }
| switch_status_t switch_core_asr_load_grammar | ( | switch_asr_handle_t * | ah, | |
| const char * | grammar, | |||
| const char * | name | |||
| ) |
Load a grammar to an asr handle.
| ah | the handle to load to | |
| grammar | the grammar text, file path, or URI | |
| name | the grammar name |
Definition at line 91 of file switch_core_asr.c.
References switch_assert, switch_core_asr_text_param(), switch_find_end_paren(), switch_safe_free, switch_separate_string(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.
Referenced by switch_ivr_detect_speech(), and switch_ivr_detect_speech_load_grammar().
00092 { 00093 switch_status_t status = SWITCH_STATUS_SUCCESS; 00094 char *param_string = NULL; 00095 char *data = NULL; 00096 char *lgrammar = NULL; 00097 00098 switch_assert(ah != NULL); 00099 00100 if (zstr(grammar)) { 00101 status = SWITCH_STATUS_FALSE; 00102 goto done; 00103 } 00104 00105 /* Set ASR parameters from params in the grammar string 00106 * Params are defined as follows {name1=val1,name2=val2,name3=val3}grammar text 00107 */ 00108 lgrammar = strdup(grammar); 00109 data = lgrammar; 00110 00111 /* strip leading spaces */ 00112 while (data && *data == ' ') { 00113 data++; 00114 } 00115 if (zstr(data)) { 00116 status = SWITCH_STATUS_FALSE; 00117 goto done; 00118 } 00119 00120 /* extract params */ 00121 if (*data == '{') { 00122 param_string = data + 1; 00123 data = switch_find_end_paren(data, '{', '}'); 00124 if (zstr(data)) { 00125 status = SWITCH_STATUS_FALSE; 00126 goto done; 00127 } else { 00128 *data = '\0'; 00129 data++; 00130 } 00131 } 00132 00133 /* set ASR params */ 00134 if (!zstr(param_string)) { 00135 char *param[256] = { 0 }; 00136 int i; 00137 int argc = switch_separate_string(param_string, ',', param, (sizeof(param) / sizeof(param[0]))); 00138 for (i = 0; i < argc && param[i]; ++i) { 00139 char *param_pair[2] = { 0 }; 00140 if (switch_separate_string(param[i], '=', param_pair, (sizeof(param_pair) / sizeof(param_pair[0]))) == 2) { 00141 switch_core_asr_text_param(ah, param_pair[0], param_pair[1]); 00142 } 00143 } 00144 } 00145 00146 status = ah->asr_interface->asr_load_grammar(ah, data, name); 00147 00148 done: 00149 00150 switch_safe_free(lgrammar); 00151 return status; 00152 }
| void switch_core_asr_numeric_param | ( | switch_asr_handle_t * | ah, | |
| char * | param, | |||
| int | val | |||
| ) |
Set a numeric parameter on an asr handle.
| sh | the asr handle | |
| param | the parameter | |
| val | the value |
Definition at line 291 of file switch_core_asr.c.
References switch_assert.
00292 { 00293 switch_assert(ah != NULL); 00294 00295 if (ah->asr_interface->asr_numeric_param) { 00296 ah->asr_interface->asr_numeric_param(ah, param, val); 00297 } 00298 }
| 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.
| 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) |
Definition at line 40 of file switch_core_asr.c.
References buf, SWITCH_ASR_FLAG_FREE_POOL, switch_assert, SWITCH_CHANNEL_LOG, switch_core_new_memory_pool, switch_core_strdup, switch_loadable_module_get_asr_interface(), SWITCH_LOG_ERROR, switch_log_printf(), switch_set_flag, switch_set_string, SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, and UNPROTECT_INTERFACE.
Referenced by switch_ivr_detect_speech().
00043 { 00044 switch_status_t status; 00045 char buf[256] = ""; 00046 char *param = NULL; 00047 00048 if (strchr(module_name, ':')) { 00049 switch_set_string(buf, module_name); 00050 if ((param = strchr(buf, ':'))) { 00051 *param++ = '\0'; 00052 module_name = buf; 00053 } 00054 } 00055 00056 switch_assert(ah != NULL); 00057 00058 if ((ah->asr_interface = switch_loadable_module_get_asr_interface(module_name)) == 0) { 00059 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid ASR module [%s]!\n", module_name); 00060 return SWITCH_STATUS_GENERR; 00061 } 00062 00063 ah->flags = *flags; 00064 00065 if (pool) { 00066 ah->memory_pool = pool; 00067 } else { 00068 if ((status = switch_core_new_memory_pool(&ah->memory_pool)) != SWITCH_STATUS_SUCCESS) { 00069 UNPROTECT_INTERFACE(ah->asr_interface); 00070 return status; 00071 } 00072 switch_set_flag(ah, SWITCH_ASR_FLAG_FREE_POOL); 00073 } 00074 00075 if (param) { 00076 ah->param = switch_core_strdup(ah->memory_pool, param); 00077 } 00078 ah->rate = rate; 00079 ah->name = switch_core_strdup(ah->memory_pool, module_name); 00080 00081 status = ah->asr_interface->asr_open(ah, codec, rate, dest, flags); 00082 00083 if (status != SWITCH_STATUS_SUCCESS) { 00084 UNPROTECT_INTERFACE(ah->asr_interface); 00085 } 00086 00087 return status; 00088 00089 }
| switch_status_t switch_core_asr_pause | ( | switch_asr_handle_t * | ah | ) |
Pause detection on an asr handle.
| ah | the handle to pause |
Definition at line 203 of file switch_core_asr.c.
References switch_assert.
Referenced by switch_ivr_pause_detect_speech().
00204 { 00205 switch_assert(ah != NULL); 00206 00207 return ah->asr_interface->asr_pause(ah); 00208 }
| switch_status_t switch_core_asr_resume | ( | switch_asr_handle_t * | ah | ) |
Resume detection on an asr handle.
| ah | the handle to resume |
Definition at line 210 of file switch_core_asr.c.
References switch_assert.
Referenced by switch_ivr_resume_detect_speech().
00211 { 00212 switch_assert(ah != NULL); 00213 00214 return ah->asr_interface->asr_resume(ah); 00215 }
| switch_status_t switch_core_asr_start_input_timers | ( | switch_asr_handle_t * | ah | ) |
Start input timers on an asr handle.
| ah | the handle to start timers on |
Definition at line 269 of file switch_core_asr.c.
References switch_assert, and SWITCH_STATUS_SUCCESS.
Referenced by switch_ivr_detect_speech_start_input_timers().
00270 { 00271 switch_status_t status = SWITCH_STATUS_SUCCESS; 00272 00273 switch_assert(ah != NULL); 00274 00275 if (ah->asr_interface->asr_start_input_timers) { 00276 status = ah->asr_interface->asr_start_input_timers(ah); 00277 } 00278 00279 return status; 00280 }
| void switch_core_asr_text_param | ( | switch_asr_handle_t * | ah, | |
| char * | param, | |||
| const char * | val | |||
| ) |
Set a text parameter on an asr handle.
| sh | the asr handle | |
| param | the parameter | |
| val | the value |
Definition at line 282 of file switch_core_asr.c.
References switch_assert.
Referenced by switch_core_asr_load_grammar(), and switch_ivr_set_param_detect_speech().
00283 { 00284 switch_assert(ah != NULL); 00285 00286 if (ah->asr_interface->asr_text_param) { 00287 ah->asr_interface->asr_text_param(ah, param, val); 00288 } 00289 }
| switch_status_t switch_core_asr_unload_grammar | ( | switch_asr_handle_t * | ah, | |
| const char * | name | |||
| ) |
Unload a grammar from an asr handle.
| ah | the handle to unload the grammar from | |
| name | the name of the grammar to unload |
Definition at line 154 of file switch_core_asr.c.
References switch_assert.
Referenced by switch_ivr_detect_speech_unload_grammar().
00155 { 00156 switch_status_t status; 00157 00158 switch_assert(ah != NULL); 00159 status = ah->asr_interface->asr_unload_grammar(ah, name); 00160 00161 return status; 00162 }
| switch_status_t switch_core_speech_close | ( | switch_speech_handle_t * | sh, | |
| switch_speech_flag_t * | flags | |||
| ) |
Close an open speech handle.
| sh | the speech handle to close | |
| flags | flags in/out for fine tuning |
Definition at line 269 of file switch_core_speech.c.
References switch_buffer_destroy(), switch_clear_flag, switch_core_destroy_memory_pool, switch_resample_destroy(), SWITCH_SPEECH_FLAG_FREE_POOL, SWITCH_SPEECH_FLAG_OPEN, SWITCH_STATUS_FALSE, switch_test_flag, and UNPROTECT_INTERFACE.
Referenced by switch_ivr_clear_speech_cache(), and switch_ivr_speak_text().
00270 { 00271 switch_status_t status = sh->speech_interface->speech_close(sh, flags); 00272 00273 if (!switch_test_flag(sh, SWITCH_SPEECH_FLAG_OPEN)) { 00274 return SWITCH_STATUS_FALSE; 00275 } 00276 00277 if (sh->buffer) { 00278 switch_buffer_destroy(&sh->buffer); 00279 } 00280 00281 switch_resample_destroy(&sh->resampler); 00282 00283 UNPROTECT_INTERFACE(sh->speech_interface); 00284 00285 if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL)) { 00286 switch_core_destroy_memory_pool(&sh->memory_pool); 00287 } 00288 00289 switch_clear_flag(sh, SWITCH_SPEECH_FLAG_OPEN); 00290 00291 return status; 00292 }
| 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.
| sh | the speech handle to feed | |
| text | the buffer to write | |
| flags | flags in/out for fine tuning |
Definition at line 96 of file switch_core_speech.c.
References switch_assert, switch_core_speech_text_param_tts(), switch_find_end_paren(), switch_safe_free, switch_separate_string(), SWITCH_STATUS_FALSE, SWITCH_STATUS_SUCCESS, and zstr.
Referenced by switch_ivr_speak_text_handle().
00097 { 00098 switch_status_t status = SWITCH_STATUS_SUCCESS; 00099 char *param_string = NULL; 00100 char *data = NULL; 00101 char *ltext = NULL; 00102 00103 switch_assert(sh != NULL); 00104 00105 if (zstr(text)) { 00106 status = SWITCH_STATUS_FALSE; 00107 goto done; 00108 } 00109 00110 /* Set TTS parameters from params in the text string 00111 * Params are defined as follows {name1=val1,name2=val2,name3=val3}text to speak 00112 */ 00113 ltext = strdup(text); 00114 data = ltext; 00115 00116 /* strip leading spaces */ 00117 while (data && *data == ' ') { 00118 data++; 00119 } 00120 if (zstr(data)) { 00121 status = SWITCH_STATUS_FALSE; 00122 goto done; 00123 } 00124 00125 /* extract params */ 00126 if (*data == '{') { 00127 param_string = data + 1; 00128 data = switch_find_end_paren(data, '{', '}'); 00129 if (zstr(data)) { 00130 status = SWITCH_STATUS_FALSE; 00131 goto done; 00132 } else { 00133 *data = '\0'; 00134 data++; 00135 } 00136 } 00137 00138 /* set TTS params */ 00139 if (!zstr(param_string)) { 00140 char *param[256] = { 0 }; 00141 int i; 00142 int argc = switch_separate_string(param_string, ',', param, (sizeof(param) / sizeof(param[0]))); 00143 for (i = 0; i < argc && param[i]; ++i) { 00144 char *param_pair[2] = { 0 }; 00145 if (switch_separate_string(param[i], '=', param_pair, (sizeof(param_pair) / sizeof(param_pair[0]))) == 2) { 00146 switch_core_speech_text_param_tts(sh, param_pair[0], param_pair[1]); 00147 } 00148 } 00149 } 00150 00151 status = sh->speech_interface->speech_feed_tts(sh, data, flags); 00152 00153 done: 00154 00155 switch_safe_free(ltext); 00156 return status; 00157 }
| void switch_core_speech_float_param_tts | ( | switch_speech_handle_t * | sh, | |
| char * | param, | |||
| double | val | |||
| ) |
Set a float parameter on a TTS handle.
| sh | the speech handle | |
| param | the parameter | |
| val | the value |
Definition at line 186 of file switch_core_speech.c.
References switch_assert.
00187 { 00188 switch_assert(sh != NULL); 00189 00190 if (sh->speech_interface->speech_float_param_tts) { 00191 sh->speech_interface->speech_float_param_tts(sh, param, val); 00192 } 00193 }
| void switch_core_speech_flush_tts | ( | switch_speech_handle_t * | sh | ) |
Flush TTS audio on a given handle.
| sh | the speech handle |
Definition at line 159 of file switch_core_speech.c.
References switch_assert.
Referenced by switch_ivr_speak_text_handle().
00160 { 00161 switch_assert(sh != NULL); 00162 00163 if (sh->speech_interface->speech_flush_tts) { 00164 sh->speech_interface->speech_flush_tts(sh); 00165 } 00166 }
| void switch_core_speech_numeric_param_tts | ( | switch_speech_handle_t * | sh, | |
| char * | param, | |||
| int | val | |||
| ) |
Set a numeric parameter on a TTS handle.
| sh | the speech handle | |
| param | the parameter | |
| val | the value |
Definition at line 177 of file switch_core_speech.c.
References switch_assert.
00178 { 00179 switch_assert(sh != NULL); 00180 00181 if (sh->speech_interface->speech_numeric_param_tts) { 00182 sh->speech_interface->speech_numeric_param_tts(sh, param, val); 00183 } 00184 }
| 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_opt_ switch_memory_pool_t * | pool | |||
| ) |
Open a speech handle.
| 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) |
Referenced by switch_ivr_speak_text().
| switch_status_t switch_core_speech_read_tts | ( | switch_speech_handle_t * | sh, | |
| void * | data, | |||
| switch_size_t * | datalen, | |||
| switch_speech_flag_t * | flags | |||
| ) |
Read rendered audio from the TTS module.
| 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 |
Definition at line 195 of file switch_core_speech.c.
References switch_assert, switch_buffer_create_dynamic(), switch_buffer_inuse(), switch_buffer_read(), switch_buffer_write(), SWITCH_CHANNEL_LOG, switch_clear_flag, switch_core_alloc, SWITCH_LOG_CRIT, switch_log_printf(), switch_resample_create, switch_resample_process(), SWITCH_RESAMPLE_QUALITY, switch_set_flag, SWITCH_SPEECH_FLAG_DONE, SWITCH_STATUS_BREAK, SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, and switch_test_flag.
Referenced by switch_ivr_speak_text_handle().
00196 { 00197 switch_status_t status; 00198 switch_size_t want, orig_len = *datalen; 00199 00200 switch_assert(sh != NULL); 00201 00202 want = *datalen; 00203 00204 top: 00205 00206 if (sh->buffer && (switch_buffer_inuse(sh->buffer) >= orig_len || switch_test_flag(sh, SWITCH_SPEECH_FLAG_DONE))) { 00207 if ((*datalen = switch_buffer_read(sh->buffer, data, orig_len))) { 00208 return SWITCH_STATUS_SUCCESS; 00209 } 00210 } 00211 00212 if (switch_test_flag(sh, SWITCH_SPEECH_FLAG_DONE)) { 00213 switch_clear_flag(sh, SWITCH_SPEECH_FLAG_DONE); 00214 *datalen = 0; 00215 return SWITCH_STATUS_BREAK; 00216 } 00217 00218 more: 00219 00220 if ((status = sh->speech_interface->speech_read_tts(sh, data, datalen, flags)) != SWITCH_STATUS_SUCCESS) { 00221 switch_set_flag(sh, SWITCH_SPEECH_FLAG_DONE); 00222 goto top; 00223 } 00224 00225 00226 if (sh->native_rate && sh->samplerate && sh->native_rate != sh->samplerate) { 00227 if (!sh->resampler) { 00228 if (switch_resample_create(&sh->resampler, 00229 sh->native_rate, sh->samplerate, (uint32_t) orig_len, SWITCH_RESAMPLE_QUALITY, 1) != SWITCH_STATUS_SUCCESS) { 00230 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n"); 00231 return SWITCH_STATUS_GENERR; 00232 } 00233 } 00234 00235 switch_resample_process(sh->resampler, data, *datalen / 2); 00236 if (sh->resampler->to_len < want / 2 || sh->resampler->to_len > orig_len / 2) { 00237 if (!sh->buffer) { 00238 int factor = sh->resampler->to_len * sh->samplerate / 1000; 00239 switch_buffer_create_dynamic(&sh->buffer, factor, factor, 0); 00240 switch_assert(sh->buffer); 00241 } 00242 if (!sh->dbuf || sh->dbuflen < sh->resampler->to_len * 2) { 00243 sh->dbuflen = sh->resampler->to_len * 2; 00244 sh->dbuf = switch_core_alloc(sh->memory_pool, sh->dbuflen); 00245 } 00246 switch_assert(sh->resampler->to_len <= sh->dbuflen); 00247 00248 memcpy((int16_t *) sh->dbuf, sh->resampler->to, sh->resampler->to_len * 2); 00249 switch_buffer_write(sh->buffer, sh->dbuf, sh->resampler->to_len * 2); 00250 00251 if (switch_buffer_inuse(sh->buffer) < want) { 00252 *datalen = want; 00253 goto more; 00254 } 00255 *datalen = switch_buffer_read(sh->buffer, data, orig_len); 00256 status = SWITCH_STATUS_SUCCESS; 00257 } else { 00258 memcpy(data, sh->resampler->to, sh->resampler->to_len * 2); 00259 *datalen = sh->resampler->to_len * 2; 00260 status = SWITCH_STATUS_SUCCESS; 00261 } 00262 } 00263 00264 return status; 00265 00266 }
| 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.
| sh | the speech handle | |
| param | the parameter | |
| val | the value |
Definition at line 168 of file switch_core_speech.c.
References switch_assert.
Referenced by switch_core_speech_feed_tts(), and switch_ivr_speak_text().
00169 { 00170 switch_assert(sh != NULL); 00171 00172 if (sh->speech_interface->speech_text_param_tts) { 00173 sh->speech_interface->speech_text_param_tts(sh, param, val); 00174 } 00175 }
1.4.7