Skip to content

Commit ee2ef6d

Browse files
authored
Merge 5a8d539 into 69c8c5b
2 parents 69c8c5b + 5a8d539 commit ee2ef6d

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

source/synthDrivers/sapi4.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@
4545
PitchCommand,
4646
RateCommand,
4747
VolumeCommand,
48+
BaseProsodyCommand
4849
)
50+
from speech.types import SpeechSequence
4951

5052

5153
class SynthDriverBufSink(COMObject):
@@ -124,14 +126,23 @@ def __init__(self):
124126
def terminate(self):
125127
self._bufSink._allowDelete = True
126128

127-
def speak(self,speechSequence):
129+
def speak(self, speechSequence: SpeechSequence):
128130
textList=[]
129131
charMode=False
130132
item=None
131133
oldPitch = self.pitch
132134
oldVolume = self.volume
133135
oldRate = self.rate
134-
136+
prosodyInSequence = (type(i) for i in speechSequence if isinstance(i, BaseProsodyCommand))
137+
if prosodyInSequence :
138+
# #15500: Some SAPI4 voices reset all prosody when they receive any prosody command.
139+
# Therefore, we add all default values to the start of the sequence.
140+
prosodyToAdd = [
141+
c() for c in self.supportedCommands
142+
if issubclass(c, BaseProsodyCommand)
143+
and c not in prosodyInSequence
144+
]
145+
speechSequence = prosodyToAdd + speechSequence
135146
for item in speechSequence:
136147
if isinstance(item,str):
137148
textList.append(item.replace('\\','\\\\'))

0 commit comments

Comments
 (0)