Skip to content

Commit 4f78e6b

Browse files
songguocolakevinlin09
authored andcommitted
feat(model/qwen3-tts-realtime):support instruct param, update audio ws connection auth config bear -> Bear
1 parent 86b1527 commit 4f78e6b

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

dashscope/audio/qwen_omni/omni_realtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ def _get_websocket_header(self):
168168
)
169169
headers = {
170170
"user-agent": ua,
171-
"Authorization": "bearer " + self.apikey,
171+
"Authorization": "Bearer " + self.apikey,
172172
}
173173
if self.user_headers:
174174
headers = {**self.user_headers, **headers}

dashscope/audio/qwen_tts_realtime/qwen_tts_realtime.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def _get_websocket_header(self):
120120
)
121121
headers = {
122122
"user-agent": ua,
123-
"Authorization": "bearer " + self.apikey,
123+
"Authorization": "Bearer " + self.apikey,
124124
}
125125
if self.user_headers:
126126
headers = {**self.user_headers, **headers}
@@ -177,6 +177,8 @@ def update_session(
177177
bit_rate: int = None,
178178
language_type: str = None,
179179
enable_tn: bool = None,
180+
instructions: str = None,
181+
optimize_instructions: bool = None,
180182
**kwargs,
181183
) -> None:
182184
"""
@@ -206,6 +208,10 @@ def update_session(
206208
bit_rate for tts, support 6~510,default is 128kbps. only work on format: opus/mp3 # noqa: E501 # pylint: disable=line-too-long
207209
enable_tn: bool
208210
enable text normalization for tts, default is None
211+
instructions: str
212+
instructions for tts, default is None
213+
optimize_instructions: bool
214+
optimize_instructions for tts, default is None
209215
"""
210216
self.config = {
211217
"voice": voice,
@@ -230,6 +236,10 @@ def update_session(
230236

231237
if language_type is not None:
232238
self.config["language_type"] = language_type
239+
if instructions is not None:
240+
self.config["instructions"] = instructions
241+
if optimize_instructions is not None:
242+
self.config["optimize_instructions"] = optimize_instructions
233243
self.config.update(kwargs)
234244
self.__send_str(
235245
json.dumps(

dashscope/audio/tts_v2/speech_synthesizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def getWebsocketHeaders(self, headers, workspace):
147147
)
148148
self.headers = {
149149
"user-agent": ua,
150-
"Authorization": "bearer " + self.apikey,
150+
"Authorization": "Bearer " + self.apikey,
151151
}
152152
if headers:
153153
self.headers = {**self.headers, **headers}

dashscope/multimodal/multimodal_dialog.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,12 @@ def get_websocket_header(self, api_key):
445445
)
446446
self.ws_headers = {
447447
"User-Agent": ua,
448-
"Authorization": f"bearer {api_key}",
448+
"Authorization": f"Bearer {api_key}",
449449
"Accept": "application/json",
450450
}
451-
logger.info("websocket header: %s", self.ws_headers)
451+
log_headers = self.ws_headers.copy()
452+
log_headers["Authorization"] = "REDACTED"
453+
logger.info("websocket header: %s", log_headers)
452454
return self.ws_headers
453455

454456
def generate_start_request(

dashscope/multimodal/tingwu/tingwu_realtime.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,12 @@ def get_websocket_header(self, api_key):
345345
)
346346
self.ws_headers = {
347347
"User-Agent": ua,
348-
"Authorization": f"bearer {api_key}",
348+
"Authorization": f"Bearer {api_key}",
349349
"Accept": "application/json",
350350
}
351-
logger.info("websocket header: %s", self.ws_headers)
351+
log_headers = self.ws_headers.copy()
352+
log_headers["Authorization"] = "REDACTED"
353+
logger.info("websocket header: %s", log_headers)
352354
return self.ws_headers
353355

354356
def generate_start_request(

0 commit comments

Comments
 (0)