speechd-discuss
[Top][All Lists]
Advanced

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

[PATCH 2/2] src/modules/ibmtts.c: enable the punctuation filter.


From: Christopher Brannon
Subject: [PATCH 2/2] src/modules/ibmtts.c: enable the punctuation filter.
Date: Sat, 4 Sep 2010 02:22:29 -0500

This patch comes from the Voxin package.
It fixes issues with punctuation.
For example, it is now possible to use the "some" punctuation mode
with the IBMTTS module.

I assume that the original author of this patch is Gilles Casse,
since he distributes Voxin.
---
 src/modules/ibmtts.c |   35 ++++++++++++++++++++++++++++++-----
 1 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/src/modules/ibmtts.c b/src/modules/ibmtts.c
index 6e62c25..af23f36 100644
--- a/src/modules/ibmtts.c
+++ b/src/modules/ibmtts.c
@@ -253,6 +253,7 @@ static void ibmtts_set_language_and_voice(char *lang, 
EVoiceType voice, char* di
 static void ibmtts_set_synthesis_voice(char *);
 static void ibmtts_set_rate(signed int rate);
 static void ibmtts_set_pitch(signed int pitch);
+static void ibmtts_set_punctuation_mode(EPunctMode punct_mode);
 static void ibmtts_set_volume(signed int pitch);
 
 /* Internal function prototypes for synthesis thread. */
@@ -300,6 +301,7 @@ MOD_OPTION_1_INT(IbmttsMaxChunkLength);
 MOD_OPTION_1_STR(IbmttsDelimiters);
 
 MOD_OPTION_1_INT(IbmttsUseSSML);
+MOD_OPTION_1_STR(IbmttsPunctuationList);
 MOD_OPTION_1_INT(IbmttsUseAbbreviation);
 MOD_OPTION_1_INT(IbmttsAudioChunkSize);
 MOD_OPTION_1_STR(IbmttsSoundIconFolder);
@@ -375,6 +377,7 @@ module_load(void)
        
     MOD_OPTION_1_INT_REG(IbmttsUseSSML, 1);
     MOD_OPTION_1_INT_REG(IbmttsUseAbbreviation, 1);
+    MOD_OPTION_1_STR_REG(IbmttsPunctuationList, "()?");
 
     MOD_OPTION_1_INT_REG(IbmttsAudioChunkSize, 20000);
     MOD_OPTION_1_STR_REG(IbmttsSoundIconFolder, 
"/usr/share/sounds/sound-icons/");
@@ -457,10 +460,17 @@ module_init(char **status_info)
 
     eciSetParam (eciHandle, eciDictionary, !IbmttsUseAbbreviation);
 
+    /* enable annotations */
     eciSetParam (eciHandle, eciInputType, 1);
+
     /* load possibly the ssml filter */
     eciAddText(eciHandle, " `gfa1 ");
 
+    /* load possibly the punctuation filter */
+    eciAddText(eciHandle, " `gfa2 "); 
+
+    ibmtts_set_punctuation_mode(msg_settings.punctuation_mode);
+
     alloc_voice_list();
 
     /* These mutexes are locked when the corresponding threads are suspended. 
*/
@@ -586,8 +596,9 @@ module_speak(gchar *data, size_t bytes, EMessageType 
msgtype)
     UPDATE_PARAMETER(rate, ibmtts_set_rate);
     UPDATE_PARAMETER(volume, ibmtts_set_volume);
     UPDATE_PARAMETER(pitch, ibmtts_set_pitch);
+    UPDATE_PARAMETER(punctuation_mode, ibmtts_set_punctuation_mode);
+
     /* TODO: Handle these in _ibmtts_synth() ?
-    UPDATE_PARAMETER(punctuation_mode, festival_set_punctuation_mode);
     UPDATE_PARAMETER(cap_let_recogn, festival_set_cap_let_recogn);
     */
 
@@ -983,10 +994,6 @@ _ibmtts_synth(void* nothing)
             }
 
             /* TODO: How to map these msg_settings to ibm tts?
-                EPunctMode punctuation_mode;
-                    PUNCT_NONE = 0,
-                    PUNCT_ALL = 1,
-                    PUNCT_SOME = 2
                 ESpellMode spelling_mode;
                     SPELLING_ON already handled in module_speak()
                 ECapLetRecogn cap_let_recogn;
@@ -1095,6 +1102,19 @@ ibmtts_set_pitch(signed int pitch)
         DBG("Ibmtts: Pitch set to %i.", pitchBaseline);
 }
 
+static void
+ibmtts_set_punctuation_mode(EPunctMode punct_mode)
+{
+    const char* fmt = "`Pf%d%s";
+    size_t len = strlen(fmt) + strlen(IbmttsPunctuationList) + sizeof('\0');
+    char* msg = malloc(len);
+
+    if (msg) {
+        snprintf(msg, len, fmt, punct_mode, IbmttsPunctuationList);
+        eciAddText(eciHandle, msg);
+        free(msg);
+    }
+}
 
 static char*
 ibmtts_voice_enum_to_str(EVoiceType voice)
@@ -1708,3 +1728,8 @@ free_voice_list()
 
 
 #include "module_main.c"
+
+/* local variables: */
+/* c-basic-offset: 4 */
+/* indent-tabs-mode: nil */
+/* end: */
-- 
1.7.2.2




reply via email to

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