@@ -181,7 +181,34 @@ def speak(self,speechSequence):
181
181
elif isinstance (item ,speech .CharacterModeCommand ):
182
182
outlist .append ((_ibmeci .speak , (b"`ts1" if item .state else b"`ts0" ,)))
183
183
elif isinstance (item ,speech .BreakCommand ):
184
- outlist .append ((_ibmeci .speak , (b' `p%d ' % item .time * 3 ,)))
184
+ # taken from eloquence_threshold (https://github.com/pumper42nickel/eloquence_threshold)
185
+ # Eloquence doesn't respect delay time in milliseconds.
186
+ # Therefore we need to adjust waiting time depending on current speech rate
187
+ # The following table of adjustments has been measured empirically
188
+ # Then we do linear approximation
189
+ coefficients = {
190
+ 10 :1 ,
191
+ 43 :2 ,
192
+ 60 :3 ,
193
+ 75 :4 ,
194
+ 85 :5 ,
195
+ }
196
+ ck = sorted (coefficients .keys ())
197
+ if self .rate <= ck [0 ]:
198
+ factor = coefficients [ck [0 ]]
199
+ elif self .rate >= ck [- 1 ]:
200
+ factor = coefficients [ck [- 1 ]]
201
+ elif self .rate in ck :
202
+ factor = coefficients [self .rate ]
203
+ else :
204
+ li = [index for index , r in enumerate (ck ) if r < self .rate ][- 1 ]
205
+ ri = li + 1
206
+ ra = ck [li ]
207
+ rb = ck [ri ]
208
+ factor = 1.0 * coefficients [ra ] + (coefficients [rb ] - coefficients [ra ]) * (self .rate - ra ) / (rb - ra )
209
+ pFactor = factor * item .time
210
+ pFactor = int (pFactor )
211
+ outlist .append ((_ibmeci .speak , (b' `p%d ' % (pFactor ),)))
185
212
elif type (item ) in self .PROSODY_ATTRS :
186
213
val = max (0 , min (item .newValue , 100 ))
187
214
if type (item ) == speech .RateCommand : val = self .percentToRate (val )
0 commit comments