[Asterisk-cvs] asterisk Makefile,1.84,1.85 asterisk.c,1.79,1.80 pbx.c,1.116,1.117 say.c,1.21,1.22 sounds.txt,1.27,1.28
markster at lists.digium.com
markster at lists.digium.com
Sun May 2 20:46:28 CDT 2004
Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv17969
Modified Files:
Makefile asterisk.c pbx.c say.c sounds.txt
Log Message:
Add SayPhonetic and SayAlpha applications (bug #793)
Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/Makefile,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- Makefile 29 Apr 2004 22:27:40 -0000 1.84
+++ Makefile 3 May 2004 00:54:15 -0000 1.85
@@ -273,6 +273,24 @@
exit 1; \
fi; \
done
+ mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
+ for x in sounds/letters/*.gsm; do \
+ if grep -q "^%`basename $$x`%" sounds.txt; then \
+ install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
+ else \
+ echo "No description for $$x"; \
+ exit 1; \
+ fi; \
+ done
+ mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
+ for x in sounds/phonetic/*.gsm; do \
+ if grep -q "^%`basename $$x`%" sounds.txt; then \
+ install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
+ else \
+ echo "No description for $$x"; \
+ exit 1; \
+ fi; \
+ done
for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-*; do \
if grep -q "^%`basename $$x`%" sounds.txt; then \
install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
Index: asterisk.c
===================================================================
RCS file: /usr/cvsroot/asterisk/asterisk.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- asterisk.c 2 May 2004 19:13:16 -0000 1.79
+++ asterisk.c 3 May 2004 00:54:15 -0000 1.80
@@ -896,7 +896,6 @@
int i;
struct timeval tv;
struct tm tm;
- time_t curtime;
FILE *LOADAVG;
int fgcolor = COLOR_WHITE, bgcolor = COLOR_BLACK;
Index: pbx.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- pbx.c 29 Apr 2004 02:30:14 -0000 1.116
+++ pbx.c 3 May 2004 00:54:15 -0000 1.117
@@ -169,6 +169,8 @@
static int pbx_builtin_gotoiftime(struct ast_channel *, void *);
static int pbx_builtin_saynumber(struct ast_channel *, void *);
static int pbx_builtin_saydigits(struct ast_channel *, void *);
+static int pbx_builtin_saycharacters(struct ast_channel *, void *);
+static int pbx_builtin_sayphonetic(struct ast_channel *, void *);
int pbx_builtin_setvar(struct ast_channel *, void *);
void pbx_builtin_setvar_helper(struct ast_channel *chan, char *name, char *value);
char *pbx_builtin_getvar_helper(struct ast_channel *chan, char *name);
@@ -293,6 +295,14 @@
"Say Digits",
" SayDigits(digits): Says the passed digits\n" },
+ { "SayAlpha", pbx_builtin_saycharacters,
+"Say Alpha",
+" SayAlpha(string): Spells the passed string\n" },
+
+ { "SayPhonetic", pbx_builtin_sayphonetic,
+"Say Phonetic",
+" SayPhonetic(string): Spells the passed string with phonetic alphabet\n" },
+
{ "SetAccount", pbx_builtin_setaccount,
"Sets account code",
" SetAccount([account]): Set the channel account code for billing\n"
@@ -4598,6 +4608,22 @@
int res = 0;
if (data)
res = ast_say_digit_str(chan, (char *)data, "", chan->language);
+ return res;
+}
+
+static int pbx_builtin_saycharacters(struct ast_channel *chan, void *data)
+{
+ int res = 0;
+ if (data)
+ res = ast_say_character_str(chan, (char *)data, "", chan->language);
+ return res;
+}
+
+static int pbx_builtin_sayphonetic(struct ast_channel *chan, void *data)
+{
+ int res = 0;
+ if (data)
+ res = ast_say_phonetic_str(chan, (char *)data, "", chan->language);
return res;
}
Index: say.c
===================================================================
RCS file: /usr/cvsroot/asterisk/say.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- say.c 1 May 2004 22:14:42 -0000 1.21
+++ say.c 3 May 2004 00:54:15 -0000 1.22
@@ -16,6 +16,7 @@
#include <stdlib.h>
#include <netinet/in.h>
#include <time.h>
+#include <ctype.h>
#include <asterisk/file.h>
#include <asterisk/channel.h>
#include <asterisk/logger.h>
@@ -45,13 +46,13 @@
snprintf(fn, sizeof(fn), "digits/pound");
break;
default:
- if((fn2[num] >= '0') && (fn2[num] <= '9')){ /* Must be in {0-9} */
+ if((fn2[num] >= '0') && (fn2[num] <= '9')){ /* Must be in {0-9} */
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
}
- }
+ }
if(strlen(fn)){ /* if length == 0, then skip this digit as it is invalid */
res = ast_streamfile(chan, fn, lang);
- if (!res)
+ if (!res)
res = ast_waitstream(chan, ints);
ast_stopstream(chan);
}
@@ -60,6 +61,178 @@
return res;
}
+int ast_say_character_str(struct ast_channel *chan, char *fn2, char *ints, char *lang)
+{
+ /* XXX Merge with full version? XXX */
+ char fn[256] = "";
+ char ltr;
+ int num = 0;
+ int res = 0;
+ while(fn2[num] && !res) {
+ fn[0] = '\0';
+ switch (fn2[num]) {
+ case ('*'):
+ snprintf(fn, sizeof(fn), "digits/star");
+ break;
+ case ('#'):
+ snprintf(fn, sizeof(fn), "digits/pound");
+ break;
+ case ('0'):
+ case ('1'):
+ case ('2'):
+ case ('3'):
+ case ('4'):
+ case ('5'):
+ case ('6'):
+ case ('7'):
+ case ('8'):
+ case ('9'):
+ snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
+ break;
+ case ('!'):
+ strncpy(fn, "letters/exclaimation-point", sizeof(fn));
+ break;
+ case ('@'):
+ strncpy(fn, "letters/at", sizeof(fn));
+ break;
+ case ('$'):
+ strncpy(fn, "letters/dollar", sizeof(fn));
+ break;
+ case ('-'):
+ strncpy(fn, "letters/dash", sizeof(fn));
+ break;
+ case ('.'):
+ strncpy(fn, "letters/dot", sizeof(fn));
+ break;
+ case ('='):
+ strncpy(fn, "letters/equals", sizeof(fn));
+ break;
+ case ('+'):
+ strncpy(fn, "letters/plus", sizeof(fn));
+ break;
+ case ('/'):
+ strncpy(fn, "letters/slash", sizeof(fn));
+ break;
+ case (' '):
+ strncpy(fn, "letters/space", sizeof(fn));
+ break;
+ default:
+ ltr = fn2[num];
+ if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
+ snprintf(fn, sizeof(fn), "letters/%c", ltr);
+ }
+ if(strlen(fn)){ /* if length == 0, then skip this digit as it is invalid */
+ res = ast_streamfile(chan, fn, lang);
+ if (!res)
+ res = ast_waitstream(chan, ints);
+ } ast_stopstream(chan);
+ num++;
+ }
+ return res;
+}
+
+int ast_say_phonetic_str(struct ast_channel *chan, char *fn2, char *ints, char *lang)
+{
+ /* XXX Merge with full version? XXX */
+ char fn[256] = "";
+ char ltr;
+ int num = 0;
+ int res = 0;
+ int temp;
+ int play;
+ char hex[3];
+/* while(fn2[num] && !res) { */
+ while(fn2[num]) {
+ play=1;
+ switch (fn2[num]) {
+ case ('*'):
+ snprintf(fn, sizeof(fn), "digits/star");
+ break;
+ case ('#'):
+ snprintf(fn, sizeof(fn), "digits/pound");
+ break;
+ case ('0'):
+ case ('1'):
+ case ('2'):
+ case ('3'):
+ case ('4'):
+ case ('5'):
+ case ('6'):
+ case ('7'):
+ case ('8'):
+ snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
+ break;
+ case ('!'):
+ strncpy(fn, "exclaimation-point", sizeof(fn));
+ break;
+ case ('@'):
+ strncpy(fn, "at", sizeof(fn));
+ break;
+ case ('$'):
+ strncpy(fn, "dollar", sizeof(fn));
+ break;
+ case ('-'):
+ strncpy(fn, "dash", sizeof(fn));
+ break;
+ case ('.'):
+ strncpy(fn, "dot", sizeof(fn));
+ break;
+ case ('='):
+ strncpy(fn, "equals", sizeof(fn));
+ break;
+ case ('+'):
+ strncpy(fn, "plus", sizeof(fn));
+ break;
+ case ('/'):
+ strncpy(fn, "slash", sizeof(fn));
+ break;
+ case (' '):
+ strncpy(fn, "space", sizeof(fn));
+ break;
+ case ('%'):
+ play=0;
+ /* check if we have 2 chars after the % */
+ if (strlen(fn2)>num+2)
+ {
+ hex[0]=fn2[num+1];
+ hex[1]=fn2[num+2];
+ hex[2]='\0';
+ if (sscanf(hex,"%x", &temp))
+ { /* Hex to char convertion successfull */
+ fn2[num+2]=temp;
+ num++;
+ if (temp==37)
+ { /* If it is a percent, play it now */
+ strncpy(fn, "percent", sizeof(fn));
+ num++;
+ play=1;
+ }
+ /* check for invalid characters */
+ if ((temp<32) || (temp>126))
+ {
+ num++;
+ }
+ }
+ }
+ else
+ num++;
+ break;
+ default: /* '9' falls through to here, too */
+ ltr = tolower(fn2[num]);
+ snprintf(fn, sizeof(fn), "phonetic/%c_p", ltr);
+ }
+ if (play)
+ {
+ res = ast_streamfile(chan, fn, lang);
+ if (!res)
+ res = ast_waitstream(chan, ints);
+ ast_stopstream(chan);
+ }
+ num++;
+ }
+ return res;
+}
+
int ast_say_digit_str_full(struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd)
{
char fn[256] = "";
@@ -67,6 +240,141 @@
int res = 0;
while(fn2[num] && !res) {
snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
+ res = ast_streamfile(chan, fn, lang);
+ if (!res)
+ res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
+ ast_stopstream(chan);
+ num++;
+ }
+ return res;
+}
+
+int ast_say_character_str_full(struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd)
+{
+ char fn[256] = "";
+ char ltr;
+ int num = 0;
+ int res = 0;
+ while(fn2[num] && !res) {
+ switch (fn2[num]) {
+ case ('*'):
+ snprintf(fn, sizeof(fn), "digits/star");
+ break;
+ case ('#'):
+ snprintf(fn, sizeof(fn), "digits/pound");
+ break;
+ case ('0'):
+ case ('1'):
+ case ('2'):
+ case ('3'):
+ case ('4'):
+ case ('5'):
+ case ('6'):
+ case ('7'):
+ case ('8'):
+ case ('9'):
+ snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
+ break;
+ case ('!'):
+ strncpy(fn, "exclaimation-point", sizeof(fn));
+ break;
+ case ('@'):
+ strncpy(fn, "at", sizeof(fn));
+ break;
+ case ('$'):
+ strncpy(fn, "dollar", sizeof(fn));
+ break;
+ case ('-'):
+ strncpy(fn, "dash", sizeof(fn));
+ break;
+ case ('.'):
+ strncpy(fn, "dot", sizeof(fn));
+ break;
+ case ('='):
+ strncpy(fn, "equals", sizeof(fn));
+ break;
+ case ('+'):
+ strncpy(fn, "plus", sizeof(fn));
+ break;
+ case ('/'):
+ strncpy(fn, "slash", sizeof(fn));
+ break;
+ case (' '):
+ strncpy(fn, "space", sizeof(fn));
+ break;
+ default:
+ ltr = fn2[num];
+ if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
+ snprintf(fn, sizeof(fn), "letters/%c", ltr);
+ }
+ /* snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); */
+ res = ast_streamfile(chan, fn, lang);
+ if (!res)
+ res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
+ ast_stopstream(chan);
+ num++;
+ }
+ return res;
+}
+
+int ast_say_phonetic_str_full(struct ast_channel *chan, char *fn2, char *ints, char *lang, int audiofd, int ctrlfd)
+{
+ char fn[256] = "";
+ char ltr;
+ int num = 0;
+ int res = 0;
+ while(fn2[num] && !res) {
+ switch (fn2[num]) {
+ case ('*'):
+ snprintf(fn, sizeof(fn), "digits/star");
+ break;
+ case ('#'):
+ snprintf(fn, sizeof(fn), "digits/pound");
+ break;
+ case ('0'):
+ case ('1'):
+ case ('2'):
+ case ('3'):
+ case ('4'):
+ case ('5'):
+ case ('6'):
+ case ('7'):
+ case ('8'):
+ snprintf(fn, sizeof(fn), "digits/%c", fn2[num]);
+ break;
+ case ('!'):
+ strncpy(fn, "exclaimation-point", sizeof(fn));
+ break;
+ case ('@'):
+ strncpy(fn, "at", sizeof(fn));
+ break;
+ case ('$'):
+ strncpy(fn, "dollar", sizeof(fn));
+ break;
+ case ('-'):
+ strncpy(fn, "dash", sizeof(fn));
+ break;
+ case ('.'):
+ strncpy(fn, "dot", sizeof(fn));
+ break;
+ case ('='):
+ strncpy(fn, "equals", sizeof(fn));
+ break;
+ case ('+'):
+ strncpy(fn, "plus", sizeof(fn));
+ break;
+ case ('/'):
+ strncpy(fn, "slash", sizeof(fn));
+ break;
+ case (' '):
+ strncpy(fn, "space", sizeof(fn));
+ break;
+ default: /* '9' falls here... */
+ ltr = fn2[num];
+ if ('A' <= ltr && ltr <= 'Z') ltr += 'a' - 'A'; /* file names are all lower-case */
+ snprintf(fn, sizeof(fn), "phonetic/%c", ltr);
+ }
+ /* snprintf(fn, sizeof(fn), "digits/%c", fn2[num]); */
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream_full(chan, ints, audiofd, ctrlfd);
Index: sounds.txt
===================================================================
RCS file: /usr/cvsroot/asterisk/sounds.txt,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- sounds.txt 29 Apr 2004 14:14:27 -0000 1.27
+++ sounds.txt 3 May 2004 00:54:15 -0000 1.28
@@ -478,3 +478,137 @@
%vm-reachoper.gsm%press 0 to reach an operator
%vm-tooshort.gsm%your message is too short
+
+%9_p.gsm%niner
+
+%a.gsm%a
+
+%b.gsm%b
+
+%c.gsm%c
+
+%d.gsm%d
+
+%e.gsm%e
+
+%f.gsm%f
+
+%g.gsm%g
+
+%h.gsm%h
+
+%i.gsm%i
+
+%j.gsm%j
+
+%k.gsm%k
+
+%l.gsm%l
+
+%m.gsm%m
+
+%n.gsm%n
+
+%o.gsm%o
+
+%p.gsm%p
+
+%q.gsm%q
+
+%r.gsm%r
+
+%s.gsm%s
+
+%t.gsm%t
+
+%u.gsm%u
+
+%v.gsm%v
+
+%w.gsm%w
+
+%x.gsm%x
+
+%y.gsm%y
+
+%z.gsm%z
+
+%zed.gsm%zed
+
+%a_p.gsm%alpha
+
+%b_p.gsm%bravo
+
+%c_p.gsm%charlie
+
+%d_p.gsm%delta
+
+%e_p.gsm%echo
+
+%f_p.gsm%foxtrot
+
+%g_p.gsm%golf
+
+%h_p.gsm%hotel
+
+%i_p.gsm%india
+
+%j_p.gsm%juliet
+
+%k_p.gsm%kilo
+
+%l_p.gsm%lima
+
+%m_p.gsm%mike
+
+%n_p.gsm%november
+
+%o_p.gsm%oscar
+
+%p_p.gsm%papa
+
+%q_p.gsm%quebec
+
+%r_p.gsm%romeo
+
+%s_p.gsm%sierra
+
+%t_p.gsm%tango
+
+%u_p.gsm%uniform
+
+%v_p.gsm%victor
+
+%w_p.gsm%wiskey
+
+%x_p.gsm%xray
+
+%y_p.gsm%yankee
+
+%z_p.gsm%zulu
+
+%niner.gsm%niner
+
+; Misc
+
+%percent.gsm%percent [%]
+
+%plus.gsm%plus [+]
+
+%exclaimation-point.gsm%exclaimation-point [!]
+
+%at.gsm%at [@]
+
+%dollar.gsm%dollar [$]
+
+%dash.gsm%dash [-]
+
+%dot.gsm%dot [.]
+
+%slash.gsm%slash [/]
+
+%space.gsm%space [ ]
+
+%plus.gsm%plus [+]
+
+%equals.gsm%equals [=]
More information about the svn-commits
mailing list