Gemini TTS 插件接入语音代理与表现力模式
LiveKit 的 Gemini TTS 插件让语音代理把 Gemini 作为语音合成提供方。文档说明从 PyPI 安装插件,并介绍 gemini-3.8-flash-tts 等模型的表现力模式,由 LLM 标注回复、LiveKit 渲染情绪、语速、停顿和非语言声音。
LiveKit Docs QQ Building Agents QQ 合伙人聚光灯 Google Google 双子座 TTS --- # 双子座 TTS 插件指南 > 如何使用双子座TTS插件用于LiveKit代理. 可用(BETA): - [x] 节点.js - [x] Python 键 - **[用于代理构建器](https://cloud.livekit.io/projects/p_/agents/builder/new?tts=google%2Fgemini-3.8-flash-tts)**: 在浏览器中使用 google/ gemini-3.8 - flash- tts 创建新代理 ## 概览 此插件允许您使用 [双子座 TTS](https://ai.google.dev/gemini-api/docs/speech-generation) 作为您的语音代理的TTS提供商. ### 安装 从 PyPI 安装插件 : **Python 键**: ```shell uv add "livekit-agents[google]~=1.8" ``` --- **节点.js**: ```shell pnpm add @livekit/agents-plugin-google@1.x ``` ### 认证 全权证书必须以下列方法之一提供: - 对于Vertex AI,您必须设置 `GOOGLE_APPLICATION_CREDENTIALS` 服务账户密钥文件路径的环境变量 。 更多关于向 LiveKit Cloud 部署时将文件装入为机密的信息, 请参见 [文件挂载的机密](https://docs.livekit.io/deploy/agents/secrets.md#file-mounted-secrets). - 要使用双子座 API : 设置 `api_key` 参数或 `GOOGLE_API_KEY` 环境变量。 ### 使用量 在一个双子体 TTS 中使用 `AgentSession` 或作为独立的语音生成器。例如,您可以使用此功能TTS输入 [语音 AI 快速启动](https://docs.livekit.io/agents/start/voice-ai.md). **Python 键**: ```python from livekit.agents import AgentSession from livekit.plugins import google session = AgentSession( tts=google.beta.GeminiTTS( model="gemini-3.8-flash-tts", voice_name="Zephyr", instructions="Speak in a friendly and engaging tone.", ), # ... llm, stt, etc. ) ``` --- **节点.js**: ```typescript import * as google from '@livekit/agents-plugin-google'; import { voice } from '@livekit/agents'; const session = new voice.AgentSession({ tts: new google.beta.TTS({ model: 'gemini-3.8-flash-tts', voiceName: 'Zephyr', instructions: 'Speak in a friendly and engaging tone.', }), // ... llm, stt, etc. }); ``` ### 参数 本节描述一些可用的参数。请参看该页中的插件引用链接 [追加资源](#additional-resources) 区域,用于完整列出所有可用的参数。 - **`model`** _(字符串)_(可选) - 默认 : `gemini-3.1-flash-tts-preview`: 用于语音生成的模型。关于模型列表,请参见 [支持的模型](https://ai.google.dev/gemini-api/docs/speech-generation#supported-models). - **`voice_name`** _(字符串)_(可选) - 默认 : `Kore`: 用于合成语音的预建声音。对于支持的声音,请参见 [语音选项](https://ai.google.dev/gemini-api/docs/speech-generation#voices)。在 Node.js 中,这个参数叫做 `voiceName`. - **`instructions`** _(字符串)_(可选的): 迅速控制样式、语气、重音和节奏。要学习更多,请看 [用提示控制语音样式](https://ai.google.dev/gemini-api/docs/speech-generation#controllable)。默认为 `Say the text with a proper tone, don't omit or add any words`. - **`customPronunciations`** _(CustomPronunciations)_(可选):在: - [x] 节点.js - [ ] Python 键 双子座模型的读音指令。通过一个带有 a 的对象 `pronunciations` 数组,每个条目指定一个 `phrase`, `pronunciation`选择性 `phoneticEncoding`。这些指示的格式是连同语音生成请求一起发送给双子座模型的即时文本。 ```typescript const tts = new google.beta.TTS({ model: 'gemini-3.8-flash-tts', voiceName: 'Aoede', customPronunciations: { pronunciations: [ { phrase: 'LiveKit', pronunciation: 'Live Kit', }, { phrase: 'gRPC', pronunciation: 'gee arr pee see', phoneticEncoding: 'IPA', // optional }, ], }, }); ``` ## 表达式 双子座 `gemini-3.8-flash-tts` 财务报告和财务报告 `gemini-3.8-flash-lite-tts` 与工作关系 [表达式](https://docs.livekit.io/agents/models/tts/expressive.md),其中LLM标记了它的答复,而LiveKit使交付成为了一种情感基调. 双子座设置了一种情绪基调,调整了节奏,插入了暂停,并产生了诸如笑声和叹息等非口头声音. `lk.expression` 属性用于您的前端。 打开它 `expressive=True` 在你身边 `AgentSession`。为了调整交付,见 [自定义](https://docs.livekit.io/agents/models/tts/expressive.md#customization). ## 追加资源 以下资源提供更多关于使用双子座TTS与LiveKit Agents的信息. - **[表达式](https://docs.livekit.io/agents/models/tts/expressive.md)**:让LLM在双子座演讲中自动加入情感,节奏,以及非口头声音. - **[双子座 TTS 文档](https://ai.google.dev/gemini-api/docs/speech-generation)**:双子座开发者API Docs用于TTS. - **[语音 AI 快速启动](https://docs.livekit.io/agents/start/voice-ai.md)**:从LiveKit特工和双子座TTS开始. - **[谷歌生态系统指南](https://docs.livekit.io/agents/integrations/google.md)**: Google AI和LiveKit代理集成的全集成概况. --- 这份文件是在2026 - 12-01T03:04:40.580Z. 本文件的最新版本见: [https://docs.livekit.io/agents/models/tts/gemini.md](https://docs.livekit.io/agents/models/tts/gemini.md). 要探索所有 LiveKit 文档,请参见 [页:1](https://docs.livekit.io/llms.txt).
查看原始来源