From 8807c5561e1c945aa21ff9f261fd0a25393d7cce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=81=A5=E4=BB=99?= Date: Wed, 28 Jan 2026 11:13:33 +0800 Subject: [PATCH] feat(model/qwen3-tts-realtime):support instruct param, update audio ws connection auth config bear -> Bear --- dashscope/audio/qwen_omni/omni_realtime.py | 2 +- .../audio/qwen_tts_realtime/qwen_tts_realtime.py | 12 +++++++++++- dashscope/audio/tts_v2/speech_synthesizer.py | 2 +- dashscope/multimodal/multimodal_dialog.py | 6 ++++-- dashscope/multimodal/tingwu/tingwu_realtime.py | 6 ++++-- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/dashscope/audio/qwen_omni/omni_realtime.py b/dashscope/audio/qwen_omni/omni_realtime.py index 22ec9cf..c0723f5 100644 --- a/dashscope/audio/qwen_omni/omni_realtime.py +++ b/dashscope/audio/qwen_omni/omni_realtime.py @@ -168,7 +168,7 @@ def _get_websocket_header(self): ) headers = { "user-agent": ua, - "Authorization": "bearer " + self.apikey, + "Authorization": "Bearer " + self.apikey, } if self.user_headers: headers = {**self.user_headers, **headers} diff --git a/dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py b/dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py index 0bb9dcd..ee06d98 100644 --- a/dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py +++ b/dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py @@ -120,7 +120,7 @@ def _get_websocket_header(self): ) headers = { "user-agent": ua, - "Authorization": "bearer " + self.apikey, + "Authorization": "Bearer " + self.apikey, } if self.user_headers: headers = {**self.user_headers, **headers} @@ -177,6 +177,8 @@ def update_session( bit_rate: int = None, language_type: str = None, enable_tn: bool = None, + instructions: str = None, + optimize_instructions: bool = None, **kwargs, ) -> None: """ @@ -206,6 +208,10 @@ def update_session( bit_rate for tts, support 6~510,default is 128kbps. only work on format: opus/mp3 # noqa: E501 # pylint: disable=line-too-long enable_tn: bool enable text normalization for tts, default is None + instructions: str + instructions for tts, default is None + optimize_instructions: bool + optimize_instructions for tts, default is None """ self.config = { "voice": voice, @@ -230,6 +236,10 @@ def update_session( if language_type is not None: self.config["language_type"] = language_type + if instructions is not None: + self.config["instructions"] = instructions + if optimize_instructions is not None: + self.config["optimize_instructions"] = optimize_instructions self.config.update(kwargs) self.__send_str( json.dumps( diff --git a/dashscope/audio/tts_v2/speech_synthesizer.py b/dashscope/audio/tts_v2/speech_synthesizer.py index c981368..66a2013 100644 --- a/dashscope/audio/tts_v2/speech_synthesizer.py +++ b/dashscope/audio/tts_v2/speech_synthesizer.py @@ -147,7 +147,7 @@ def getWebsocketHeaders(self, headers, workspace): ) self.headers = { "user-agent": ua, - "Authorization": "bearer " + self.apikey, + "Authorization": "Bearer " + self.apikey, } if headers: self.headers = {**self.headers, **headers} diff --git a/dashscope/multimodal/multimodal_dialog.py b/dashscope/multimodal/multimodal_dialog.py index 10a40f3..f7ed847 100644 --- a/dashscope/multimodal/multimodal_dialog.py +++ b/dashscope/multimodal/multimodal_dialog.py @@ -445,10 +445,12 @@ def get_websocket_header(self, api_key): ) self.ws_headers = { "User-Agent": ua, - "Authorization": f"bearer {api_key}", + "Authorization": f"Bearer {api_key}", "Accept": "application/json", } - logger.info("websocket header: %s", self.ws_headers) + log_headers = self.ws_headers.copy() + log_headers["Authorization"] = "REDACTED" + logger.info("websocket header: %s", log_headers) return self.ws_headers def generate_start_request( diff --git a/dashscope/multimodal/tingwu/tingwu_realtime.py b/dashscope/multimodal/tingwu/tingwu_realtime.py index ea8775c..9e2c3dc 100644 --- a/dashscope/multimodal/tingwu/tingwu_realtime.py +++ b/dashscope/multimodal/tingwu/tingwu_realtime.py @@ -345,10 +345,12 @@ def get_websocket_header(self, api_key): ) self.ws_headers = { "User-Agent": ua, - "Authorization": f"bearer {api_key}", + "Authorization": f"Bearer {api_key}", "Accept": "application/json", } - logger.info("websocket header: %s", self.ws_headers) + log_headers = self.ws_headers.copy() + log_headers["Authorization"] = "REDACTED" + logger.info("websocket header: %s", log_headers) return self.ws_headers def generate_start_request(