Skip to content

Commit 2ebb800

Browse files
authored
feat(qwen3-asr/CosyVoice-v3/tingwu agent): add API and parameters and sample code (#53)
1 parent b43a09e commit 2ebb800

File tree

6 files changed

+838
-0
lines changed

6 files changed

+838
-0
lines changed

dashscope/audio/tts_v2/speech_synthesizer.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ def __init__(
9898
volume=50,
9999
speech_rate=1.0,
100100
pitch_rate=1.0,
101+
seed=0,
102+
synthesis_type=0,
103+
instruction=None,
104+
language_hints: list = None,
101105
):
102106
self.task_id = self.genUid()
103107
self.apikey = apikey
@@ -109,6 +113,10 @@ def __init__(
109113
self.volume = volume
110114
self.speech_rate = speech_rate
111115
self.pitch_rate = pitch_rate
116+
self.seed = seed
117+
self.synthesis_type = synthesis_type
118+
self.instruction = instruction
119+
self.language_hints = language_hints
112120

113121
def genUid(self):
114122
# 生成随机UUID
@@ -156,13 +164,19 @@ def getStartRequest(self, additional_params=None):
156164
'rate': self.speech_rate,
157165
'format': self.format,
158166
'pitch': self.pitch_rate,
167+
'seed': self.seed,
168+
'type': self.synthesis_type
159169
},
160170
},
161171
}
162172
if self.format == 'opus':
163173
cmd['payload']['parameters']['bit_rate'] = self.bit_rate
164174
if additional_params:
165175
cmd['payload']['parameters'].update(additional_params)
176+
if self.instruction is not None:
177+
cmd['payload']['parameters']['instruction'] = self.instruction
178+
if self.language_hints is not None:
179+
cmd['payload']['parameters']['language_hints'] = self.language_hints
166180
return json.dumps(cmd)
167181

168182
def getContinueRequest(self, text):
@@ -207,6 +221,10 @@ def __init__(
207221
volume=50,
208222
speech_rate=1.0,
209223
pitch_rate=1.0,
224+
seed=0,
225+
synthesis_type=0,
226+
instruction=None,
227+
language_hints: list = None,
210228
headers=None,
211229
callback: ResultCallback = None,
212230
workspace=None,
@@ -237,6 +255,14 @@ def __init__(
237255
Dashscope workspace ID.
238256
url: str
239257
Dashscope WebSocket URL.
258+
seed: int
259+
The seed of the synthesizer, with a range from 0 to 65535. Default is 0.
260+
synthesis_type: int
261+
The type of the synthesizer, Default is 0.
262+
instruction: str
263+
The instruction of the synthesizer, max length is 128.
264+
language_hints: list
265+
The language hints of the synthesizer. supported language: zh, en.
240266
additional_params: Dict
241267
Additional parameters for the Dashscope API.
242268
"""
@@ -271,6 +297,10 @@ def __init__(
271297
volume=volume,
272298
speech_rate=speech_rate,
273299
pitch_rate=pitch_rate,
300+
seed=seed,
301+
synthesis_type=synthesis_type,
302+
instruction=instruction,
303+
language_hints=language_hints
274304
)
275305
self.last_request_id = self.request.task_id
276306
self.start_event = threading.Event()

dashscope/multimodal/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) Alibaba, Inc. and its affiliates.
2+
3+
from .tingwu import tingwu
4+
from .tingwu.tingwu import TingWu
5+
from .tingwu.tingwu_realtime import TingWuRealtime, TingWuRealtimeCallback
6+
7+
from .multimodal_dialog import MultiModalDialog, MultiModalCallback
8+
from .dialog_state import DialogState
9+
from .multimodal_constants import *
10+
from .multimodal_request_params import *
11+
12+
__all__ = [
13+
'tingwu',
14+
'TingWu',
15+
'TingWuRealtime',
16+
'TingWuRealtimeCallback',
17+
'MultiModalDialog',
18+
'MultiModalCallback',
19+
'DialogState'
20+
]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) Alibaba, Inc. and its affiliates.
2+
3+
from .tingwu import TingWu
4+
from .tingwu_realtime import TingWuRealtime, TingWuRealtimeCallback
5+
6+
__all__ = [
7+
'TingWu',
8+
'TingWuRealtime',
9+
'TingWuRealtimeCallback'
10+
]

0 commit comments

Comments
 (0)