Skip to content

Commit 094435d

Browse files
committed
fix:streaming_cancel change for cosyvoice
1 parent 8484e4a commit 094435d

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

dashscope/audio/tts_v2/speech_synthesizer.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,11 @@ def streaming_cancel(self, complete_timeout_millis=10000):
686686
Parameters:
687687
-----------
688688
complete_timeout_millis: int
689-
Throws TimeoutError exception if it times out waiting for the
690-
server's task-finished message. If the timeout is not None and
691-
greater than zero, it will wait for the corresponding number of
692-
milliseconds; otherwise, it will wait indefinitely.
689+
If it times out waiting for the server's task-finished message,
690+
the connection is force-closed and a warning is logged. If the
691+
timeout is not None and greater than zero, it will wait for the
692+
corresponding number of milliseconds; otherwise, it will wait
693+
indefinitely.
693694
"""
694695

695696
if not self._is_started:
@@ -707,10 +708,13 @@ def streaming_cancel(self, complete_timeout_millis=10000):
707708
"after cancel timeout %sms, force closing.",
708709
complete_timeout_millis,
709710
)
711+
self.close()
712+
elif self._close_ws_after_use:
713+
self.close()
710714
else:
711715
self.complete_event.wait()
712-
if self._close_ws_after_use:
713-
self.close()
716+
if self._close_ws_after_use:
717+
self.close()
714718
self._stopped.set()
715719
self._is_started = False
716720

0 commit comments

Comments
 (0)