agentscope.ttsDashScopeRealtimeTTSModel
class DashScopeRealtimeTTSModel(TTSModelBase)
agentscope/tts/_dashscope/_realtime_model.py:184–468DashScope 实时 TTS 模型,处理低延迟的实时语音与多模态交互。位于 agentscope.tts 包,继承自 TTSModelBase。核心成员包括 connect、close、push、synthesize。
This model supports streaming input: text can be pushed incrementally
via :meth:push, and :meth:synthesize finalizes the current utterance.
For more details see the official document
<https://bailian.console.aliyun.com/?tab=doc#/doc/?type=model&url=2938790>_.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Parameters | 类class | 参数,处理低延迟的实时语音与多模态交互。 Frontend-exposed parameters for DashScope Realtime TTS models. |
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
def __init__(credential: DashScopeCredential, model: str = 'qwen3-tts-flash-realtime', parameters: 'DashScopeRealtimeTT… | 初始化 `DashScopeRealtimeTTSModel` 实例。 Initialize the DashScope Realtime TTS model. |
属性摘要Attribute Summary
| 属性Attribute | 类型Type | 说明Description | 值Value |
|---|---|---|---|
type | Literal['dashscope_realtime_tts'] | 类型字段。 | 'dashscope_realtime_tts' |
realtime | bool | 实时字段。 | True |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
async def connect() -> Noneasync | 建立连接并完成初始化。 Establish the WebSocket connection. |
async def close() -> Noneasync | 关闭连接并释放相关资源。 Close the WebSocket connection. |
async def push(text: str, **kwargs: Any) -> TTSResponseasync | 执行推送相关操作。 Push an incremental text delta for realtime synthesis. |
async def synthesize(text: str | None = None, **kwargs: Any) -> TTSResponse | AsyncGenerator[TTSResponse, None]async | 执行 `synthesize` 方法。 Finalize synthesis for the current utterance. |
构造器详情Constructor Detail
DashScopeRealtimeTTSModel
def __init__(credential: DashScopeCredential, model: str = 'qwen3-tts-flash-realtime', parameters: 'DashScopeRealtimeTTSModel.Parameters | None' = None, stream: bool = True, cold_start_length: int | None = None, cold_start_words: int | None = None, max_retries: int = 3, retry_delay: float = 5.0) -> None
初始化 DashScopeRealtimeTTSModel 实例。
Initialize the DashScope Realtime TTS model.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
credential | DashScopeCredential | DashScope 凭证。The DashScope credential. |
model默认default 'qwen3-tts-flash-realtime' | str | 实时 TTS 模型名称。The realtime TTS model name. |
parameters默认default None | 'DashScopeRealtimeTTSModel.Parameters | None' | 参数(类型 `'DashScopeRealtimeTTSModel.Parameters | None'`)。The TTS parameters (voice, etc.). |
stream默认default True | bool | 流(类型 `bool`)。Whether :meth:`synthesize` returns a streaming async generator. |
cold_start_length默认default None | int | None | cold 启动长度(类型 `int | None`)。Minimum character count before the first text chunk is sent. |
cold_start_words默认default None | int | None | cold 启动 words(类型 `int | None`)。Minimum word count before the first text chunk is sent. |
max_retries默认default 3 | int | 最大重试次数(类型 `int`)。Max retry attempts on WebSocket failure. |
retry_delay默认default 5.0 | float | 重试延迟(类型 `float`)。Initial retry delay in seconds (exponential backoff). |
agentscope/tts/_dashscope/_realtime_model.py:209–256属性详情Attribute Detail
type
Literal['dashscope_realtime_tts'] = 'dashscope_realtime_tts'类型字段。声明为 Literal['dashscope_realtime_tts']。
The type field.
agentscope/tts/_dashscope/_realtime_model.py:205realtime
bool = True实时字段。声明为 bool。
The realtime field.
agentscope/tts/_dashscope/_realtime_model.py:207方法详情Method Detail
connect
async def connect() -> None
建立连接并完成初始化。
Establish the WebSocket connection.
agentscope/tts/_dashscope/_realtime_model.py:272–283close
async def close() -> None
关闭连接并释放相关资源。
Close the WebSocket connection.
agentscope/tts/_dashscope/_realtime_model.py:285–293push
async def push(text: str, **kwargs: Any) -> TTSResponse
执行推送相关操作。
Push an incremental text delta for realtime synthesis.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | str | 文本(类型 `str`)。An incremental text chunk (delta) to append. |
kwargs | Any | 关键字参数(类型 `Any`)。The kwargs. |
agentscope/tts/_dashscope/_realtime_model.py:306–363synthesize
async def synthesize(text: str | None = None, **kwargs: Any) -> TTSResponse | AsyncGenerator[TTSResponse, None]
执行 synthesize 方法。
If text was previously pushed via :meth:push, this flushes any remaining buffered text, commits, and waits for audio.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text默认default None | str | None | 文本(类型 `str | None`)。Optional additional text to append before finalizing. If `None`, finalizes previously pushed text. |
kwargs | Any | 关键字参数(类型 `Any`)。The kwargs. |
agentscope/tts/_dashscope/_realtime_model.py:365–462嵌套类详情Nested Class Detail
Parameters
class Parameters参数,处理低延迟的实时语音与多模态交互。位于 agentscope.tts 包。
Frontend-exposed parameters for DashScope Realtime TTS models. Declared in agentscope.tts.