speechd-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Fix punctuation handling in the ibmtts module.


From: Christopher Brannon
Subject: [PATCH] Fix punctuation handling in the ibmtts module.
Date: Thu, 31 Mar 2011 17:22:10 +0000

We were sending the wrong value for the punctuation mode when the
user selected "all punctuation" or "some punctuation".
Now, we send the correct value in all cases.

Also, the function is simplified slightly, as g_malloc + snprintf is
replaced with a single call to g_strdup_printf.
---
 src/modules/ibmtts.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index 55955bf..1371ff3 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -1110,14 +1110,24 @@ static void ibmtts_set_pitch(signed int pitch)
 static void ibmtts_set_punctuation_mode(SPDPunctuation punct_mode)
 {
        const char *fmt = "`Pf%d%s";
-       size_t len = strlen(fmt) + strlen(IbmttsPunctuationList) + sizeof('\0');
-       char *msg = g_malloc(len);
+       char *msg = NULL;
+       int real_punct_mode = 0;
 
-       if (msg) {
-               snprintf(msg, len, fmt, punct_mode, IbmttsPunctuationList);
-               eciAddText(eciHandle, msg);
-               g_free(msg);
+       switch (punct_mode) {
+       case SPD_PUNCT_NONE:
+               real_punct_mode = 0;
+               break;
+       case SPD_PUNCT_SOME:
+               real_punct_mode = 2;
+               break;
+       case SPD_PUNCT_ALL:
+               real_punct_mode = 1;
+               break;
        }
+
+       msg = g_strdup_printf(fmt, real_punct_mode, IbmttsPunctuationList);
+       eciAddText(eciHandle, msg);
+       g_free(msg);
 }
 
 static char *ibmtts_voice_enum_to_str(SPDVoiceType voice)
-- 
1.7.3.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]