File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4545 PitchCommand ,
4646 RateCommand ,
4747 VolumeCommand ,
48+ BaseProsodyCommand
4849)
50+ from speech .types import SpeechSequence
4951
5052
5153class 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 ('\\ ' ,'\\ \\ ' ))
You can’t perform that action at this time.
0 commit comments