FreeSWITCH API Documentation  1.7.0
Functions
switch_core_speech.c File Reference
#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, unsigned int channels, 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. More...
 
void switch_core_speech_flush_tts (switch_speech_handle_t *sh)
 Flush TTS audio on a given handle. More...
 
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. More...
 
void switch_core_speech_numeric_param_tts (switch_speech_handle_t *sh, char *param, int val)
 Set a numeric parameter on a TTS handle. More...
 
void switch_core_speech_float_param_tts (switch_speech_handle_t *sh, char *param, double val)
 Set a float parameter on a TTS handle. More...
 
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. More...
 
switch_status_t switch_core_speech_close (switch_speech_handle_t *sh, switch_speech_flag_t *flags)
 Close an open speech handle. More...
 

Function Documentation

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,
unsigned int  channels,
switch_speech_flag_t flags,
switch_memory_pool_t pool 
)

Definition at line 39 of file switch_core_speech.c.

References buf, pool, 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.

44 {
45  switch_status_t status;
46  char buf[256] = "";
47  char *param = NULL;
48 
49  if (!sh || !flags || zstr(module_name)) {
50  return SWITCH_STATUS_FALSE;
51  }
52 
53  if (strchr(module_name, ':')) {
54  switch_set_string(buf, module_name);
55  if ((param = strchr(buf, ':'))) {
56  *param++ = '\0';
57  module_name = buf;
58  }
59  }
60 
61  if ((sh->speech_interface = switch_loadable_module_get_speech_interface(module_name)) == 0) {
62  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid speech module [%s]!\n", module_name);
63  return SWITCH_STATUS_GENERR;
64  }
65 
66  sh->flags = *flags;
67  if (pool) {
68  sh->memory_pool = pool;
69  } else {
72  return status;
73  }
75  }
76 
77  sh->engine = switch_core_strdup(sh->memory_pool, module_name);
78  if (param) {
79  sh->param = switch_core_strdup(sh->memory_pool, param);
80  }
81 
82  sh->rate = rate;
83  sh->name = switch_core_strdup(sh->memory_pool, module_name);
84  sh->samples = switch_samples_per_packet(rate, interval);
85  sh->samplerate = rate;
86  sh->native_rate = rate;
87  sh->channels = channels;
88  sh->real_channels = 1;
89 
90  if ((status = sh->speech_interface->speech_open(sh, voice_name, rate, channels, flags)) == SWITCH_STATUS_SUCCESS) {
92  } else {
94  }
95 
96  return status;
97 }
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
Definition: switch_core.h:631
#define switch_set_flag(obj, flag)
Set a flag on an arbitrary object.
Definition: switch_utils.h:631
#define SWITCH_CHANNEL_LOG
#define switch_core_strdup(_pool, _todup)
Copy a string using memory allocation from a given pool.
Definition: switch_core.h:729
switch_memory_pool_t * pool
#define zstr(x)
Definition: switch_utils.h:281
switch_memory_pool_t * memory_pool
#define UNPROTECT_INTERFACE(_it)
switch_byte_t switch_byte_t * buf
switch_speech_interface_t * speech_interface
#define switch_samples_per_packet(rate, interval)
Definition: switch_utils.h:258
switch_status_t
Common return values.
#define switch_set_string(_dst, _src)
Definition: switch_utils.h:665
switch_status_t(* speech_open)(switch_speech_handle_t *sh, const char *voice_name, int rate, int channels, switch_speech_flag_t *flags)
void switch_log_printf(_In_ switch_text_channel_t channel, _In_z_ const char *file, _In_z_ const char *func, _In_ int line, _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, _In_z_ _Printf_format_string_ const char *fmt,...) PRINTF_FUNCTION(7
Write log data to the logging engine.
switch_speech_interface_t * switch_loadable_module_get_speech_interface(const char *name)
Retrieve the speech interface by it's registered name.