@@ -46,14 +46,15 @@ def unicode(s):
46
46
re .compile (r'(\w+)\.([a-zA-Z]+)' ): r'\1 dot \2' ,
47
47
re .compile (r'([a-zA-Z0-9_]+)@(\w+)' ): r'\1 at \2' ,
48
48
}
49
+
49
50
french_fixes = { re .compile (r'([a-zA-Z0-9_]+)@(\w+)' ): r'\1 arobase \2' }
51
+
50
52
spanish_fixes = {
51
53
#for emails
52
54
re .compile (r'([a-zA-Z0-9_]+)@(\w+)' ): r'\1 arroba \2' ,
53
55
re .compile (u'([€$]\d{1,3})((\s\d{3})+\.\d{2})' ): r'\1 \2' ,
54
56
}
55
57
56
-
57
58
variants = {
58
59
1 :"Reed" ,
59
60
2 :"Shelley" ,
@@ -132,20 +133,19 @@ def __init__(self):
132
133
self .variant = "1"
133
134
134
135
PROSODY_ATTRS = {
135
- speech .PitchCommand : b'vb' ,
136
- speech .VolumeCommand : b'vv' ,
137
- speech .RateCommand : b'vs' ,
136
+ speech .PitchCommand : ECIVoiceParam . eciPitchBaseline ,
137
+ speech .VolumeCommand : ECIVoiceParam . eciVolume ,
138
+ speech .RateCommand : ECIVoiceParam . eciSpeed ,
138
139
}
139
140
140
141
def speak (self ,speechSequence ):
141
142
last = None
142
143
defaultLanguage = self .language
143
144
outlist = []
144
- outlist .append ((_ibmeci .speak , (b' `ts0 `pp0 `vb%d `vs%d `vv%d ' % ( self . pitch , _ibmeci . getVParam ( ECIVoiceParam . eciSpeed ), self . volume ) ,)))
145
+ outlist .append ((_ibmeci .speak , (b" `ts0" ,)))
145
146
for item in speechSequence :
146
147
if isinstance (item , string_types ):
147
148
s = self .processText (unicode (item ))
148
- if not s : continue
149
149
outlist .append ((_ibmeci .speak , (s ,)))
150
150
last = s
151
151
elif isinstance (item ,speech .IndexCommand ):
@@ -168,10 +168,10 @@ def speak(self,speechSequence):
168
168
elif type (item ) in self .PROSODY_ATTRS :
169
169
val = max (0 , min (item .newValue , 100 ))
170
170
if type (item ) == speech .RateCommand : val = self .percentToRate (val )
171
- outlist .append ((_ibmeci .speak , (b' `%s%d ' % ( self .PROSODY_ATTRS [type (item )], val ), )))
171
+ outlist .append ((_ibmeci .setProsodyParam , (self .PROSODY_ATTRS [type (item )], val )))
172
172
else :
173
- log .error ("Unknown speech: %s" % item )
174
- if last and str (last [- 1 ]) not in punctuation : outlist .append ((_ibmeci .speak , (b'`p1. ' ,)))
173
+ log .error ("Unknown speech: %s" % item )
174
+ if last is not None and not str (last [- 1 ]) in punctuation : outlist .append ((_ibmeci .speak , (b'`p1. ' ,)))
175
175
outlist .append ((_ibmeci .setEndStringMark , ()))
176
176
outlist .append ((_ibmeci .synth , ()))
177
177
_ibmeci .eciQueue .put (outlist )
@@ -185,19 +185,20 @@ def processText(self,text):
185
185
text = resub (french_fixes , text )
186
186
text = text .replace ('quil' , 'qil' ) #Sometimes this string make everything buggy with IBMTTS in French
187
187
if self ._backquoteVoiceTags :
188
- text = text .replace ('`' , ' ' ) #no embedded commands
189
- text = text .encode ('mbcs' , 'replace' )
190
- text = resub (anticrash_res , text )
191
188
#this converts to ansi for anticrash. If this breaks with foreign langs, we can remove it.
189
+ text = text .replace ('`' , ' ' ).encode ('mbcs' , 'replace' ) #no embedded commands
190
+ text = b"`pp0 `vv%d %s" % (_ibmeci .getVParam (ECIVoiceParam .eciVolume ), text )
191
+ text = resub (anticrash_res , text )
192
192
else :
193
193
#this converts to ansi for anticrash. If this breaks with foreign langs, we can remove it.
194
194
text = text .encode ('mbcs' , 'replace' )
195
- text = text .replace (b'`' , b' ' ) #no embedded commands
196
195
text = resub (anticrash_res , text )
196
+ text = b"`pp0 `vv%d %s" % (_ibmeci .getVParam (ECIVoiceParam .eciVolume ), text .replace (b'`' , b' ' )) #no embedded commands
197
197
text = pause_re .sub (br'\1 `p1\2\3' , text )
198
198
text = time_re .sub (br'\1:\2 \3' , text )
199
199
return text
200
200
201
+
201
202
def pause (self ,switch ):
202
203
_ibmeci .pause (switch )
203
204
@@ -224,7 +225,6 @@ def _set_rateBoost(self, enable):
224
225
self ._rateBoost = enable
225
226
self .rate = rate
226
227
227
-
228
228
def _get_rate (self ):
229
229
val = _ibmeci .getVParam (ECIVoiceParam .eciSpeed )
230
230
if self ._rateBoost : val = int (round (val / self .RATE_BOOST_MULTIPLIER ))
0 commit comments