AS AgentScopeAPI 手册 / API Reference
类class agentscope.tts

DashScopeRealtimeTTSModel

class DashScopeRealtimeTTSModel(TTSModelBase)
源码Source agentscope/tts/_dashscope/_realtime_model.py:184–468

DashScope 实时 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
typeLiteral['dashscope_realtime_tts']
类型字段。
'dashscope_realtime_tts'
realtimebool
实时字段。
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.

参数Parameters
名称Name类型Type说明Description
credentialDashScopeCredentialDashScope 凭证。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 Truebool流(类型 `bool`)。Whether :meth:`synthesize` returns a streaming async generator.
cold_start_length默认default Noneint | Nonecold 启动长度(类型 `int | None`)。Minimum character count before the first text chunk is sent.
cold_start_words默认default Noneint | Nonecold 启动 words(类型 `int | None`)。Minimum word count before the first text chunk is sent.
max_retries默认default 3int最大重试次数(类型 `int`)。Max retry attempts on WebSocket failure.
retry_delay默认default 5.0float重试延迟(类型 `float`)。Initial retry delay in seconds (exponential backoff).
源码Source 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.

源码Source agentscope/tts/_dashscope/_realtime_model.py:205

realtime

bool = True

实时字段。声明为 bool。

The realtime field.

源码Source agentscope/tts/_dashscope/_realtime_model.py:207

方法详情Method Detail

connect

async def connect() -> None
async

建立连接并完成初始化。

Establish the WebSocket connection.

返回Returns None
无返回值。No value is returned.
源码Source agentscope/tts/_dashscope/_realtime_model.py:272–283

close

async def close() -> None
async

关闭连接并释放相关资源。

Close the WebSocket connection.

返回Returns None
无返回值。No value is returned.
源码Source agentscope/tts/_dashscope/_realtime_model.py:285–293

push

async def push(text: str, **kwargs: Any) -> TTSResponse
async

执行推送相关操作。

Push an incremental text delta for realtime synthesis.

参数Parameters
名称Name类型Type说明Description
textstr文本(类型 `str`)。An incremental text chunk (delta) to append.
kwargsAny关键字参数(类型 `Any`)。The kwargs.
返回Returns TTSResponse
返回TTSResponse。`TTSResponse`:
源码Source agentscope/tts/_dashscope/_realtime_model.py:306–363

synthesize

async def synthesize(text: str | None = None, **kwargs: Any) -> TTSResponse | AsyncGenerator[TTSResponse, None]
async

执行 synthesize 方法。

If text was previously pushed via :meth:push, this flushes any remaining buffered text, commits, and waits for audio.

参数Parameters
名称Name类型Type说明Description
text默认default Nonestr | None文本(类型 `str | None`)。Optional additional text to append before finalizing. If `None`, finalizes previously pushed text.
kwargsAny关键字参数(类型 `Any`)。The kwargs.
返回Returns TTSResponse | AsyncGenerator[TTSResponse, None]
返回TTSResponse|AsyncGenerator[TTSResponse,None]。`TTSResponse | AsyncGenerator[TTSResponse, None]`:
源码Source 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.

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.