#include <switch.h>#include "private/switch_core_pvt.h"Include dependency graph for switch_core_speech.c:
Go to the source code of this file.
Functions | |
| switch_status_t | switch_core_speech_open (switch_speech_handle_t *sh, const char *module_name, const char *voice_name, unsigned int rate, unsigned int interval, switch_speech_flag_t *flags, switch_memory_pool_t *pool) |
| 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_speech_open | ( | switch_speech_handle_t * | sh, | |
| const char * | module_name, | |||
| const char * | voice_name, | |||
| unsigned int | rate, | |||
| unsigned int | interval, | |||
| switch_speech_flag_t * | flags, | |||
| switch_memory_pool_t * | pool | |||
| ) |
Definition at line 39 of file switch_core_speech.c.
References buf, SWITCH_CHANNEL_LOG, switch_core_new_memory_pool, switch_core_strdup, switch_loadable_module_get_speech_interface(), SWITCH_LOG_ERROR, switch_log_printf(), switch_samples_per_packet, switch_set_flag, switch_set_string, SWITCH_SPEECH_FLAG_FREE_POOL, SWITCH_SPEECH_FLAG_OPEN, SWITCH_STATUS_FALSE, SWITCH_STATUS_GENERR, SWITCH_STATUS_SUCCESS, UNPROTECT_INTERFACE, and zstr.
00043 { 00044 switch_status_t status; 00045 char buf[256] = ""; 00046 char *param = NULL; 00047 00048 if (!sh || !flags || zstr(module_name)) { 00049 return SWITCH_STATUS_FALSE; 00050 } 00051 00052 if (strchr(module_name, ':')) { 00053 switch_set_string(buf, module_name); 00054 if ((param = strchr(buf, ':'))) { 00055 *param++ = '\0'; 00056 module_name = buf; 00057 } 00058 } 00059 00060 if ((sh->speech_interface = switch_loadable_module_get_speech_interface(module_name)) == 0) { 00061 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid speech module [%s]!\n", module_name); 00062 return SWITCH_STATUS_GENERR; 00063 } 00064 00065 sh->flags = *flags; 00066 if (pool) { 00067 sh->memory_pool = pool; 00068 } else { 00069 if ((status = switch_core_new_memory_pool(&sh->memory_pool)) != SWITCH_STATUS_SUCCESS) { 00070 UNPROTECT_INTERFACE(sh->speech_interface); 00071 return status; 00072 } 00073 switch_set_flag(sh, SWITCH_SPEECH_FLAG_FREE_POOL); 00074 } 00075 00076 sh->engine = switch_core_strdup(sh->memory_pool, module_name); 00077 if (param) { 00078 sh->param = switch_core_strdup(sh->memory_pool, param); 00079 } 00080 00081 sh->rate = rate; 00082 sh->name = switch_core_strdup(sh->memory_pool, module_name); 00083 sh->samples = switch_samples_per_packet(rate, interval); 00084 sh->samplerate = rate; 00085 sh->native_rate = rate; 00086 00087 if ((status = sh->speech_interface->speech_open(sh, voice_name, rate, flags)) == SWITCH_STATUS_SUCCESS) { 00088 switch_set_flag(sh, SWITCH_SPEECH_FLAG_OPEN); 00089 } else { 00090 UNPROTECT_INTERFACE(sh->speech_interface); 00091 } 00092 00093 return status; 00094 }
1.4.7