60 const char *err = NULL;
62 char *extra_modules[100] = { 0 };
63 int extra_modules_count = 0;
65 const char *tts_engine =
"flite";
66 const char *tts_voice =
"default";
67 const char *input = NULL;
68 const char *output = NULL;
69 const char *text = NULL;
74 char txtbuf[2048] = { 0 };
78 for (i = 1; i < argc; i++) {
79 if (argv[i][0] ==
'-') {
105 if (strchr(argv[i],
',')) {
106 extra_modules_count =
switch_split(argv[i],
',', extra_modules);
108 extra_modules_count = 1;
109 extra_modules[0] = argv[i];
116 tts_engine = argv[++i];
119 tts_voice = argv[++i];
122 rate = atoi(argv[++i]);
128 printf(
"Command line option not recognized: %s\n", argv[i]);
136 if (argc - i < 1 || cmd_fail) {
151 fprintf(stderr,
"Cannot init core [%s]\n", err);
161 for (i = 0; i < extra_modules_count; i++) {
163 fprintf(stderr,
"Cannot init %s [%s]\n", extra_modules[i], err);
169 fprintf(stderr,
"Cannot init mod_sndfile [%s]\n", err);
174 fprintf(stderr,
"Cannot init mod_ssml [%s]\n", err);
178 if (!strcmp(tts_engine,
"polly")) {
180 fprintf(stderr,
"Cannot init mod_polly [%s]\n", err);
185 if (!strcmp(tts_engine,
"gcloud")) {
187 fprintf(stderr,
"Cannot init mod_polly [%s]\n", err);
192 if (!strcmp(tts_voice,
"default") && !strcmp(tts_engine,
"flite")) {
198 if (
zstr(text) || *text ==
'-') {
199 while(read(STDIN_FILENO, txtbuf + len, 1) == 1) {
200 if(++len ==
sizeof(txtbuf) - 1)
break;
203 int fd = open(input, O_RDONLY);
206 fprintf(stderr,
"Error opening file %s\n", input);
210 len = read(fd, txtbuf,
sizeof(txtbuf) - 1);
223 fprintf(stderr,
"Speaking %s\n", input);
227 fprintf(stderr,
"Couldn't open %s\n", input);
232 fprintf(stderr,
"Opening file %s\n", output);
236 fprintf(stderr,
"Couldn't open %s\n", output);
240 len =
sizeof(
buf) / 2;
244 fprintf(stderr,
"Write error\n");
248 len =
sizeof(
buf) / 2;
272 printf(
"Usage: %s [options] output [text]\n\n", argv[0]);
273 printf(
"The output must end in the format, e.g., myfile.wav myfile.mp3\n");
274 printf(
"\t\t -c path\t\t Path to the FS configurations.\n");
275 printf(
"\t\t -k path\t\t Path to the FS log directory\n");
276 printf(
"\t\t -l module[,module]\t Load additional modules (comma-separated)\n");
277 printf(
"\t\t -m path\t\t Path to the modules.\n");
278 printf(
"\t\t -r rate\t\t sampling rate\n");
279 printf(
"\t\t -v\t\t\t verbose\n");
280 printf(
"\t\t -e\t\t\t TTS engine\n");
281 printf(
"\t\t -V\t\t\t TTS voice\n");
#define switch_core_new_memory_pool(p)
Create a new sub memory pool from the core's master pool.
switch_status_t switch_core_init(_In_ switch_core_flag_t flags, _In_ switch_bool_t console, _Out_ const char **err)
Initilize the core.
#define switch_split(_data, _delim, _array)
#define switch_core_destroy_memory_pool(p)
Returns a subpool back to the main pool.
switch_memory_pool_t * pool
static const char usage[]
switch_byte_t switch_byte_t * buf
static void fs_tts_cleanup(void)
switch_directories SWITCH_GLOBAL_dirs
switch_status_t switch_loadable_module_load_module(const char *dir, const char *fname, switch_bool_t runtime, const char **err)
Load a module.
switch_status_t switch_loadable_module_init(switch_bool_t autoload)
Initilize the module backend and load all the modules.
#define switch_test_flag(obj, flag)
Test for the existance of a flag on an arbitary object.
struct fspr_pool_t switch_memory_pool_t
char * switch_core_sprintf(_In_ switch_memory_pool_t *pool, _In_z_ _Printf_format_string_ const char *fmt,...)
printf-style style printing routine. The data is output to a string allocated from the pool ...