mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-13 07:45:26 +00:00
first cut and say interface rework to include gender and put all args into a struct for easier future extension
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16929 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
0241b93bc5
commit
7c16b84aac
@ -222,7 +222,8 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg);
|
||||
SWITCH_DECLARE(void *) getPrivate(char *var);
|
||||
SWITCH_DECLARE(const char *) getVariable(char *var);
|
||||
SWITCH_DECLARE(switch_status_t) process_callback_result(char *result);
|
||||
SWITCH_DECLARE(void) say(const char *tosay, const char *module_name, const char *say_type, const char *say_method);
|
||||
SWITCH_DECLARE(void) say(const char *tosay, const char *module_name, const char *say_type, const char *say_method,
|
||||
const char *say_gender = NULL);
|
||||
SWITCH_DECLARE(void) sayPhrase(const char *phrase_name, const char *phrase_data = "", const char *phrase_lang = NULL);
|
||||
SWITCH_DECLARE(const char *) hangupCause();
|
||||
SWITCH_DECLARE(const char *) getState();
|
||||
|
@ -810,10 +810,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_se
|
||||
switch_bind_flag_t bind_flags, const char *app);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session, uint32_t key);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_soft_hold(switch_core_session_t *session, const char *unhold_key, const char *moh_a, const char *moh_b);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type,
|
||||
const char *say_method, switch_input_args_t *args);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session,
|
||||
const char *tosay,
|
||||
const char *module_name,
|
||||
const char *say_type,
|
||||
const char *say_method,
|
||||
const char *say_gender,
|
||||
switch_input_args_t *args);
|
||||
|
||||
SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name);
|
||||
SWITCH_DECLARE(switch_say_gender_t) switch_ivr_get_say_gender_by_name(const char *name);
|
||||
SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_set_user(switch_core_session_t *session, const char *data);
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session);
|
||||
|
@ -309,6 +309,12 @@ typedef enum {
|
||||
SST_SHORT_DATE_TIME
|
||||
} switch_say_type_t;
|
||||
|
||||
typedef enum {
|
||||
SSG_MASCULINE,
|
||||
SSG_FEMININE,
|
||||
SSG_NEUTER
|
||||
} switch_say_gender_t;
|
||||
|
||||
typedef enum {
|
||||
SMA_NONE,
|
||||
SMA_GET,
|
||||
@ -1579,8 +1585,18 @@ typedef struct {
|
||||
switch_read_frame_callback_function_t read_frame_callback;
|
||||
void *user_data;
|
||||
} switch_input_args_t;
|
||||
|
||||
typedef struct {
|
||||
switch_say_type_t type;
|
||||
switch_say_method_t method;
|
||||
switch_say_gender_t gender;
|
||||
} switch_say_args_t;
|
||||
|
||||
typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args);
|
||||
char *tosay,
|
||||
switch_say_args_t *say_args,
|
||||
switch_input_args_t *args);
|
||||
|
||||
typedef struct switch_xml *switch_xml_t;
|
||||
typedef struct switch_core_time_duration switch_core_time_duration_t;
|
||||
typedef switch_xml_t(*switch_xml_search_function_t) (const char *section,
|
||||
|
@ -1807,23 +1807,23 @@ SWITCH_STANDARD_APP(play_and_get_digits_function)
|
||||
prompt_audio_file, bad_input_audio_file, var_name, digit_buffer, sizeof(digit_buffer), digits_regex);
|
||||
}
|
||||
|
||||
#define SAY_SYNTAX "<module_name> <say_type> <say_method> <text>"
|
||||
#define SAY_SYNTAX "<module_name> <say_type> <say_method> [<say_gender>] <text>"
|
||||
SWITCH_STANDARD_APP(say_function)
|
||||
{
|
||||
char *argv[4] = { 0 };
|
||||
char *argv[5] = { 0 };
|
||||
int argc;
|
||||
char *lbuf = NULL;
|
||||
switch_input_args_t args = { 0 };
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
|
||||
if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
|
||||
&& (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) && (argc == 4 || argc == 5)) {
|
||||
|
||||
args.input_callback = on_dtmf;
|
||||
|
||||
switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
|
||||
|
||||
switch_ivr_say(session, argv[3], argv[0], argv[1], argv[2], &args);
|
||||
switch_ivr_say(session, (argc == 4) ? argv[3] : argv[4], argv[0], argv[1], argv[2], (argc == 5) ? argv[3] : NULL ,&args);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SAY_SYNTAX);
|
||||
}
|
||||
|
@ -52,27 +52,36 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_de_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_de, mod_say_de_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = de_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
de_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}}\
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t de_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t de_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -81,9 +90,9 @@ static switch_status_t de_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -177,8 +186,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t de_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t de_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int x = 0;
|
||||
@ -201,7 +209,7 @@ static switch_status_t de_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
@ -210,7 +218,7 @@ static switch_status_t de_say_general_count(switch_core_session_t *session,
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -233,7 +241,7 @@ static switch_status_t de_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t de_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t de_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -258,27 +266,26 @@ static switch_status_t de_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t de_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
switch_time_exp_t tm;
|
||||
uint8_t say_date = 0, say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -365,7 +372,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -416,8 +423,7 @@ static switch_status_t de_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t de_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -449,7 +455,7 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
de_say_general_count(session, dollars, type, method, args);
|
||||
de_say_general_count(session, dollars, say_args, args);
|
||||
if (atoi(dollars) == 1) {
|
||||
say_file("currency/dollar.wav");
|
||||
} else {
|
||||
@ -461,7 +467,7 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
de_say_general_count(session, cents, type, method, args);
|
||||
de_say_general_count(session, cents, say_args, args);
|
||||
if (atoi(cents) == 1) {
|
||||
say_file("currency/cent.wav");
|
||||
} else {
|
||||
@ -477,12 +483,12 @@ static switch_status_t de_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t de_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t de_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -506,12 +512,12 @@ static switch_status_t de_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = de_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -51,27 +51,37 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_en_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_en, mod_say_en_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = en_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
en_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
static switch_status_t en_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t en_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -80,9 +90,9 @@ static switch_status_t en_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -170,8 +180,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int x = 0;
|
||||
@ -179,7 +188,7 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
char sbuf[128] = "";
|
||||
switch_status_t status;
|
||||
|
||||
if (method == SSM_ITERATED) {
|
||||
if (say_args->method == SSM_ITERATED) {
|
||||
if ((tosay = strip_commas(tosay, sbuf, sizeof(sbuf)))) {
|
||||
char *p;
|
||||
for (p = tosay; p && *p; p++) {
|
||||
@ -207,7 +216,7 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
@ -216,7 +225,7 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -231,7 +240,7 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t en_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -256,20 +265,19 @@ static switch_status_t en_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t en_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t en_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0, target_now = 0;
|
||||
@ -278,7 +286,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *tz = switch_channel_get_variable(channel, "timezone");
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -381,7 +389,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
|
||||
switch_time_exp_lt(&tm_now, target_now);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -481,8 +489,7 @@ static switch_status_t en_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t en_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t en_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -514,7 +521,7 @@ static switch_status_t en_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
en_say_general_count(session, dollars, type, method, args);
|
||||
en_say_general_count(session, dollars, say_args, args);
|
||||
if (atoi(dollars) == 1) {
|
||||
say_file("currency/dollar.wav");
|
||||
} else {
|
||||
@ -526,7 +533,7 @@ static switch_status_t en_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
en_say_general_count(session, cents, type, method, args);
|
||||
en_say_general_count(session, cents, say_args, args);
|
||||
if (atoi(cents) == 1) {
|
||||
say_file("currency/cent.wav");
|
||||
} else {
|
||||
@ -542,12 +549,12 @@ static switch_status_t en_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t en_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t en_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -572,12 +579,12 @@ static switch_status_t en_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = en_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -51,27 +51,37 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_es_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_es, mod_say_es_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = es_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
es_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
static switch_status_t es_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t es_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -80,9 +90,9 @@ static switch_status_t es_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -196,8 +206,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t es_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t es_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int x = 0;
|
||||
@ -220,7 +229,7 @@ static switch_status_t es_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
@ -229,7 +238,7 @@ static switch_status_t es_say_general_count(switch_core_session_t *session,
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -252,7 +261,7 @@ static switch_status_t es_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t es_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t es_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -277,27 +286,26 @@ static switch_status_t es_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t es_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t es_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
switch_time_exp_t tm;
|
||||
uint8_t say_date = 0, say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -384,7 +392,7 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -436,8 +444,7 @@ static switch_status_t es_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t es_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t es_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -469,7 +476,7 @@ static switch_status_t es_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
es_say_general_count(session, dollars, type, method, args);
|
||||
es_say_general_count(session, dollars, say_args, args);
|
||||
if (atoi(dollars) == 1) {
|
||||
say_file("currency/dollar.wav");
|
||||
} else {
|
||||
@ -481,7 +488,7 @@ static switch_status_t es_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
es_say_general_count(session, cents, type, method, args);
|
||||
es_say_general_count(session, cents, say_args, args);
|
||||
if (atoi(cents) == 1) {
|
||||
say_file("currency/cent.wav");
|
||||
} else {
|
||||
@ -497,12 +504,12 @@ static switch_status_t es_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t es_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t es_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -526,12 +533,12 @@ static switch_status_t es_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = es_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -40,7 +40,7 @@
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Michael B. Murdock <mike@mmurdock.org>
|
||||
*
|
||||
* mod_say_fr.c -- Say for English
|
||||
* mod_say_fr.c -- Say for french
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,27 +51,37 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_fr_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_fr, mod_say_fr_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = fr_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
fr_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
static switch_status_t fr_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t fr_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -80,9 +90,9 @@ static switch_status_t fr_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -166,8 +176,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t fr_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t fr_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int x = 0;
|
||||
@ -190,7 +199,7 @@ static switch_status_t fr_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
@ -199,7 +208,7 @@ static switch_status_t fr_say_general_count(switch_core_session_t *session,
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -222,7 +231,7 @@ static switch_status_t fr_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t fr_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t fr_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -247,27 +256,26 @@ static switch_status_t fr_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
switch_time_exp_t tm;
|
||||
uint8_t say_date = 0, say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -354,7 +362,7 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -406,8 +414,7 @@ static switch_status_t fr_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -439,7 +446,7 @@ static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
fr_say_general_count(session, dollars, type, method, args);
|
||||
fr_say_general_count(session, dollars, say_args, args);
|
||||
if (atoi(dollars) == 1) {
|
||||
say_file("currency/dollar.wav");
|
||||
} else {
|
||||
@ -451,7 +458,7 @@ static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
fr_say_general_count(session, cents, type, method, args);
|
||||
fr_say_general_count(session, cents, say_args, args);
|
||||
if (atoi(cents) == 1) {
|
||||
say_file("currency/cent.wav");
|
||||
} else {
|
||||
@ -467,12 +474,12 @@ static switch_status_t fr_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t fr_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t fr_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -496,12 +503,12 @@ static switch_status_t fr_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = fr_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -51,27 +51,37 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_hu_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_hu, mod_say_hu_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = hu_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
hu_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
static switch_status_t hu_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t hu_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -80,9 +90,9 @@ static switch_status_t hu_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -170,8 +180,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t hu_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t hu_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int x = 0;
|
||||
@ -196,7 +205,7 @@ static switch_status_t hu_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status =
|
||||
@ -207,7 +216,7 @@ static switch_status_t hu_say_general_count(switch_core_session_t *session,
|
||||
play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, number, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, number, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -230,7 +239,7 @@ static switch_status_t hu_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t hu_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t hu_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -255,20 +264,19 @@ static switch_status_t hu_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0, target_now = 0;
|
||||
@ -277,7 +285,7 @@ static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay,
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *tz = switch_channel_get_variable(channel, "timezone");
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -368,7 +376,7 @@ static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay,
|
||||
switch_time_exp_lt(&tm_now, target_now);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -444,8 +452,7 @@ static switch_status_t hu_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t hu_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t hu_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = "";
|
||||
char *forint;
|
||||
@ -466,7 +473,7 @@ static switch_status_t hu_say_money(switch_core_session_t *session, char *tosay,
|
||||
forint++;
|
||||
}
|
||||
|
||||
hu_say_general_count(session, forint, type, method, args);
|
||||
hu_say_general_count(session, forint, say_args, args);
|
||||
say_file("currency/forint.wav");
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
@ -474,12 +481,12 @@ static switch_status_t hu_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t hu_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t hu_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -504,12 +511,12 @@ static switch_status_t hu_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = hu_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -40,7 +40,7 @@
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Michael B. Murdock <mike@mmurdock.org>
|
||||
*
|
||||
* mod_say_it.c -- Say for English
|
||||
* mod_say_it.c -- Say for Italian
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,13 +51,34 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_it_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_it, mod_say_it_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = it_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
it_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
@ -71,7 +92,7 @@ SWITCH_MODULE_DEFINITION(mod_say_it, mod_say_it_load, NULL, NULL);
|
||||
}}\
|
||||
|
||||
|
||||
static switch_status_t it_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t it_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -80,9 +101,9 @@ static switch_status_t it_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -168,8 +189,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t it_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t it_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int places_count = 0;
|
||||
@ -207,7 +227,7 @@ static switch_status_t it_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
while (in > 0 && ++places_count > 0 /* fake check to put in while */ );
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
|
||||
@ -241,7 +261,7 @@ static switch_status_t it_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
/* Play last group */
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -264,7 +284,7 @@ static switch_status_t it_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t it_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t it_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -289,27 +309,26 @@ static switch_status_t it_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t it_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t it_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
switch_time_exp_t tm;
|
||||
uint8_t say_date = 0, say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -396,7 +415,7 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -431,8 +450,7 @@ static switch_status_t it_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t it_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t it_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -464,7 +482,7 @@ static switch_status_t it_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
it_say_general_count(session, dollars, type, method, args);
|
||||
it_say_general_count(session, dollars, say_args, args);
|
||||
if (atoi(dollars) == 1) {
|
||||
say_file("currency/dollar.wav");
|
||||
} else {
|
||||
@ -476,7 +494,7 @@ static switch_status_t it_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
it_say_general_count(session, cents, type, method, args);
|
||||
it_say_general_count(session, cents, say_args, args);
|
||||
if (atoi(cents) == 1) {
|
||||
say_file("currency/cent.wav");
|
||||
} else {
|
||||
@ -492,12 +510,12 @@ static switch_status_t it_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t it_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t it_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -521,12 +539,12 @@ static switch_status_t it_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = it_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -40,7 +40,7 @@
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Michael B. Murdock <mike@mmurdock.org>
|
||||
*
|
||||
* mod_say_nl.c -- Say for English
|
||||
* mod_say_nl.c -- Say for nl
|
||||
*
|
||||
*/
|
||||
|
||||
@ -51,27 +51,37 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_nl_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_nl, mod_say_nl_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = nl_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}}\
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
nl_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
static switch_status_t nl_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t nl_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -80,9 +90,9 @@ static switch_status_t nl_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -166,8 +176,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t nl_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t nl_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
int x = 0;
|
||||
@ -190,7 +199,7 @@ static switch_status_t nl_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
}
|
||||
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
case SSM_PRONOUNCED:
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
@ -199,7 +208,7 @@ static switch_status_t nl_say_general_count(switch_core_session_t *session,
|
||||
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
if ((status = play_group(say_args->method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||
return status;
|
||||
}
|
||||
break;
|
||||
@ -222,7 +231,7 @@ static switch_status_t nl_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t nl_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t nl_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -247,27 +256,26 @@ static switch_status_t nl_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
switch_time_exp_t tm;
|
||||
uint8_t say_date = 0, say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -354,7 +362,7 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -406,8 +414,7 @@ static switch_status_t nl_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -439,7 +446,7 @@ static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
nl_say_general_count(session, dollars, type, method, args);
|
||||
nl_say_general_count(session, dollars, say_args, args);
|
||||
if (atoi(dollars) == 1) {
|
||||
say_file("currency/dollar.wav");
|
||||
} else {
|
||||
@ -451,7 +458,7 @@ static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
nl_say_general_count(session, cents, type, method, args);
|
||||
nl_say_general_count(session, cents, say_args, args);
|
||||
if (atoi(cents) == 1) {
|
||||
say_file("currency/cent.wav");
|
||||
} else {
|
||||
@ -467,12 +474,12 @@ static switch_status_t nl_say_money(switch_core_session_t *session, char *tosay,
|
||||
|
||||
|
||||
|
||||
static switch_status_t nl_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t nl_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -496,12 +503,12 @@ static switch_status_t nl_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = nl_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -111,7 +111,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t ru_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t ru_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -120,9 +120,9 @@ static switch_status_t ru_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= 48 && a <= 57) {
|
||||
say_file("digits/%d.wav", a - 48);
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -286,14 +286,13 @@ static switch_status_t ru_say_count(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
//дописать
|
||||
static switch_status_t ru_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t ru_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
switch_status_t status;
|
||||
casus_t casus; //падеж
|
||||
say_type_t say_type; //тип произношения
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_MESSAGES:
|
||||
say_type = it_c;
|
||||
casus = nominativus;
|
||||
@ -308,8 +307,7 @@ static switch_status_t ru_say_general_count(switch_core_session_t *session,
|
||||
return status;
|
||||
}
|
||||
|
||||
static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type,
|
||||
switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = "";
|
||||
char *rubles = NULL;
|
||||
@ -380,8 +378,7 @@ static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
char buf[80];
|
||||
@ -391,9 +388,9 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
|
||||
switch_channel_t *channel = switch_core_session_get_channel(session);
|
||||
const char *tz = switch_channel_get_variable(channel, "timezone");
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n", tosay, type, method);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n", tosay, say_args->type, say_args->method);
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -492,7 +489,7 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
|
||||
switch_time_exp_lt(&tm_now, target_now);
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -562,12 +559,13 @@ static switch_status_t ru_say_time(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
if (say_time) {
|
||||
switch_snprintf(buf, sizeof(buf), "%d:%d:%d", tm.tm_hour + 1, tm.tm_min, tm.tm_sec);
|
||||
ru_say_time(session, buf, SST_TIME_MEASUREMENT, method, args);
|
||||
say_args->type = SST_TIME_MEASUREMENT;
|
||||
ru_say_time(session, buf, say_args, args);
|
||||
}
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -605,11 +603,11 @@ static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t ru_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t ru_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -642,12 +640,12 @@ static switch_status_t ru_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = ru_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -58,29 +58,36 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_th_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_th, mod_say_th_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = th_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}\
|
||||
}\
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}\
|
||||
}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
th_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
|
||||
static switch_status_t th_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
static switch_status_t th_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -89,9 +96,9 @@ static switch_status_t th_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= '0' && a <= '9') {
|
||||
say_file("digits/%d.wav", a - '0');
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -146,8 +153,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t th_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t th_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
char sbuf[13] = "";
|
||||
@ -164,7 +170,7 @@ static switch_status_t th_say_general_count(switch_core_session_t *session,
|
||||
if (in != 0) {
|
||||
snprintf(digits, sizeof(digits), "%10.10d", in);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Say: %s \n", digits);
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
say_file("digits/ordinal.wav");
|
||||
/* Fall through */
|
||||
@ -286,7 +292,7 @@ static switch_status_t th_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t th_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t th_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -311,19 +317,18 @@ static switch_status_t th_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t th_say_time(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t th_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
@ -335,7 +340,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
|
||||
uint8_t say_date = 0;
|
||||
uint8_t say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -421,7 +426,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
|
||||
target = switch_micro_time_now();
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -514,8 +519,7 @@ static switch_status_t th_say_time(switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t th_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t th_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -547,12 +551,12 @@ static switch_status_t th_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
th_say_general_count(session, dollars, type, method, args);
|
||||
th_say_general_count(session, dollars, say_args, args);
|
||||
say_file("currency/dollar.wav");
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
th_say_general_count(session, cents, type, method, args);
|
||||
th_say_general_count(session, cents, say_args, args);
|
||||
} else {
|
||||
say_file("digits/0.wav");
|
||||
}
|
||||
@ -561,11 +565,11 @@ static switch_status_t th_say_money(switch_core_session_t *session, char *tosay,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t th_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t th_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -589,12 +593,12 @@ static switch_status_t th_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = th_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -58,29 +58,35 @@
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_say_zh_load);
|
||||
SWITCH_MODULE_DEFINITION(mod_say_zh, mod_say_zh_load, NULL, NULL);
|
||||
|
||||
#define say_num(num, t) { \
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = zh_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||
return tstatus;\
|
||||
}\
|
||||
}\
|
||||
#define say_num(num, meth) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_say_method_t smeth = say_args->method; \
|
||||
switch_say_type_t stype = say_args->type; \
|
||||
say_args->type = SST_ITEMS; say_args->method = meth; \
|
||||
switch_snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||
if ((tstatus = \
|
||||
zh_say_general_count(session, tmp, say_args, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS) { \
|
||||
return tstatus; \
|
||||
} \
|
||||
say_args->method = smeth; say_args->type = stype; \
|
||||
} \
|
||||
|
||||
#define say_file(...) {\
|
||||
char tmp[80];\
|
||||
switch_status_t tstatus;\
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__);\
|
||||
if ((tstatus = switch_ivr_play_file(session, NULL, tmp, args)) != SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus;\
|
||||
}\
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) {\
|
||||
return SWITCH_STATUS_FALSE;\
|
||||
}\
|
||||
}\
|
||||
#define say_file(...) { \
|
||||
char tmp[80]; \
|
||||
switch_status_t tstatus; \
|
||||
switch_snprintf(tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
if ((tstatus = \
|
||||
switch_ivr_play_file(session, NULL, tmp, args)) \
|
||||
!= SWITCH_STATUS_SUCCESS){ \
|
||||
return tstatus; \
|
||||
} \
|
||||
if (!switch_channel_ready(switch_core_session_get_channel(session))) { \
|
||||
return SWITCH_STATUS_FALSE; \
|
||||
}} \
|
||||
|
||||
|
||||
static switch_status_t zh_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t zh_spell(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *p;
|
||||
|
||||
@ -89,9 +95,9 @@ static switch_status_t zh_spell(switch_core_session_t *session, char *tosay, swi
|
||||
if (a >= '0' && a <= '9') {
|
||||
say_file("digits/%d.wav", a - '0');
|
||||
} else {
|
||||
if (type == SST_NAME_SPELLED) {
|
||||
if (say_args->type == SST_NAME_SPELLED) {
|
||||
say_file("ascii/%d.wav", a);
|
||||
} else if (type == SST_NAME_PHONETIC) {
|
||||
} else if (say_args->type == SST_NAME_PHONETIC) {
|
||||
say_file("phonetic-ascii/%d.wav", a);
|
||||
}
|
||||
}
|
||||
@ -146,8 +152,7 @@ static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static switch_status_t zh_say_general_count(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t zh_say_general_count(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int in;
|
||||
char sbuf[13] = "";
|
||||
@ -163,7 +168,7 @@ static switch_status_t zh_say_general_count(switch_core_session_t *session,
|
||||
|
||||
if (in != 0) {
|
||||
snprintf(digits, sizeof(digits), "%10.10d", in);
|
||||
switch (method) {
|
||||
switch (say_args->method) {
|
||||
case SSM_COUNTED:
|
||||
say_file("digits/ordinal.wav");
|
||||
/* Fall through */
|
||||
@ -266,7 +271,7 @@ static switch_status_t zh_say_general_count(switch_core_session_t *session,
|
||||
}
|
||||
|
||||
|
||||
static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char *a, *b, *c, *d;
|
||||
if (!(a = switch_core_session_strdup(session, tosay))) {
|
||||
@ -291,19 +296,18 @@ static switch_status_t zh_ip(switch_core_session_t *session, char *tosay, switch
|
||||
|
||||
*d++ = '\0';
|
||||
|
||||
say_num(atoi(a), method);
|
||||
say_num(atoi(a), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(b), method);
|
||||
say_num(atoi(b), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(c), method);
|
||||
say_num(atoi(c), say_args->method);
|
||||
say_file("digits/dot.wav");
|
||||
say_num(atoi(d), method);
|
||||
say_num(atoi(d), say_args->method);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t zh_say_time(switch_core_session_t *session,
|
||||
char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t zh_say_time(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
int32_t t;
|
||||
switch_time_t target = 0;
|
||||
@ -315,7 +319,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
|
||||
uint8_t say_date = 0;
|
||||
uint8_t say_time = 0;
|
||||
|
||||
if (type == SST_TIME_MEASUREMENT) {
|
||||
if (say_args->type == SST_TIME_MEASUREMENT) {
|
||||
int64_t hours = 0;
|
||||
int64_t minutes = 0;
|
||||
int64_t seconds = 0;
|
||||
@ -401,7 +405,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
|
||||
target = switch_micro_time_now();
|
||||
switch_time_exp_lt(&tm, target);
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_CURRENT_DATE_TIME:
|
||||
say_date = say_time = 1;
|
||||
break;
|
||||
@ -494,8 +498,7 @@ static switch_status_t zh_say_time(switch_core_session_t *session,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t zh_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
|
||||
switch_input_args_t *args)
|
||||
static switch_status_t zh_say_money(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
char sbuf[16] = ""; /* enough for 999,999,999,999.99 (w/o the commas or leading $) */
|
||||
char *dollars = NULL;
|
||||
@ -527,12 +530,12 @@ static switch_status_t zh_say_money(switch_core_session_t *session, char *tosay,
|
||||
}
|
||||
|
||||
/* Say dollar amount */
|
||||
zh_say_general_count(session, dollars, type, method, args);
|
||||
zh_say_general_count(session, dollars, say_args, args);
|
||||
say_file("currency/dollar.wav");
|
||||
|
||||
/* Say cents */
|
||||
if (cents) {
|
||||
zh_say_general_count(session, cents, type, method, args);
|
||||
zh_say_general_count(session, cents, say_args, args);
|
||||
} else {
|
||||
say_file("digits/0.wav");
|
||||
}
|
||||
@ -541,11 +544,11 @@ static switch_status_t zh_say_money(switch_core_session_t *session, char *tosay,
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
|
||||
static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args)
|
||||
{
|
||||
switch_say_callback_t say_cb = NULL;
|
||||
|
||||
switch (type) {
|
||||
switch (say_args->type) {
|
||||
case SST_NUMBER:
|
||||
case SST_ITEMS:
|
||||
case SST_PERSONS:
|
||||
@ -569,12 +572,12 @@ static switch_status_t zh_say(switch_core_session_t *session, char *tosay, switc
|
||||
say_cb = zh_say_money;
|
||||
break;
|
||||
default:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", say_args->type);
|
||||
break;
|
||||
}
|
||||
|
||||
if (say_cb) {
|
||||
return say_cb(session, tosay, type, method, args);
|
||||
return say_cb(session, tosay, say_args, args);
|
||||
}
|
||||
|
||||
return SWITCH_STATUS_FALSE;
|
||||
|
@ -809,7 +809,7 @@ SWITCH_DECLARE(char *) CoreSession::playAndGetDigits(int min_digits,
|
||||
return dtmf_buf;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name, const char *say_type, const char *say_method)
|
||||
SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name, const char *say_type, const char *say_method, const char *say_gender)
|
||||
{
|
||||
this_check_void();
|
||||
sanity_check_noreturn;
|
||||
@ -818,7 +818,7 @@ SWITCH_DECLARE(void) CoreSession::say(const char *tosay, const char *module_name
|
||||
return;
|
||||
}
|
||||
begin_allow_threads();
|
||||
switch_ivr_say(session, tosay, module_name, say_type, say_method, ap);
|
||||
switch_ivr_say(session, tosay, module_name, say_type, say_method, say_gender, ap);
|
||||
end_allow_threads();
|
||||
}
|
||||
|
||||
|
@ -2137,8 +2137,13 @@ SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint3
|
||||
stfu_n_destroy(&jb);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, const char *tosay, const char *module_name, const char *say_type,
|
||||
const char *say_method, switch_input_args_t *args)
|
||||
SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session,
|
||||
const char *tosay,
|
||||
const char *module_name,
|
||||
const char *say_type,
|
||||
const char *say_method,
|
||||
const char *say_gender,
|
||||
switch_input_args_t *args)
|
||||
{
|
||||
switch_say_interface_t *si;
|
||||
switch_channel_t *channel;
|
||||
@ -2215,7 +2220,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_say(switch_core_session_t *session, c
|
||||
|
||||
if ((si = switch_loadable_module_get_say_interface(module_name))) {
|
||||
/* should go back and proto all the say mods to const.... */
|
||||
status = si->say_function(session, (char *) tosay, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method), args);
|
||||
switch_say_args_t say_args = {0};
|
||||
|
||||
say_args.type = switch_ivr_get_say_type_by_name(say_type);
|
||||
say_args.method = switch_ivr_get_say_method_by_name(say_method);
|
||||
say_args.gender = switch_ivr_get_say_gender_by_name(say_gender);
|
||||
|
||||
status = si->say_function(session, (char *) tosay, &say_args, args);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
|
@ -66,9 +66,34 @@ static char *SAY_TYPE_NAMES[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static char *SAY_GENDER_NAMES[] = {
|
||||
"MASCULINE",
|
||||
"FEMININE",
|
||||
"NEUTER",
|
||||
NULL
|
||||
};
|
||||
|
||||
SWITCH_DECLARE(switch_say_gender_t) switch_ivr_get_say_gender_by_name(const char *name)
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (!name) return (switch_say_gender_t)0;
|
||||
|
||||
for (x = 0; SAY_GENDER_NAMES[x]; x++) {
|
||||
if (!strcasecmp(SAY_GENDER_NAMES[x], name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (switch_say_gender_t) x;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char *name)
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (!name) return (switch_say_method_t)0;
|
||||
|
||||
for (x = 0; SAY_METHOD_NAMES[x]; x++) {
|
||||
if (!strcasecmp(SAY_METHOD_NAMES[x], name)) {
|
||||
break;
|
||||
@ -81,6 +106,9 @@ SWITCH_DECLARE(switch_say_method_t) switch_ivr_get_say_method_by_name(const char
|
||||
SWITCH_DECLARE(switch_say_type_t) switch_ivr_get_say_type_by_name(const char *name)
|
||||
{
|
||||
int x = 0;
|
||||
|
||||
if (!name) return (switch_say_type_t)0;
|
||||
|
||||
for (x = 0; SAY_TYPE_NAMES[x]; x++) {
|
||||
if (!strcasecmp(SAY_TYPE_NAMES[x], name)) {
|
||||
break;
|
||||
@ -330,10 +358,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro_event(switch_core_sessio
|
||||
if ((si = switch_loadable_module_get_say_interface(module_name))) {
|
||||
char *say_type = (char *) switch_xml_attr_soft(action, "type");
|
||||
char *say_method = (char *) switch_xml_attr_soft(action, "method");
|
||||
char *say_gender = (char *) switch_xml_attr_soft(action, "gender");
|
||||
switch_say_args_t say_args = {0};
|
||||
|
||||
status =
|
||||
si->say_function(session, odata, switch_ivr_get_say_type_by_name(say_type), switch_ivr_get_say_method_by_name(say_method),
|
||||
args);
|
||||
say_args.type = switch_ivr_get_say_type_by_name(say_type);
|
||||
say_args.method = switch_ivr_get_say_method_by_name(say_method);
|
||||
say_args.gender = switch_ivr_get_say_gender_by_name(say_gender);
|
||||
|
||||
status = si->say_function(session, odata, &say_args, args);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid SAY Interface [%s]!\n", module_name);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user