From bf7598723a7ea220a3b9b1800f549db631285f69 Mon Sep 17 00:00:00 2001 From: chrys Date: Tue, 18 Oct 2016 11:27:26 +0200 Subject: [PATCH] add pause to punctuation --- config/punctuation/default.conf | 13 +++++++------ src/fenrir/core/punctuationManager.py | 9 ++++++--- src/fenrir/speechDriver/speechd.py | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/config/punctuation/default.conf b/config/punctuation/default.conf index 5cd85478..11fff1ab 100644 --- a/config/punctuation/default.conf +++ b/config/punctuation/default.conf @@ -8,19 +8,20 @@ some:===:.-$~+*-/\\@ most:===:.,:-$~+*-/\\@!#%^&*()[]}{<>; all:===:!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ +# the punctuation char in some cases are append to the words because they create a pause in TTS, the behaviour may differ between the synthesers [punctDict] &:===:and ':===:apostrophe @:===:at \:===:backslash |:===:bar -!:===:bang +!:===:bang! ^:===:carrot -::===:colon -,:===:comma +::===:colon: +,:===:comma, -:===:dash $:===:dollar -.:===:dot +.:===:dot. >:===:greater `:===:grave #:===:hash @@ -30,12 +31,12 @@ $:===:dollar <:===:less %:===:percent +:===:plus -?:===:question +?:===:question? ":===:quote ):===:right paren }:===:right brace ]:===:right bracket -;:===:semicolon +;:===:semicolon; /:===:slash *:===:star ~:===:tilde diff --git a/src/fenrir/core/punctuationManager.py b/src/fenrir/core/punctuationManager.py index eca809b6..a3f88250 100644 --- a/src/fenrir/core/punctuationManager.py +++ b/src/fenrir/core/punctuationManager.py @@ -13,10 +13,13 @@ class punctuationManager(): def initialize(self, environment): self.env = environment self.allPunctNone = dict.fromkeys(map(ord, string.punctuation +"ยง"), ' ') - # replace with space: - # dot, comma, grave, apostrophe - for char in [ord('.'),ord(','),ord('`'),ord("'")]: + # replace with None: + # grave, apostrophe + for char in [ord('`'),ord("'")]: self.allPunctNone[char] = None + # dont translate dot and comma because they create a pause + for char in [ord('.'),ord(',')]: + del self.allPunctNone[char] def shutdown(self): pass diff --git a/src/fenrir/speechDriver/speechd.py b/src/fenrir/speechDriver/speechd.py index 17e8c82a..bb709f88 100644 --- a/src/fenrir/speechDriver/speechd.py +++ b/src/fenrir/speechDriver/speechd.py @@ -15,6 +15,7 @@ class driver(): try: import speechd self._sd = speechd.SSIPClient('fenrir') + self._punct = speechd.PunctuationMode() self._isInitialized = True except: self._initialized = False @@ -34,6 +35,7 @@ class driver(): if queueable == False: self.cancel() try: self._sd.set_synthesis_voice(self._language) + self._sd.set_punctuation(self._punct.NONE) except: pass self._sd.speak(text)