mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-17 00:34:13 +00:00
introduce new say_string method of doing say and use it in mod_say_en as an example. try: eval ${say_string en.gsm en current_date_time pronounced ${strepoch()}} from the cli with this patch. We can do more to centralize the say things and go back and apply it to other langs, using this method you can set the desired file ext as well which I think is a bounty....
This commit is contained in:
1 parent
1552ecf54a
commit
d5ef86d778
11 files changed
+548
-111
No files matched your search
@@ -116,6 +116,59 @@ static switch_status_t select_url(const char *user,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
#define SAY_STRING_SYNTAX "<module_name>[.<ext>] <lang>[.<ext>] <say_type> <say_method> [<say_gender>] <text>"
|
||||
SWITCH_STANDARD_API(say_string_function)
|
||||
{
|
||||
char *argv[6] = { 0 };
|
||||
int argc;
|
||||
char *lbuf = NULL, *string = NULL;
|
||||
int err = 1, par = 0;
|
||||
char *p, *ext = "wav";
|
||||
|
||||
if (cmd) {
|
||||
lbuf = strdup(cmd);
|
||||
}
|
||||
|
||||
if (lbuf && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) && (argc == 5 || argc == 6)) {
|
||||
|
||||
if ((p = strchr(argv[0], '.'))) {
|
||||
*p++ = '\0';
|
||||
ext = p;
|
||||
par++;
|
||||
}
|
||||
|
||||
if (!par && (p = strchr(argv[1], '.'))) {
|
||||
*p++ = '\0';
|
||||
ext = p;
|
||||
}
|
||||
switch_ivr_say_string(session,
|
||||
argv[1],
|
||||
ext,
|
||||
(argc == 5) ? argv[4] : argv[5],
|
||||
argv[0],
|
||||
argv[2],
|
||||
argv[3],
|
||||
(argc == 6) ? argv[4] : NULL ,
|
||||
&string);
|
||||
if (string) {
|
||||
stream->write_function(stream, "%s", string);
|
||||
free(string);
|
||||
err = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (err) {
|
||||
stream->write_function(stream, "-ERR Usage: %s\n", SAY_STRING_SYNTAX);
|
||||
}
|
||||
|
||||
free(lbuf);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWITCH_STANDARD_API(reg_url_function)
|
||||
{
|
||||
char *data;
|
||||
@@ -5105,6 +5158,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load)
|
||||
SWITCH_ADD_API(commands_api_interface, "reload", "Reload Module", reload_function, UNLOAD_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_xml_function, "");
|
||||
SWITCH_ADD_API(commands_api_interface, "replace", "replace a string", replace_function, "<data>|<string1>|<string2>");
|
||||
SWITCH_ADD_API(commands_api_interface, "say_string", "", say_string_function, SAY_STRING_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "sched_api", "Schedule an api command", sched_api_function, SCHED_SYNTAX);
|
||||
SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function,
|
||||
SCHED_BROADCAST_SYNTAX);
|
||||
|
||||
Reference in new issue
Block a user