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

GeminiTTSModel

class GeminiTTSModel(TTSModelBase)
源码Source agentscope/tts/_gemini/_model.py:51–329

Gemini TTS 模型,处理低延迟的实时语音与多模态交互。位于 agentscope.tts 包,继承自 TTSModelBase。核心成员包括 synthesize。

Gemini TTS model implementation using the generateContent API with responseModalities: ["AUDIO"]. Declared in agentscope.tts. Extends TTSModelBase.

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Parameters类class
参数,处理低延迟的实时语音与多模态交互。
Frontend-exposed parameters for Gemini TTS models.

构造器摘要Constructor Summary

构造器Constructor说明Description
def __init__(credential: GeminiCredential, model: str = 'gemini-2.5-flash-preview-tts', parameters: 'GeminiTTSModel.Par…
初始化 `GeminiTTSModel` 实例。
Initialize the Gemini TTS model.

属性摘要Attribute Summary

属性Attribute类型Type说明Description值Value
typeLiteral['gemini_tts']
类型字段。
'gemini_tts'
realtimebool
实时字段。
False

方法摘要Method Summary

方法Method说明Description
async def synthesize(text: str | None = None, **kwargs: Any) -> TTSResponse | AsyncGenerator[TTSResponse, None]async
执行 `synthesize` 方法。
Call the Gemini TTS API to synthesize speech from text.

构造器详情Constructor Detail

GeminiTTSModel

def __init__(credential: GeminiCredential, model: str = 'gemini-2.5-flash-preview-tts', parameters: 'GeminiTTSModel.Parameters | None' = None, stream: bool = False, client_kwargs: dict[str, Any] | None = None) -> None

初始化 GeminiTTSModel 实例。

Initialize the Gemini TTS model.

说明Notes

  • 注意:该行为受运行时配置或底层实现影响,建议结合对应源码与版本说明确认。Note: More details about the parameters, such as `model` and `voice`, can be found in the `official document `_.
参数Parameters
名称Name类型Type说明Description
credentialGeminiCredential凭证对象(类型 `GeminiCredential`)。The Google Gemini credential used to authenticate the API call.
model默认default 'gemini-2.5-flash-preview-tts'str模型实例(类型 `str`)。The TTS model name. Supported models include `gemini-2.5-flash-preview-tts` and `gemini-2.5-pro-preview-tts`.
parameters默认default None'GeminiTTSModel.Parameters | None'参数(类型 `'GeminiTTSModel.Parameters | None'`)。The TTS parameters (voice, etc.). When `None`, the default parameters will be used.
stream默认default Falsebool流(类型 `bool`)。Whether to use streaming output. When `True`, :meth:`synthesize` returns an async generator yielding incremental `TTSResponse` chunks (see the `streaming document `_); when `False`, it returns a single aggregated `TTSResponse`.
client_kwargs默认default Nonedict[str, Any] | None客户端关键字参数(类型 `dict[str, Any] | None`)。Extra keyword arguments forwarded to `google.genai.Client` (e.g. `vertexai`, `project`, `location`, `credentials`, `http_options`).
源码Source agentscope/tts/_gemini/_model.py:72–117

属性详情Attribute Detail

type

Literal['gemini_tts'] = 'gemini_tts'

类型字段。声明为 Literal['gemini_tts']。

The type field.

源码Source agentscope/tts/_gemini/_model.py:67

realtime

bool = False

实时字段。声明为 bool。

The realtime field.

源码Source agentscope/tts/_gemini/_model.py:70

方法详情Method Detail

synthesize

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

执行 synthesize 方法。

Call the Gemini TTS API to synthesize speech from text.

参数Parameters
名称Name类型Type说明Description
text默认default Nonestr | None文本(类型 `str | None`)。The text to be synthesized.
kwargsAny关键字参数(类型 `Any`)。The kwargs.
返回Returns TTSResponse | AsyncGenerator[TTSResponse, None]
返回TTSResponse|AsyncGenerator[TTSResponse,None]。`TTSResponse | AsyncGenerator[TTSResponse, None]`:
源码Source agentscope/tts/_gemini/_model.py:119–179

嵌套类详情Nested Class Detail

Parameters

class Parameters

参数,处理低延迟的实时语音与多模态交互。位于 agentscope.tts 包。

Frontend-exposed parameters for Gemini 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.