[Freeswitch-svn] [commit] r5908 - freeswitch/trunk/src

Freeswitch SVN anthm at freeswitch.org
Tue Oct 16 14:49:56 EDT 2007


Author: anthm
Date: Tue Oct 16 14:49:56 2007
New Revision: 5908

Modified:
   freeswitch/trunk/src/switch_ivr_play_say.c

Log:
make variable to override what tts says for # and *

Modified: freeswitch/trunk/src/switch_ivr_play_say.c
==============================================================================
--- freeswitch/trunk/src/switch_ivr_play_say.c	(original)
+++ freeswitch/trunk/src/switch_ivr_play_say.c	Tue Oct 16 14:49:56 2007
@@ -1202,7 +1202,9 @@
 	uint32_t rate = 0;
 	int extra = 0;
 	char *p, *tmp = NULL;
-
+	char *star, *pound;
+	switch_size_t starlen, poundlen;
+	
 	channel = switch_core_session_get_channel(session);
 	assert(channel != NULL);
 
@@ -1218,12 +1220,22 @@
 	len = sh->samples * 2;
 	
 	flags = 0;
-	//switch_sleep(200000);
+	
+	if (!(star = switch_channel_get_variable(channel, "star_replace"))) {
+		star = "star";
+	}
+	if (!(pound = switch_channel_get_variable(channel, "pound_replace"))) {
+		pound = "pound";
+	}
+	starlen = strlen(star);
+	poundlen = strlen(pound);
+
+
 	for(p = text; p && *p; p++) {
 		if (*p == '*') {
-			extra += 4;
+			extra += starlen;
 		} else if (*p == '#') {
-			extra += 5;
+			extra += poundlen;
 		}
 	}
 
@@ -1231,24 +1243,20 @@
 		char *tp;
 		switch_size_t mylen = strlen(text) + extra + 1;
 		tmp = malloc(mylen);
+		memset(tmp, 0, mylen);
 		tp = tmp;
 		for (p = text; p && *p; p++) {
 			if (*p == '*') {
-				*tp++ = 's';
-				*tp++ = 't';
-				*tp++ = 'a';
-				*tp++ = 'r';
+				strncat(tp, star, starlen);
+				tp += starlen;
 			} else  if (*p == '#') {
-				*tp++ = 'p';
-				*tp++ = 'o';
-				*tp++ = 'u';
-				*tp++ = 'n';
-				*tp++ = 'd';
+				strncat(tp, pound, poundlen);
+				tp += poundlen;
 			} else {
 				*tp++ = *p;
 			}
 		}
-		*tp = '\0';
+		
 		text = tmp;
 	}
 



More information about the Freeswitch-svn mailing list