mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-21 10:53:48 +00:00
say update
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3897 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
8e84f70d59
commit
f79ade4532
@ -96,7 +96,8 @@ typedef uint8_t switch_byte_t;
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
SSM_NA,
|
SSM_NA,
|
||||||
SSM_PRONOUNCED,
|
SSM_PRONOUNCED,
|
||||||
SSM_ITERATED
|
SSM_ITERATED,
|
||||||
|
SSM_COUNTED
|
||||||
} switch_say_method_t;
|
} switch_say_method_t;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -112,6 +113,7 @@ typedef enum {
|
|||||||
SST_TELEPHONE_NUMBER,
|
SST_TELEPHONE_NUMBER,
|
||||||
SST_TELEPHONE_EXTENSION,
|
SST_TELEPHONE_EXTENSION,
|
||||||
SST_URL,
|
SST_URL,
|
||||||
|
SST_IP_ADDRESS,
|
||||||
SST_EMAIL_ADDRESS,
|
SST_EMAIL_ADDRESS,
|
||||||
SST_POSTAL_ADDRESS,
|
SST_POSTAL_ADDRESS,
|
||||||
SST_ACCOUNT_NUMBER,
|
SST_ACCOUNT_NUMBER,
|
||||||
|
@ -35,11 +35,11 @@
|
|||||||
static const char modname[] = "mod_say_en";
|
static const char modname[] = "mod_say_en";
|
||||||
|
|
||||||
|
|
||||||
#define say_num(num) {\
|
#define say_num(num, t) { \
|
||||||
char tmp[80];\
|
char tmp[80];\
|
||||||
switch_status_t status;\
|
switch_status_t status;\
|
||||||
snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
snprintf(tmp, sizeof(tmp), "%u", (unsigned)num); \
|
||||||
if ((status = en_say_general_count(session, tmp, SST_ITEMS, SSM_PRONOUNCED, args)) != SWITCH_STATUS_SUCCESS) {\
|
if ((status = en_say_general_count(session, tmp, SST_ITEMS, t, args)) != SWITCH_STATUS_SUCCESS) {\
|
||||||
return status;\
|
return status;\
|
||||||
}}\
|
}}\
|
||||||
|
|
||||||
@ -52,7 +52,6 @@ static const char modname[] = "mod_say_en";
|
|||||||
}}\
|
}}\
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static switch_status_t en_spell(switch_core_session_t *session,
|
static switch_status_t en_spell(switch_core_session_t *session,
|
||||||
char *tosay,
|
char *tosay,
|
||||||
switch_say_type_t type,
|
switch_say_type_t type,
|
||||||
@ -73,7 +72,8 @@ static switch_status_t en_spell(switch_core_session_t *session,
|
|||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_status_t play_group(int a,
|
static switch_status_t play_group(switch_say_method_t method,
|
||||||
|
int a,
|
||||||
int b,
|
int b,
|
||||||
int c,
|
int c,
|
||||||
char *what,
|
char *what,
|
||||||
@ -96,8 +96,12 @@ static switch_status_t play_group(int a,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
|
if (method == SSM_COUNTED) {
|
||||||
|
say_file("digits/h-%d.wav", c);
|
||||||
|
} else {
|
||||||
say_file("digits/%d.wav", c);
|
say_file("digits/%d.wav", c);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (what && (a || b || c)) {
|
if (what && (a || b || c)) {
|
||||||
say_file(what);
|
say_file(what);
|
||||||
@ -160,21 +164,25 @@ static switch_status_t en_say_general_count(switch_core_session_t *session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
case SSM_COUNTED:
|
||||||
case SSM_PRONOUNCED:
|
case SSM_PRONOUNCED:
|
||||||
if ((status = play_group(places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
if ((status = play_group(places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
if ((status = play_group(places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SSM_ITERATED:
|
case SSM_ITERATED:
|
||||||
for(x = 8; x >= 0; x--) {
|
{
|
||||||
if (places[x]) {
|
char *p;
|
||||||
say_file("digits/%d.wav", places[x]);
|
for (p = tosay; p && *p; p++) {
|
||||||
|
if (places[x] > -1) {
|
||||||
|
say_file("digits/%c.wav", *p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -185,6 +193,53 @@ 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)
|
||||||
|
{
|
||||||
|
char *a, *b, *c, *d;
|
||||||
|
switch_status_t status = SWITCH_STATUS_SUCCESS;
|
||||||
|
if (!(a = strdup(tosay))) {
|
||||||
|
return SWITCH_STATUS_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(b = strchr(a, '.'))) {
|
||||||
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
*b++ = '\0';
|
||||||
|
|
||||||
|
if (!(c = strchr(b, '.'))) {
|
||||||
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
*c++ = '\0';
|
||||||
|
|
||||||
|
if (!(d = strchr(c, '.'))) {
|
||||||
|
status = SWITCH_STATUS_FALSE;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
*d++ = '\0';
|
||||||
|
|
||||||
|
say_num(atoi(a), method);
|
||||||
|
say_file("digits/dot.wav");
|
||||||
|
say_num(atoi(b), method);
|
||||||
|
say_file("digits/dot.wav");
|
||||||
|
say_num(atoi(c), method);
|
||||||
|
say_file("digits/dot.wav");
|
||||||
|
say_num(atoi(d), method);
|
||||||
|
|
||||||
|
done:
|
||||||
|
switch_safe_free(a);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static switch_status_t en_say_time(switch_core_session_t *session,
|
static switch_status_t en_say_time(switch_core_session_t *session,
|
||||||
char *tosay,
|
char *tosay,
|
||||||
switch_say_type_t type,
|
switch_say_type_t type,
|
||||||
@ -236,17 +291,17 @@ static switch_status_t en_say_time(switch_core_session_t *session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hours) {
|
if (hours) {
|
||||||
say_num(hours);
|
say_num(hours, SSM_PRONOUNCED);
|
||||||
say_file("digits/hours.wav");
|
say_file("digits/hours.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minutes) {
|
if (minutes) {
|
||||||
say_num(minutes);
|
say_num(minutes, SSM_PRONOUNCED);
|
||||||
say_file("digits/minutes.wav");
|
say_file("digits/minutes.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (seconds) {
|
if (seconds) {
|
||||||
say_num(seconds);
|
say_num(seconds, SSM_PRONOUNCED);
|
||||||
say_file("digits/seconds.wav");
|
say_file("digits/seconds.wav");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,8 +332,8 @@ static switch_status_t en_say_time(switch_core_session_t *session,
|
|||||||
if (say_date) {
|
if (say_date) {
|
||||||
say_file("digits/day-%d.wav", tm.tm_wday);
|
say_file("digits/day-%d.wav", tm.tm_wday);
|
||||||
say_file("digits/mon-%d.wav", tm.tm_mon);
|
say_file("digits/mon-%d.wav", tm.tm_mon);
|
||||||
say_num(tm.tm_mday);
|
say_num(tm.tm_mday, SSM_COUNTED);
|
||||||
say_num(tm.tm_year + 1900);
|
say_num(tm.tm_year + 1900, SSM_PRONOUNCED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (say_time) {
|
if (say_time) {
|
||||||
@ -294,13 +349,13 @@ static switch_status_t en_say_time(switch_core_session_t *session,
|
|||||||
pm = 0;
|
pm = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
say_num(hour);
|
say_num(hour, SSM_PRONOUNCED);
|
||||||
|
|
||||||
if (tm.tm_min > 9) {
|
if (tm.tm_min > 9) {
|
||||||
say_num(tm.tm_min);
|
say_num(tm.tm_min, SSM_PRONOUNCED);
|
||||||
} else if (tm.tm_min) {
|
} else if (tm.tm_min) {
|
||||||
say_file("digits/oh.wav");
|
say_file("digits/oh.wav");
|
||||||
say_num(tm.tm_min);
|
say_num(tm.tm_min, SSM_PRONOUNCED);
|
||||||
} else {
|
} else {
|
||||||
say_file("digits/oclock.wav");
|
say_file("digits/oclock.wav");
|
||||||
}
|
}
|
||||||
@ -336,6 +391,9 @@ static switch_status_t en_say(switch_core_session_t *session,
|
|||||||
case SST_CURRENT_DATE_TIME:
|
case SST_CURRENT_DATE_TIME:
|
||||||
say_cb = en_say_time;
|
say_cb = en_say_time;
|
||||||
break;
|
break;
|
||||||
|
case SST_IP_ADDRESS:
|
||||||
|
say_cb = en_ip;
|
||||||
|
break;
|
||||||
case SST_NAME_SPELLED:
|
case SST_NAME_SPELLED:
|
||||||
case SST_NAME_PHONETIC:
|
case SST_NAME_PHONETIC:
|
||||||
say_cb = en_spell;
|
say_cb = en_spell;
|
||||||
|
@ -960,7 +960,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
char dtmf[128];
|
char dtmf[128];
|
||||||
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
|
uint32_t interval = 0, samples = 0, framelen, sample_start = 0;
|
||||||
uint32_t ilen = 0;
|
uint32_t ilen = 0;
|
||||||
switch_size_t olen = 0;
|
switch_size_t olen = 0, llen = 0;
|
||||||
switch_frame_t write_frame = {0};
|
switch_frame_t write_frame = {0};
|
||||||
switch_timer_t timer;
|
switch_timer_t timer;
|
||||||
switch_core_thread_session_t thread_session;
|
switch_core_thread_session_t thread_session;
|
||||||
@ -1264,11 +1264,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
|
|||||||
last_speed = fh->speed;
|
last_speed = fh->speed;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (olen < llen) {
|
||||||
|
uint8_t *dp = (uint8_t *) write_frame.data;
|
||||||
|
memset(dp + (int)olen, 0, (int)(llen - olen));
|
||||||
|
olen = llen;
|
||||||
|
}
|
||||||
|
|
||||||
write_frame.datalen = (uint32_t)(olen * (asis ? 1 : 2));
|
write_frame.datalen = (uint32_t)(olen * (asis ? 1 : 2));
|
||||||
write_frame.samples = (uint32_t)olen;
|
write_frame.samples = (uint32_t)olen;
|
||||||
|
|
||||||
|
llen = olen;
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
@ -4345,6 +4350,7 @@ static char *SAY_METHOD_NAMES[] = {
|
|||||||
"N/A",
|
"N/A",
|
||||||
"PRONOUNCED",
|
"PRONOUNCED",
|
||||||
"ITERATED",
|
"ITERATED",
|
||||||
|
"COUNTED",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4361,6 +4367,7 @@ static char *SAY_TYPE_NAMES[] = {
|
|||||||
"TELEPHONE_NUMBER",
|
"TELEPHONE_NUMBER",
|
||||||
"TELEPHONE_EXTENSION",
|
"TELEPHONE_EXTENSION",
|
||||||
"URL",
|
"URL",
|
||||||
|
"IP_ADDRESS",
|
||||||
"EMAIL_ADDRESS",
|
"EMAIL_ADDRESS",
|
||||||
"POSTAL_ADDRESS",
|
"POSTAL_ADDRESS",
|
||||||
"ACCOUNT_NUMBER",
|
"ACCOUNT_NUMBER",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user