add pause to punctuation

This commit is contained in:
chrys 2016-10-18 11:27:26 +02:00
parent b36d19ca78
commit bf7598723a
3 changed files with 15 additions and 9 deletions

View File

@ -8,19 +8,20 @@ some:===:.-$~+*-/\\@
most:===:.,:-$~+*-/\\@!#%^&*()[]}{<>; most:===:.,:-$~+*-/\\@!#%^&*()[]}{<>;
all:===:!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ 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] [punctDict]
&:===:and &:===:and
':===:apostrophe ':===:apostrophe
@:===:at @:===:at
\:===:backslash \:===:backslash
|:===:bar |:===:bar
!:===:bang !:===:bang!
^:===:carrot ^:===:carrot
::===:colon ::===:colon:
,:===:comma ,:===:comma,
-:===:dash -:===:dash
$:===:dollar $:===:dollar
.:===:dot .:===:dot.
>:===:greater >:===:greater
`:===:grave `:===:grave
#:===:hash #:===:hash
@ -30,12 +31,12 @@ $:===:dollar
<:===:less <:===:less
%:===:percent %:===:percent
+:===:plus +:===:plus
?:===:question ?:===:question?
":===:quote ":===:quote
):===:right paren ):===:right paren
}:===:right brace }:===:right brace
]:===:right bracket ]:===:right bracket
;:===:semicolon ;:===:semicolon;
/:===:slash /:===:slash
*:===:star *:===:star
~:===:tilde ~:===:tilde

View File

@ -13,10 +13,13 @@ class punctuationManager():
def initialize(self, environment): def initialize(self, environment):
self.env = environment self.env = environment
self.allPunctNone = dict.fromkeys(map(ord, string.punctuation +"§"), ' ') self.allPunctNone = dict.fromkeys(map(ord, string.punctuation +"§"), ' ')
# replace with space: # replace with None:
# dot, comma, grave, apostrophe # grave, apostrophe
for char in [ord('.'),ord(','),ord('`'),ord("'")]: for char in [ord('`'),ord("'")]:
self.allPunctNone[char] = None 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): def shutdown(self):
pass pass

View File

@ -15,6 +15,7 @@ class driver():
try: try:
import speechd import speechd
self._sd = speechd.SSIPClient('fenrir') self._sd = speechd.SSIPClient('fenrir')
self._punct = speechd.PunctuationMode()
self._isInitialized = True self._isInitialized = True
except: except:
self._initialized = False self._initialized = False
@ -34,6 +35,7 @@ class driver():
if queueable == False: self.cancel() if queueable == False: self.cancel()
try: try:
self._sd.set_synthesis_voice(self._language) self._sd.set_synthesis_voice(self._language)
self._sd.set_punctuation(self._punct.NONE)
except: except:
pass pass
self._sd.speak(text) self._sd.speak(text)