livekit-plugins-volcengine 1.2.9__tar.gz → 1.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- livekit_plugins_volcengine-1.3.0/PKG-INFO +586 -0
- livekit_plugins_volcengine-1.3.0/README.md +563 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/realtime.py +7 -3
- livekit_plugins_volcengine-1.3.0/livekit/plugins/volcengine/version.py +1 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/pyproject.toml +1 -1
- livekit_plugins_volcengine-1.2.9/PKG-INFO +0 -80
- livekit_plugins_volcengine-1.2.9/README.md +0 -57
- livekit_plugins_volcengine-1.2.9/livekit/plugins/volcengine/version.py +0 -1
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/.gitignore +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/__init__.py +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/bigmodel_stt.py +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/llm.py +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/log.py +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/py.typed +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/stt.py +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/tts.py +0 -0
- {livekit_plugins_volcengine-1.2.9 → livekit_plugins_volcengine-1.3.0}/livekit/plugins/volcengine/utils.py +0 -0
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: livekit-plugins-volcengine
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: LiveKit Agent Plugins for Volcengine
|
|
5
|
+
Author-email: wangmengdi <790990241@qq.com>
|
|
6
|
+
Keywords: audio,livekit,realtime,video,webrtc
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
14
|
+
Classifier: Topic :: Multimedia :: Video
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.9
|
|
17
|
+
Requires-Dist: livekit-agents==1.2.9
|
|
18
|
+
Requires-Dist: numpy
|
|
19
|
+
Requires-Dist: openai>=1.75.0
|
|
20
|
+
Requires-Dist: osc-data==0.2.2
|
|
21
|
+
Requires-Dist: pydantic
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# livekit-plugins-volcengine
|
|
25
|
+
|
|
26
|
+
[](https://pypi.org/project/livekit-plugins-volcengine/)
|
|
27
|
+
[](https://www.python.org/downloads/)
|
|
28
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
29
|
+
|
|
30
|
+
火山引擎服务专用的 [LiveKit Agents](https://github.com/livekit/agents) 插件,提供完整的语音和语言模型集成解决方案。
|
|
31
|
+
|
|
32
|
+
## ✨ 特性
|
|
33
|
+
|
|
34
|
+
- 🎤 **语音识别 (STT)** - 支持火山引擎语音识别服务
|
|
35
|
+
- 🗣️ **语音合成 (TTS)** - 支持火山引擎文本转语音服务
|
|
36
|
+
- 🤖 **大语言模型 (LLM)** - 支持豆包大模型系列
|
|
37
|
+
- 🎯 **大模型语音识别 (BigModelSTT)** - 增强版语音识别服务
|
|
38
|
+
- ⚡ **实时语音模型 (Realtime)** - 端到端实时语音交互
|
|
39
|
+
- 🔧 **简单集成** - 与 LiveKit Agents 框架无缝集成
|
|
40
|
+
- 📦 **开箱即用** - 完整的 Python 包支持
|
|
41
|
+
|
|
42
|
+
## 📋 支持的服务
|
|
43
|
+
|
|
44
|
+
| 服务 | 描述 | 文档链接 |
|
|
45
|
+
|------|------|----------|
|
|
46
|
+
| TTS | 文本转语音 | [语音合成](https://www.volcengine.com/docs/6561/79817) |
|
|
47
|
+
| STT | 语音识别 | [语音识别](https://www.volcengine.com/docs/6561/80818) |
|
|
48
|
+
| BigModelSTT | 大模型语音识别 | [大模型语音识别](https://www.volcengine.com/docs/6561/1354869) |
|
|
49
|
+
| LLM | 大语言模型 | [流式调用](https://www.volcengine.com/docs/82379/1298454) |
|
|
50
|
+
| Realtime | 实时语音模型 | [实时语音](https://www.volcengine.com/docs/6561/1594356) |
|
|
51
|
+
|
|
52
|
+
## 🛠️ 安装
|
|
53
|
+
|
|
54
|
+
### 使用 pip 安装
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install livekit-plugins-volcengine
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 从源码安装
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
git clone https://github.com/your-repo/livekit-plugins-volcengine.git
|
|
64
|
+
cd livekit-plugins-volcengine
|
|
65
|
+
pip install -e .
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### 系统要求
|
|
69
|
+
|
|
70
|
+
- Python >= 3.9
|
|
71
|
+
- LiveKit Agents >= 1.2.9
|
|
72
|
+
|
|
73
|
+
## ⚙️ 配置
|
|
74
|
+
|
|
75
|
+
### 环境变量
|
|
76
|
+
|
|
77
|
+
在使用插件前,请配置以下环境变量:
|
|
78
|
+
|
|
79
|
+
| 环境变量 | 描述 | 获取方式 |
|
|
80
|
+
|----------|------|----------|
|
|
81
|
+
| `VOLCENGINE_TTS_ACCESS_TOKEN` | TTS 服务的访问令牌 | [语音合成控制台](https://console.volcengine.com/speech/service/16) |
|
|
82
|
+
| `VOLCENGINE_STT_ACCESS_TOKEN` | STT 服务的访问令牌 | [语音识别控制台](https://console.volcengine.com/speech/service/16) |
|
|
83
|
+
| `VOLCENGINE_LLM_API_KEY` | LLM 服务的 API 密钥 | [大模型控制台](https://console.volcengine.com/ark/) |
|
|
84
|
+
| `VOLCENGINE_REALTIME_ACCESS_TOKEN` | 实时服务的访问令牌 | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
|
|
85
|
+
|
|
86
|
+
### .env 文件示例
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# .env
|
|
90
|
+
VOLCENGINE_TTS_ACCESS_TOKEN=your_tts_token_here
|
|
91
|
+
VOLCENGINE_STT_ACCESS_TOKEN=your_stt_token_here
|
|
92
|
+
VOLCENGINE_LLM_API_KEY=your_llm_api_key_here
|
|
93
|
+
VOLCENGINE_REALTIME_ACCESS_TOKEN=your_realtime_token_here
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 📖 使用指南
|
|
97
|
+
|
|
98
|
+
### 基础使用
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
102
|
+
from livekit.plugins import volcengine
|
|
103
|
+
from dotenv import load_dotenv
|
|
104
|
+
|
|
105
|
+
async def entry_point(ctx: JobContext):
|
|
106
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
107
|
+
|
|
108
|
+
# 使用实时语音模型
|
|
109
|
+
llm = volcengine.RealtimeModel(
|
|
110
|
+
app_id="your_app_id",
|
|
111
|
+
access_token="your_access_token",
|
|
112
|
+
bot_name="智能助手",
|
|
113
|
+
model="O" # 或 "SC"
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
session = AgentSession(llm=llm)
|
|
117
|
+
|
|
118
|
+
await session.start(agent=agent, room=ctx.room)
|
|
119
|
+
await ctx.connect()
|
|
120
|
+
|
|
121
|
+
if __name__ == "__main__":
|
|
122
|
+
load_dotenv()
|
|
123
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 大模型语音识别
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
130
|
+
from livekit.plugins import volcengine
|
|
131
|
+
from dotenv import load_dotenv
|
|
132
|
+
|
|
133
|
+
async def entry_point(ctx: JobContext):
|
|
134
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
135
|
+
|
|
136
|
+
# 使用大模型语音识别
|
|
137
|
+
stt = volcengine.BigModelSTT(app_id="your_app_id")
|
|
138
|
+
|
|
139
|
+
session = AgentSession(
|
|
140
|
+
stt=stt,
|
|
141
|
+
tts=volcengine.TTS(app_id="your_tts_app_id", cluster="your_cluster"),
|
|
142
|
+
llm=volcengine.LLM(model="doubao-1-5-pro-32k-250115")
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
await session.start(agent=agent, room=ctx.room)
|
|
146
|
+
await ctx.connect()
|
|
147
|
+
|
|
148
|
+
if __name__ == "__main__":
|
|
149
|
+
load_dotenv()
|
|
150
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 实时语音模型
|
|
154
|
+
|
|
155
|
+
实时语音模型提供端到端的全双工语音交互体验,支持实时语音识别、对话生成和语音合成。
|
|
156
|
+
|
|
157
|
+
#### 基础配置
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
161
|
+
from livekit.plugins import volcengine
|
|
162
|
+
from dotenv import load_dotenv
|
|
163
|
+
|
|
164
|
+
async def entry_point(ctx: JobContext):
|
|
165
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
166
|
+
|
|
167
|
+
# 基础实时语音模型配置
|
|
168
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
169
|
+
app_id="your_app_id",
|
|
170
|
+
access_token="your_access_token",
|
|
171
|
+
bot_name="豆包", # 机器人名称
|
|
172
|
+
model="O" # 默认使用O版本,功能全面
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
session = AgentSession(llm=realtime_llm)
|
|
176
|
+
|
|
177
|
+
await session.start(agent=agent, room=ctx.room)
|
|
178
|
+
await ctx.connect()
|
|
179
|
+
|
|
180
|
+
if __name__ == "__main__":
|
|
181
|
+
load_dotenv()
|
|
182
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
#### 高级配置
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
189
|
+
from livekit.plugins import volcengine
|
|
190
|
+
from dotenv import load_dotenv
|
|
191
|
+
|
|
192
|
+
# 自定义RAG函数
|
|
193
|
+
def rag_function(transcription: str) -> str:
|
|
194
|
+
"""自定义RAG函数,用于增强模型回复"""
|
|
195
|
+
# 根据用户输入返回相关的上下文信息
|
|
196
|
+
return '[{"title":"相关信息","content":"这是相关的背景知识"}]'
|
|
197
|
+
|
|
198
|
+
async def entry_point(ctx: JobContext):
|
|
199
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
200
|
+
|
|
201
|
+
# 高级配置 - 包含网络搜索和RAG功能
|
|
202
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
203
|
+
app_id="your_app_id",
|
|
204
|
+
access_token="your_access_token",
|
|
205
|
+
bot_name="智能助手",
|
|
206
|
+
model="O", # O版本支持联网搜索和RAG,SC版本专注角色扮演
|
|
207
|
+
enable_volc_websearch=True, # 启用联网搜索
|
|
208
|
+
volc_websearch_api_key="your_websearch_api_key",
|
|
209
|
+
rag_fn=rag_function, # 自定义RAG函数
|
|
210
|
+
speaking_style="专业、友好、耐心",
|
|
211
|
+
system_role="你是一个专业的AI助手,擅长解答各种问题。"
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
session = AgentSession(llm=realtime_llm)
|
|
215
|
+
|
|
216
|
+
await session.start(agent=agent, room=ctx.room)
|
|
217
|
+
await ctx.connect()
|
|
218
|
+
|
|
219
|
+
if __name__ == "__main__":
|
|
220
|
+
load_dotenv()
|
|
221
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
#### 模型版本对比
|
|
225
|
+
|
|
226
|
+
火山引擎实时语音模型提供两个不同的版本,各有独特的功能特点:
|
|
227
|
+
|
|
228
|
+
##### O版本 (标准功能版)
|
|
229
|
+
```python
|
|
230
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
231
|
+
model="O", # 标准功能版,功能全面
|
|
232
|
+
# ... 其他配置
|
|
233
|
+
)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**核心功能:**
|
|
237
|
+
- 🌐 **内置联网搜索**:支持实时网络信息检索和查询
|
|
238
|
+
- 🧠 **外部RAG支持**:支持外部知识库检索、总结和口语化改写
|
|
239
|
+
- 🎵 **精品音色**:支持 vv、xiaohe、yunzhou、xiaotian 等高品质音色
|
|
240
|
+
- ⚙️ **SP开放配置**:支持 bot_name、system_role、speaking_style 等参数配置
|
|
241
|
+
- 🚫 **角色描述**:不支持 character_manifest 参数
|
|
242
|
+
- 🚫 **克隆音色**:不支持 ICL_ 或 S_ 开头的音色名称
|
|
243
|
+
|
|
244
|
+
**适用场景:**
|
|
245
|
+
- 需要联网搜索的应用
|
|
246
|
+
- 需要外部知识库集成的场景
|
|
247
|
+
- 对音质要求较高的应用
|
|
248
|
+
- 需要灵活参数配置的场景
|
|
249
|
+
|
|
250
|
+
##### SC版本 (角色增强版)
|
|
251
|
+
```python
|
|
252
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
253
|
+
model="SC", # 角色增强版,专注角色扮演
|
|
254
|
+
# ... 其他配置
|
|
255
|
+
)
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
**核心功能:**
|
|
259
|
+
- 🚫 **内置联网搜索**:不支持联网搜索功能
|
|
260
|
+
- 🚫 **外部RAG支持**:不支持外部RAG功能
|
|
261
|
+
- 🚫 **精品音色**:不支持 vv、xiaohe、yunzhou、xiaotian 等音色
|
|
262
|
+
- 🚫 **SP开放配置**:不支持 bot_name、system_role、speaking_style 参数
|
|
263
|
+
- 🎭 **角色描述**:支持 character_manifest 参数进行角色配置
|
|
264
|
+
- 🎤 **克隆音色**:支持 ICL_ 或 S_ 开头的克隆音色
|
|
265
|
+
|
|
266
|
+
**适用场景:**
|
|
267
|
+
- 专注于角色扮演的应用
|
|
268
|
+
- 需要使用克隆音色的场景
|
|
269
|
+
- 对角色个性化要求较高的应用
|
|
270
|
+
- 需要 character_manifest 配置的场景
|
|
271
|
+
|
|
272
|
+
#### 功能对比表格
|
|
273
|
+
|
|
274
|
+
| 功能特性 | O版本 | SC版本 |
|
|
275
|
+
|----------|-------|--------|
|
|
276
|
+
| 🌐 内置联网搜索 | ✅ | ❌ |
|
|
277
|
+
| 🧠 外部RAG总结和口语化改写 | ✅ | ❌ |
|
|
278
|
+
| 🎵 精品音色(vv、xiaohe、yunzhou、xiaotian) | ✅ | ❌ |
|
|
279
|
+
| ⚙️ SP开放配置(bot_name、system_role、speaking_style) | ✅ | ❌ |
|
|
280
|
+
| 🎭 角色描述(character_manifest) | ❌ | ✅ |
|
|
281
|
+
| 🎤 克隆音色(ICL_或S_开头) | ❌ | ✅ |
|
|
282
|
+
|
|
283
|
+
#### 版本选择建议
|
|
284
|
+
|
|
285
|
+
| 应用场景 | 推荐版本 | 主要原因 |
|
|
286
|
+
|----------|----------|----------|
|
|
287
|
+
| 智能客服 | O版本 | 需要联网搜索和灵活配置 |
|
|
288
|
+
| 教育辅导 | O版本 | 需要联网搜索和精品音质 |
|
|
289
|
+
| 角色扮演 | SC版本 | 专注于角色特性和克隆音色 |
|
|
290
|
+
| 娱乐应用 | O版本 | 需要联网搜索和多样音色 |
|
|
291
|
+
| 企业培训 | SC版本 | 需要角色定制和个性化 |
|
|
292
|
+
| 内容创作 | O版本 | 需要RAG和联网搜索功能 |
|
|
293
|
+
|
|
294
|
+
**使用建议:**
|
|
295
|
+
- **O版本**:功能更全面,适合大多数应用场景
|
|
296
|
+
- **SC版本**:专注于角色扮演,适合特定个性化需求
|
|
297
|
+
- 根据您的具体需求选择合适的版本
|
|
298
|
+
- 建议先测试两种版本,选择最符合需求的那一个
|
|
299
|
+
|
|
300
|
+
#### 角色配置 (SC版本)
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
304
|
+
from livekit.plugins import volcengine
|
|
305
|
+
from dotenv import load_dotenv
|
|
306
|
+
|
|
307
|
+
async def entry_point(ctx: JobContext):
|
|
308
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
309
|
+
|
|
310
|
+
# SC版本支持角色配置和克隆音色
|
|
311
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
312
|
+
app_id="your_app_id",
|
|
313
|
+
access_token="your_access_token",
|
|
314
|
+
bot_name="小智",
|
|
315
|
+
model="SC", # SC版本支持character_manifest
|
|
316
|
+
character_manifest='{ # JSON字符串格式的角色配置
|
|
317
|
+
"name": "小智",
|
|
318
|
+
"personality": "活泼开朗、聪明机智",
|
|
319
|
+
"background": "一个充满好奇心的AI助手"
|
|
320
|
+
}',
|
|
321
|
+
speaker="ICL_custom_voice", # SC版本支持克隆音色
|
|
322
|
+
speaking_style="活泼开朗,像个小伙伴一样和你聊天",
|
|
323
|
+
system_role="你叫小智,是一个活泼开朗的AI助手,喜欢用emoji表情,回复简洁有趣。"
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
session = AgentSession(llm=realtime_llm)
|
|
327
|
+
|
|
328
|
+
await session.start(agent=agent, room=ctx.room)
|
|
329
|
+
await ctx.connect()
|
|
330
|
+
|
|
331
|
+
if __name__ == "__main__":
|
|
332
|
+
load_dotenv()
|
|
333
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### 单独组件使用
|
|
337
|
+
|
|
338
|
+
如果您需要分别使用各个组件(STT、TTS、LLM),而不是使用集成的实时语音模型:
|
|
339
|
+
|
|
340
|
+
```python
|
|
341
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
342
|
+
from livekit.plugins import volcengine
|
|
343
|
+
from dotenv import load_dotenv
|
|
344
|
+
|
|
345
|
+
async def entry_point(ctx: JobContext):
|
|
346
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
347
|
+
|
|
348
|
+
session = AgentSession(
|
|
349
|
+
# 语音识别
|
|
350
|
+
stt=volcengine.STT(
|
|
351
|
+
app_id="your_stt_app_id",
|
|
352
|
+
cluster="your_cluster"
|
|
353
|
+
),
|
|
354
|
+
# 语音合成
|
|
355
|
+
tts=volcengine.TTS(
|
|
356
|
+
app_id="your_tts_app_id",
|
|
357
|
+
cluster="your_cluster",
|
|
358
|
+
voice_type="BV001_V2_streaming"
|
|
359
|
+
),
|
|
360
|
+
# 单独的LLM (非实时)
|
|
361
|
+
llm=volcengine.LLM(model="doubao-1-5-pro-32k-250115")
|
|
362
|
+
)
|
|
363
|
+
|
|
364
|
+
await session.start(agent=agent, room=ctx.room)
|
|
365
|
+
await ctx.connect()
|
|
366
|
+
|
|
367
|
+
if __name__ == "__main__":
|
|
368
|
+
load_dotenv()
|
|
369
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## 🔧 API 参考
|
|
373
|
+
|
|
374
|
+
### TTS (文本转语音)
|
|
375
|
+
|
|
376
|
+
```python
|
|
377
|
+
volcengine.TTS(
|
|
378
|
+
app_id: str, # 应用ID
|
|
379
|
+
cluster: str, # 集群ID
|
|
380
|
+
voice_type: str = "BV001_V2_streaming", # 语音类型
|
|
381
|
+
speed_ratio: float = 1.0, # 语速 (0.5-2.0)
|
|
382
|
+
volume_ratio: float = 1.0, # 音量 (0.1-3.0)
|
|
383
|
+
pitch_ratio: float = 1.0 # 音调 (0.5-2.0)
|
|
384
|
+
)
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### STT (语音识别)
|
|
388
|
+
|
|
389
|
+
```python
|
|
390
|
+
volcengine.STT(
|
|
391
|
+
app_id: str, # 应用ID
|
|
392
|
+
cluster: str, # 集群ID
|
|
393
|
+
language: str = "zh-CN" # 语言
|
|
394
|
+
)
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
### BigModelSTT (大模型语音识别)
|
|
398
|
+
|
|
399
|
+
```python
|
|
400
|
+
volcengine.BigModelSTT(
|
|
401
|
+
app_id: str, # 应用ID
|
|
402
|
+
cluster: str = "volcengine_streaming_common", # 集群
|
|
403
|
+
protocol: str = "http", # 协议
|
|
404
|
+
language: str = "zh-CN" # 语言
|
|
405
|
+
)
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### LLM (大语言模型)
|
|
409
|
+
|
|
410
|
+
```python
|
|
411
|
+
volcengine.LLM(
|
|
412
|
+
model: str, # 模型名称
|
|
413
|
+
temperature: float = 0.7, # 温度
|
|
414
|
+
max_tokens: int = 2000, # 最大token数
|
|
415
|
+
system_message: str = None # 系统消息
|
|
416
|
+
)
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### RealtimeModel (实时语音模型)
|
|
420
|
+
|
|
421
|
+
```python
|
|
422
|
+
volcengine.RealtimeModel(
|
|
423
|
+
# 必需参数
|
|
424
|
+
app_id: str = None, # 应用ID,从环境变量 VOLCENGINE_REALTIME_APP_ID 获取
|
|
425
|
+
access_token: str = None, # 访问令牌,从环境变量 VOLCENGINE_REALTIME_ACCESS_TOKEN 获取
|
|
426
|
+
|
|
427
|
+
# 基本配置
|
|
428
|
+
bot_name: str = "豆包", # 机器人名称
|
|
429
|
+
speaking_style: str = "你的说话风格简洁明了,语速适中,语调自然。", # 说话风格描述
|
|
430
|
+
speaker: str = "zh_female_vv_jupiter_bigtts", # 语音类型
|
|
431
|
+
opening: str = "你好啊,今天过得怎么样?", # 开场白内容
|
|
432
|
+
system_role: str = None, # 系统角色提示词
|
|
433
|
+
|
|
434
|
+
# 模型配置
|
|
435
|
+
model: Literal["O", "SC"] = "O", # 模型版本:O(标准功能版) 或 SC(角色增强版)
|
|
436
|
+
character_manifest: str = None, # 角色配置,JSON字符串格式
|
|
437
|
+
|
|
438
|
+
# 音频配置
|
|
439
|
+
sample_rate: int = 24000, # 采样率
|
|
440
|
+
num_channels: int = 1, # 声道数
|
|
441
|
+
format: str = "pcm", # 音频格式
|
|
442
|
+
|
|
443
|
+
# ASR配置
|
|
444
|
+
end_smooth_window_ms: int = 500, # 结束平滑窗口毫秒数
|
|
445
|
+
|
|
446
|
+
# 网络搜索配置
|
|
447
|
+
enable_volc_websearch: bool = False, # 是否启用网络搜索
|
|
448
|
+
volc_websearch_type: Literal["web_summary", "web"] = "web_summary", # 搜索类型
|
|
449
|
+
volc_websearch_api_key: str = None, # 网络搜索API密钥
|
|
450
|
+
volc_websearch_no_result_message: str = "抱歉,我找不到相关信息。", # 无结果提示
|
|
451
|
+
|
|
452
|
+
# RAG配置
|
|
453
|
+
rag_fn: Callable[[str], str] = None, # RAG回调函数,输入查询返回增强内容
|
|
454
|
+
|
|
455
|
+
# 其他配置
|
|
456
|
+
audio_output: bool = True, # 是否输出音频
|
|
457
|
+
modalities: List[Literal["text", "audio"]] = NOT_GIVEN, # 输出模态
|
|
458
|
+
http_session: aiohttp.ClientSession = None, # HTTP会话
|
|
459
|
+
max_session_duration: float = None, # 最大会话持续时间
|
|
460
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS # 连接选项
|
|
461
|
+
)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
## ❓ 常见问题
|
|
465
|
+
|
|
466
|
+
### Q: 如何获取访问令牌?
|
|
467
|
+
|
|
468
|
+
A: 请访问[火山引擎控制台](https://console.volcengine.com/),在相应服务页面创建应用并获取访问令牌。
|
|
469
|
+
|
|
470
|
+
### Q: 支持哪些语音类型?
|
|
471
|
+
|
|
472
|
+
A: 支持多种语音类型,包括 BV001_V2_streaming、BV002_V2_streaming 等,详见[语音合成文档](https://www.volcengine.com/docs/6561/97465)。
|
|
473
|
+
|
|
474
|
+
### Q: 如何处理连接错误?
|
|
475
|
+
|
|
476
|
+
A: 请检查网络连接和访问令牌是否正确配置。建议使用环境变量管理敏感信息。
|
|
477
|
+
|
|
478
|
+
### Q: 支持哪些大语言模型?
|
|
479
|
+
|
|
480
|
+
A: 支持豆包系列模型,包括 doubao-1-5-lite、doubao-1-5-pro 等,详见[大模型文档](https://www.volcengine.com/docs/82379/1513689)。
|
|
481
|
+
|
|
482
|
+
### Q: 实时语音模型支持哪些语音类型?
|
|
483
|
+
|
|
484
|
+
A: 实时语音模型支持多种预训练语音,包括:
|
|
485
|
+
- `zh_female_vv_jupiter_bigtts` - 女声 Jupiter 大模型语音
|
|
486
|
+
- `zh_male_vv_jupiter_bigtts` - 男声 Jupiter 大模型语音
|
|
487
|
+
- 其他火山引擎TTS支持的语音类型
|
|
488
|
+
|
|
489
|
+
### Q: 如何配置网络搜索功能?
|
|
490
|
+
|
|
491
|
+
A: 要启用网络搜索功能,需要设置以下参数:
|
|
492
|
+
```python
|
|
493
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
494
|
+
enable_volc_websearch=True,
|
|
495
|
+
volc_websearch_type="web_summary", # 或 "web"
|
|
496
|
+
volc_websearch_api_key="your_websearch_key"
|
|
497
|
+
)
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
### Q: 什么是RAG功能,如何使用?
|
|
501
|
+
|
|
502
|
+
A: RAG(Retrieval-Augmented Generation)可以为模型提供额外的上下文信息:
|
|
503
|
+
```python
|
|
504
|
+
def my_rag_function(query: str) -> str:
|
|
505
|
+
# 根据用户查询返回相关的上下文信息
|
|
506
|
+
return "相关的背景知识和信息"
|
|
507
|
+
|
|
508
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
509
|
+
rag_fn=my_rag_function
|
|
510
|
+
)
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
### Q: 实时语音模型和普通LLM/TTS的区别是什么?
|
|
514
|
+
|
|
515
|
+
A: 实时语音模型是端到端的解决方案:
|
|
516
|
+
- **集成度高**:语音识别、对话生成、语音合成一体化
|
|
517
|
+
- **实时性强**:支持全双工实时对话
|
|
518
|
+
- **智能化**:内置角色配置、网络搜索、RAG等高级功能
|
|
519
|
+
- **简单配置**:一个模型即可完成语音交互全流程
|
|
520
|
+
|
|
521
|
+
普通LLM+TTS组合需要分别配置和处理各个组件的数据流,而实时模型内部集成了这些功能。
|
|
522
|
+
|
|
523
|
+
### Q: 如何选择O版本和SC版本?
|
|
524
|
+
|
|
525
|
+
A: 根据您的应用需求选择合适的版本:
|
|
526
|
+
|
|
527
|
+
**选择O版本的情况:**
|
|
528
|
+
- 需要联网搜索功能的应用
|
|
529
|
+
- 需要外部RAG集成的场景
|
|
530
|
+
- 对音质要求较高,需要精品音色的应用
|
|
531
|
+
- 需要灵活配置bot_name、system_role、speaking_style的场景
|
|
532
|
+
- 大多数通用应用场景
|
|
533
|
+
|
|
534
|
+
**选择SC版本的情况:**
|
|
535
|
+
- 专注于角色扮演的应用
|
|
536
|
+
- 需要使用克隆音色(ICL_或S_开头)的场景
|
|
537
|
+
- 需要character_manifest进行角色配置的场景
|
|
538
|
+
- 对角色个性化要求较高的应用
|
|
539
|
+
|
|
540
|
+
**版本对比:**
|
|
541
|
+
- **O版本**:功能全面,适合大多数应用场景,支持联网搜索、RAG、精品音色等
|
|
542
|
+
- **SC版本**:专注于角色扮演,支持角色描述和克隆音色,但不支持联网搜索等功能
|
|
543
|
+
|
|
544
|
+
**使用建议:**
|
|
545
|
+
- 如果您的应用需要联网搜索、RAG或精品音色,选择O版本
|
|
546
|
+
- 如果您的应用专注于角色扮演和个性化音色,选择SC版本
|
|
547
|
+
- 建议根据具体需求测试两个版本,选择最合适的
|
|
548
|
+
|
|
549
|
+
## 📝 更新日志
|
|
550
|
+
|
|
551
|
+
### v1.2.9
|
|
552
|
+
- ✨ **新增实时语音模型**:支持端到端全双工语音交互
|
|
553
|
+
- 🎯 **增强大模型语音识别**:优化BigModelSTT性能和稳定性
|
|
554
|
+
- 🔧 **改进API设计**:RealtimeModel支持丰富的配置选项
|
|
555
|
+
- 🌐 **集成网络搜索**:支持实时网络信息检索和摘要
|
|
556
|
+
- 🧠 **RAG功能支持**:可配置检索增强生成回调函数
|
|
557
|
+
- 🎭 **角色配置系统**:支持自定义AI助手角色和性格
|
|
558
|
+
- 🔊 **多语音类型**:支持多种预训练语音模型
|
|
559
|
+
- 📚 **完善文档**:详细的使用指南和API参考
|
|
560
|
+
- 🐛 **修复已知问题**:提升整体稳定性和兼容性
|
|
561
|
+
|
|
562
|
+
## 🤝 贡献
|
|
563
|
+
|
|
564
|
+
欢迎提交 Issue 和 Pull Request!
|
|
565
|
+
|
|
566
|
+
1. Fork 本项目
|
|
567
|
+
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
568
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
569
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
570
|
+
5. 打开 Pull Request
|
|
571
|
+
|
|
572
|
+
## 📄 许可证
|
|
573
|
+
|
|
574
|
+
本项目采用 Apache 2.0 许可证 - 查看 [LICENSE](../LICENSE) 文件了解详情。
|
|
575
|
+
|
|
576
|
+
## 📞 联系我们
|
|
577
|
+
|
|
578
|
+
- 项目主页: [GitHub](https://github.com/your-repo/livekit-plugins-volcengine)
|
|
579
|
+
- 问题反馈: [Issues](https://github.com/your-repo/livekit-plugins-volcengine/issues)
|
|
580
|
+
- 邮箱: 790990241@qq.com
|
|
581
|
+
|
|
582
|
+
## 🙏 致谢
|
|
583
|
+
|
|
584
|
+
- [LiveKit](https://github.com/livekit/agents) - 优秀的实时通信框架
|
|
585
|
+
- [火山引擎](https://www.volcengine.com/) - 强大的AI服务提供商
|
|
586
|
+
|
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
# livekit-plugins-volcengine
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/livekit-plugins-volcengine/)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
[](https://opensource.org/licenses/Apache-2.0)
|
|
6
|
+
|
|
7
|
+
火山引擎服务专用的 [LiveKit Agents](https://github.com/livekit/agents) 插件,提供完整的语音和语言模型集成解决方案。
|
|
8
|
+
|
|
9
|
+
## ✨ 特性
|
|
10
|
+
|
|
11
|
+
- 🎤 **语音识别 (STT)** - 支持火山引擎语音识别服务
|
|
12
|
+
- 🗣️ **语音合成 (TTS)** - 支持火山引擎文本转语音服务
|
|
13
|
+
- 🤖 **大语言模型 (LLM)** - 支持豆包大模型系列
|
|
14
|
+
- 🎯 **大模型语音识别 (BigModelSTT)** - 增强版语音识别服务
|
|
15
|
+
- ⚡ **实时语音模型 (Realtime)** - 端到端实时语音交互
|
|
16
|
+
- 🔧 **简单集成** - 与 LiveKit Agents 框架无缝集成
|
|
17
|
+
- 📦 **开箱即用** - 完整的 Python 包支持
|
|
18
|
+
|
|
19
|
+
## 📋 支持的服务
|
|
20
|
+
|
|
21
|
+
| 服务 | 描述 | 文档链接 |
|
|
22
|
+
|------|------|----------|
|
|
23
|
+
| TTS | 文本转语音 | [语音合成](https://www.volcengine.com/docs/6561/79817) |
|
|
24
|
+
| STT | 语音识别 | [语音识别](https://www.volcengine.com/docs/6561/80818) |
|
|
25
|
+
| BigModelSTT | 大模型语音识别 | [大模型语音识别](https://www.volcengine.com/docs/6561/1354869) |
|
|
26
|
+
| LLM | 大语言模型 | [流式调用](https://www.volcengine.com/docs/82379/1298454) |
|
|
27
|
+
| Realtime | 实时语音模型 | [实时语音](https://www.volcengine.com/docs/6561/1594356) |
|
|
28
|
+
|
|
29
|
+
## 🛠️ 安装
|
|
30
|
+
|
|
31
|
+
### 使用 pip 安装
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install livekit-plugins-volcengine
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 从源码安装
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
git clone https://github.com/your-repo/livekit-plugins-volcengine.git
|
|
41
|
+
cd livekit-plugins-volcengine
|
|
42
|
+
pip install -e .
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 系统要求
|
|
46
|
+
|
|
47
|
+
- Python >= 3.9
|
|
48
|
+
- LiveKit Agents >= 1.2.9
|
|
49
|
+
|
|
50
|
+
## ⚙️ 配置
|
|
51
|
+
|
|
52
|
+
### 环境变量
|
|
53
|
+
|
|
54
|
+
在使用插件前,请配置以下环境变量:
|
|
55
|
+
|
|
56
|
+
| 环境变量 | 描述 | 获取方式 |
|
|
57
|
+
|----------|------|----------|
|
|
58
|
+
| `VOLCENGINE_TTS_ACCESS_TOKEN` | TTS 服务的访问令牌 | [语音合成控制台](https://console.volcengine.com/speech/service/16) |
|
|
59
|
+
| `VOLCENGINE_STT_ACCESS_TOKEN` | STT 服务的访问令牌 | [语音识别控制台](https://console.volcengine.com/speech/service/16) |
|
|
60
|
+
| `VOLCENGINE_LLM_API_KEY` | LLM 服务的 API 密钥 | [大模型控制台](https://console.volcengine.com/ark/) |
|
|
61
|
+
| `VOLCENGINE_REALTIME_ACCESS_TOKEN` | 实时服务的访问令牌 | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
|
|
62
|
+
|
|
63
|
+
### .env 文件示例
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# .env
|
|
67
|
+
VOLCENGINE_TTS_ACCESS_TOKEN=your_tts_token_here
|
|
68
|
+
VOLCENGINE_STT_ACCESS_TOKEN=your_stt_token_here
|
|
69
|
+
VOLCENGINE_LLM_API_KEY=your_llm_api_key_here
|
|
70
|
+
VOLCENGINE_REALTIME_ACCESS_TOKEN=your_realtime_token_here
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 📖 使用指南
|
|
74
|
+
|
|
75
|
+
### 基础使用
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
79
|
+
from livekit.plugins import volcengine
|
|
80
|
+
from dotenv import load_dotenv
|
|
81
|
+
|
|
82
|
+
async def entry_point(ctx: JobContext):
|
|
83
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
84
|
+
|
|
85
|
+
# 使用实时语音模型
|
|
86
|
+
llm = volcengine.RealtimeModel(
|
|
87
|
+
app_id="your_app_id",
|
|
88
|
+
access_token="your_access_token",
|
|
89
|
+
bot_name="智能助手",
|
|
90
|
+
model="O" # 或 "SC"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
session = AgentSession(llm=llm)
|
|
94
|
+
|
|
95
|
+
await session.start(agent=agent, room=ctx.room)
|
|
96
|
+
await ctx.connect()
|
|
97
|
+
|
|
98
|
+
if __name__ == "__main__":
|
|
99
|
+
load_dotenv()
|
|
100
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 大模型语音识别
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
107
|
+
from livekit.plugins import volcengine
|
|
108
|
+
from dotenv import load_dotenv
|
|
109
|
+
|
|
110
|
+
async def entry_point(ctx: JobContext):
|
|
111
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
112
|
+
|
|
113
|
+
# 使用大模型语音识别
|
|
114
|
+
stt = volcengine.BigModelSTT(app_id="your_app_id")
|
|
115
|
+
|
|
116
|
+
session = AgentSession(
|
|
117
|
+
stt=stt,
|
|
118
|
+
tts=volcengine.TTS(app_id="your_tts_app_id", cluster="your_cluster"),
|
|
119
|
+
llm=volcengine.LLM(model="doubao-1-5-pro-32k-250115")
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
await session.start(agent=agent, room=ctx.room)
|
|
123
|
+
await ctx.connect()
|
|
124
|
+
|
|
125
|
+
if __name__ == "__main__":
|
|
126
|
+
load_dotenv()
|
|
127
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 实时语音模型
|
|
131
|
+
|
|
132
|
+
实时语音模型提供端到端的全双工语音交互体验,支持实时语音识别、对话生成和语音合成。
|
|
133
|
+
|
|
134
|
+
#### 基础配置
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
138
|
+
from livekit.plugins import volcengine
|
|
139
|
+
from dotenv import load_dotenv
|
|
140
|
+
|
|
141
|
+
async def entry_point(ctx: JobContext):
|
|
142
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
143
|
+
|
|
144
|
+
# 基础实时语音模型配置
|
|
145
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
146
|
+
app_id="your_app_id",
|
|
147
|
+
access_token="your_access_token",
|
|
148
|
+
bot_name="豆包", # 机器人名称
|
|
149
|
+
model="O" # 默认使用O版本,功能全面
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
session = AgentSession(llm=realtime_llm)
|
|
153
|
+
|
|
154
|
+
await session.start(agent=agent, room=ctx.room)
|
|
155
|
+
await ctx.connect()
|
|
156
|
+
|
|
157
|
+
if __name__ == "__main__":
|
|
158
|
+
load_dotenv()
|
|
159
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
#### 高级配置
|
|
163
|
+
|
|
164
|
+
```python
|
|
165
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
166
|
+
from livekit.plugins import volcengine
|
|
167
|
+
from dotenv import load_dotenv
|
|
168
|
+
|
|
169
|
+
# 自定义RAG函数
|
|
170
|
+
def rag_function(transcription: str) -> str:
|
|
171
|
+
"""自定义RAG函数,用于增强模型回复"""
|
|
172
|
+
# 根据用户输入返回相关的上下文信息
|
|
173
|
+
return '[{"title":"相关信息","content":"这是相关的背景知识"}]'
|
|
174
|
+
|
|
175
|
+
async def entry_point(ctx: JobContext):
|
|
176
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
177
|
+
|
|
178
|
+
# 高级配置 - 包含网络搜索和RAG功能
|
|
179
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
180
|
+
app_id="your_app_id",
|
|
181
|
+
access_token="your_access_token",
|
|
182
|
+
bot_name="智能助手",
|
|
183
|
+
model="O", # O版本支持联网搜索和RAG,SC版本专注角色扮演
|
|
184
|
+
enable_volc_websearch=True, # 启用联网搜索
|
|
185
|
+
volc_websearch_api_key="your_websearch_api_key",
|
|
186
|
+
rag_fn=rag_function, # 自定义RAG函数
|
|
187
|
+
speaking_style="专业、友好、耐心",
|
|
188
|
+
system_role="你是一个专业的AI助手,擅长解答各种问题。"
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
session = AgentSession(llm=realtime_llm)
|
|
192
|
+
|
|
193
|
+
await session.start(agent=agent, room=ctx.room)
|
|
194
|
+
await ctx.connect()
|
|
195
|
+
|
|
196
|
+
if __name__ == "__main__":
|
|
197
|
+
load_dotenv()
|
|
198
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### 模型版本对比
|
|
202
|
+
|
|
203
|
+
火山引擎实时语音模型提供两个不同的版本,各有独特的功能特点:
|
|
204
|
+
|
|
205
|
+
##### O版本 (标准功能版)
|
|
206
|
+
```python
|
|
207
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
208
|
+
model="O", # 标准功能版,功能全面
|
|
209
|
+
# ... 其他配置
|
|
210
|
+
)
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**核心功能:**
|
|
214
|
+
- 🌐 **内置联网搜索**:支持实时网络信息检索和查询
|
|
215
|
+
- 🧠 **外部RAG支持**:支持外部知识库检索、总结和口语化改写
|
|
216
|
+
- 🎵 **精品音色**:支持 vv、xiaohe、yunzhou、xiaotian 等高品质音色
|
|
217
|
+
- ⚙️ **SP开放配置**:支持 bot_name、system_role、speaking_style 等参数配置
|
|
218
|
+
- 🚫 **角色描述**:不支持 character_manifest 参数
|
|
219
|
+
- 🚫 **克隆音色**:不支持 ICL_ 或 S_ 开头的音色名称
|
|
220
|
+
|
|
221
|
+
**适用场景:**
|
|
222
|
+
- 需要联网搜索的应用
|
|
223
|
+
- 需要外部知识库集成的场景
|
|
224
|
+
- 对音质要求较高的应用
|
|
225
|
+
- 需要灵活参数配置的场景
|
|
226
|
+
|
|
227
|
+
##### SC版本 (角色增强版)
|
|
228
|
+
```python
|
|
229
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
230
|
+
model="SC", # 角色增强版,专注角色扮演
|
|
231
|
+
# ... 其他配置
|
|
232
|
+
)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
**核心功能:**
|
|
236
|
+
- 🚫 **内置联网搜索**:不支持联网搜索功能
|
|
237
|
+
- 🚫 **外部RAG支持**:不支持外部RAG功能
|
|
238
|
+
- 🚫 **精品音色**:不支持 vv、xiaohe、yunzhou、xiaotian 等音色
|
|
239
|
+
- 🚫 **SP开放配置**:不支持 bot_name、system_role、speaking_style 参数
|
|
240
|
+
- 🎭 **角色描述**:支持 character_manifest 参数进行角色配置
|
|
241
|
+
- 🎤 **克隆音色**:支持 ICL_ 或 S_ 开头的克隆音色
|
|
242
|
+
|
|
243
|
+
**适用场景:**
|
|
244
|
+
- 专注于角色扮演的应用
|
|
245
|
+
- 需要使用克隆音色的场景
|
|
246
|
+
- 对角色个性化要求较高的应用
|
|
247
|
+
- 需要 character_manifest 配置的场景
|
|
248
|
+
|
|
249
|
+
#### 功能对比表格
|
|
250
|
+
|
|
251
|
+
| 功能特性 | O版本 | SC版本 |
|
|
252
|
+
|----------|-------|--------|
|
|
253
|
+
| 🌐 内置联网搜索 | ✅ | ❌ |
|
|
254
|
+
| 🧠 外部RAG总结和口语化改写 | ✅ | ❌ |
|
|
255
|
+
| 🎵 精品音色(vv、xiaohe、yunzhou、xiaotian) | ✅ | ❌ |
|
|
256
|
+
| ⚙️ SP开放配置(bot_name、system_role、speaking_style) | ✅ | ❌ |
|
|
257
|
+
| 🎭 角色描述(character_manifest) | ❌ | ✅ |
|
|
258
|
+
| 🎤 克隆音色(ICL_或S_开头) | ❌ | ✅ |
|
|
259
|
+
|
|
260
|
+
#### 版本选择建议
|
|
261
|
+
|
|
262
|
+
| 应用场景 | 推荐版本 | 主要原因 |
|
|
263
|
+
|----------|----------|----------|
|
|
264
|
+
| 智能客服 | O版本 | 需要联网搜索和灵活配置 |
|
|
265
|
+
| 教育辅导 | O版本 | 需要联网搜索和精品音质 |
|
|
266
|
+
| 角色扮演 | SC版本 | 专注于角色特性和克隆音色 |
|
|
267
|
+
| 娱乐应用 | O版本 | 需要联网搜索和多样音色 |
|
|
268
|
+
| 企业培训 | SC版本 | 需要角色定制和个性化 |
|
|
269
|
+
| 内容创作 | O版本 | 需要RAG和联网搜索功能 |
|
|
270
|
+
|
|
271
|
+
**使用建议:**
|
|
272
|
+
- **O版本**:功能更全面,适合大多数应用场景
|
|
273
|
+
- **SC版本**:专注于角色扮演,适合特定个性化需求
|
|
274
|
+
- 根据您的具体需求选择合适的版本
|
|
275
|
+
- 建议先测试两种版本,选择最符合需求的那一个
|
|
276
|
+
|
|
277
|
+
#### 角色配置 (SC版本)
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
281
|
+
from livekit.plugins import volcengine
|
|
282
|
+
from dotenv import load_dotenv
|
|
283
|
+
|
|
284
|
+
async def entry_point(ctx: JobContext):
|
|
285
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
286
|
+
|
|
287
|
+
# SC版本支持角色配置和克隆音色
|
|
288
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
289
|
+
app_id="your_app_id",
|
|
290
|
+
access_token="your_access_token",
|
|
291
|
+
bot_name="小智",
|
|
292
|
+
model="SC", # SC版本支持character_manifest
|
|
293
|
+
character_manifest='{ # JSON字符串格式的角色配置
|
|
294
|
+
"name": "小智",
|
|
295
|
+
"personality": "活泼开朗、聪明机智",
|
|
296
|
+
"background": "一个充满好奇心的AI助手"
|
|
297
|
+
}',
|
|
298
|
+
speaker="ICL_custom_voice", # SC版本支持克隆音色
|
|
299
|
+
speaking_style="活泼开朗,像个小伙伴一样和你聊天",
|
|
300
|
+
system_role="你叫小智,是一个活泼开朗的AI助手,喜欢用emoji表情,回复简洁有趣。"
|
|
301
|
+
)
|
|
302
|
+
|
|
303
|
+
session = AgentSession(llm=realtime_llm)
|
|
304
|
+
|
|
305
|
+
await session.start(agent=agent, room=ctx.room)
|
|
306
|
+
await ctx.connect()
|
|
307
|
+
|
|
308
|
+
if __name__ == "__main__":
|
|
309
|
+
load_dotenv()
|
|
310
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 单独组件使用
|
|
314
|
+
|
|
315
|
+
如果您需要分别使用各个组件(STT、TTS、LLM),而不是使用集成的实时语音模型:
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
319
|
+
from livekit.plugins import volcengine
|
|
320
|
+
from dotenv import load_dotenv
|
|
321
|
+
|
|
322
|
+
async def entry_point(ctx: JobContext):
|
|
323
|
+
agent = Agent(instructions="You are a helpful assistant.")
|
|
324
|
+
|
|
325
|
+
session = AgentSession(
|
|
326
|
+
# 语音识别
|
|
327
|
+
stt=volcengine.STT(
|
|
328
|
+
app_id="your_stt_app_id",
|
|
329
|
+
cluster="your_cluster"
|
|
330
|
+
),
|
|
331
|
+
# 语音合成
|
|
332
|
+
tts=volcengine.TTS(
|
|
333
|
+
app_id="your_tts_app_id",
|
|
334
|
+
cluster="your_cluster",
|
|
335
|
+
voice_type="BV001_V2_streaming"
|
|
336
|
+
),
|
|
337
|
+
# 单独的LLM (非实时)
|
|
338
|
+
llm=volcengine.LLM(model="doubao-1-5-pro-32k-250115")
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
await session.start(agent=agent, room=ctx.room)
|
|
342
|
+
await ctx.connect()
|
|
343
|
+
|
|
344
|
+
if __name__ == "__main__":
|
|
345
|
+
load_dotenv()
|
|
346
|
+
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## 🔧 API 参考
|
|
350
|
+
|
|
351
|
+
### TTS (文本转语音)
|
|
352
|
+
|
|
353
|
+
```python
|
|
354
|
+
volcengine.TTS(
|
|
355
|
+
app_id: str, # 应用ID
|
|
356
|
+
cluster: str, # 集群ID
|
|
357
|
+
voice_type: str = "BV001_V2_streaming", # 语音类型
|
|
358
|
+
speed_ratio: float = 1.0, # 语速 (0.5-2.0)
|
|
359
|
+
volume_ratio: float = 1.0, # 音量 (0.1-3.0)
|
|
360
|
+
pitch_ratio: float = 1.0 # 音调 (0.5-2.0)
|
|
361
|
+
)
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### STT (语音识别)
|
|
365
|
+
|
|
366
|
+
```python
|
|
367
|
+
volcengine.STT(
|
|
368
|
+
app_id: str, # 应用ID
|
|
369
|
+
cluster: str, # 集群ID
|
|
370
|
+
language: str = "zh-CN" # 语言
|
|
371
|
+
)
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### BigModelSTT (大模型语音识别)
|
|
375
|
+
|
|
376
|
+
```python
|
|
377
|
+
volcengine.BigModelSTT(
|
|
378
|
+
app_id: str, # 应用ID
|
|
379
|
+
cluster: str = "volcengine_streaming_common", # 集群
|
|
380
|
+
protocol: str = "http", # 协议
|
|
381
|
+
language: str = "zh-CN" # 语言
|
|
382
|
+
)
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
### LLM (大语言模型)
|
|
386
|
+
|
|
387
|
+
```python
|
|
388
|
+
volcengine.LLM(
|
|
389
|
+
model: str, # 模型名称
|
|
390
|
+
temperature: float = 0.7, # 温度
|
|
391
|
+
max_tokens: int = 2000, # 最大token数
|
|
392
|
+
system_message: str = None # 系统消息
|
|
393
|
+
)
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### RealtimeModel (实时语音模型)
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
volcengine.RealtimeModel(
|
|
400
|
+
# 必需参数
|
|
401
|
+
app_id: str = None, # 应用ID,从环境变量 VOLCENGINE_REALTIME_APP_ID 获取
|
|
402
|
+
access_token: str = None, # 访问令牌,从环境变量 VOLCENGINE_REALTIME_ACCESS_TOKEN 获取
|
|
403
|
+
|
|
404
|
+
# 基本配置
|
|
405
|
+
bot_name: str = "豆包", # 机器人名称
|
|
406
|
+
speaking_style: str = "你的说话风格简洁明了,语速适中,语调自然。", # 说话风格描述
|
|
407
|
+
speaker: str = "zh_female_vv_jupiter_bigtts", # 语音类型
|
|
408
|
+
opening: str = "你好啊,今天过得怎么样?", # 开场白内容
|
|
409
|
+
system_role: str = None, # 系统角色提示词
|
|
410
|
+
|
|
411
|
+
# 模型配置
|
|
412
|
+
model: Literal["O", "SC"] = "O", # 模型版本:O(标准功能版) 或 SC(角色增强版)
|
|
413
|
+
character_manifest: str = None, # 角色配置,JSON字符串格式
|
|
414
|
+
|
|
415
|
+
# 音频配置
|
|
416
|
+
sample_rate: int = 24000, # 采样率
|
|
417
|
+
num_channels: int = 1, # 声道数
|
|
418
|
+
format: str = "pcm", # 音频格式
|
|
419
|
+
|
|
420
|
+
# ASR配置
|
|
421
|
+
end_smooth_window_ms: int = 500, # 结束平滑窗口毫秒数
|
|
422
|
+
|
|
423
|
+
# 网络搜索配置
|
|
424
|
+
enable_volc_websearch: bool = False, # 是否启用网络搜索
|
|
425
|
+
volc_websearch_type: Literal["web_summary", "web"] = "web_summary", # 搜索类型
|
|
426
|
+
volc_websearch_api_key: str = None, # 网络搜索API密钥
|
|
427
|
+
volc_websearch_no_result_message: str = "抱歉,我找不到相关信息。", # 无结果提示
|
|
428
|
+
|
|
429
|
+
# RAG配置
|
|
430
|
+
rag_fn: Callable[[str], str] = None, # RAG回调函数,输入查询返回增强内容
|
|
431
|
+
|
|
432
|
+
# 其他配置
|
|
433
|
+
audio_output: bool = True, # 是否输出音频
|
|
434
|
+
modalities: List[Literal["text", "audio"]] = NOT_GIVEN, # 输出模态
|
|
435
|
+
http_session: aiohttp.ClientSession = None, # HTTP会话
|
|
436
|
+
max_session_duration: float = None, # 最大会话持续时间
|
|
437
|
+
conn_options: APIConnectOptions = DEFAULT_API_CONNECT_OPTIONS # 连接选项
|
|
438
|
+
)
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
## ❓ 常见问题
|
|
442
|
+
|
|
443
|
+
### Q: 如何获取访问令牌?
|
|
444
|
+
|
|
445
|
+
A: 请访问[火山引擎控制台](https://console.volcengine.com/),在相应服务页面创建应用并获取访问令牌。
|
|
446
|
+
|
|
447
|
+
### Q: 支持哪些语音类型?
|
|
448
|
+
|
|
449
|
+
A: 支持多种语音类型,包括 BV001_V2_streaming、BV002_V2_streaming 等,详见[语音合成文档](https://www.volcengine.com/docs/6561/97465)。
|
|
450
|
+
|
|
451
|
+
### Q: 如何处理连接错误?
|
|
452
|
+
|
|
453
|
+
A: 请检查网络连接和访问令牌是否正确配置。建议使用环境变量管理敏感信息。
|
|
454
|
+
|
|
455
|
+
### Q: 支持哪些大语言模型?
|
|
456
|
+
|
|
457
|
+
A: 支持豆包系列模型,包括 doubao-1-5-lite、doubao-1-5-pro 等,详见[大模型文档](https://www.volcengine.com/docs/82379/1513689)。
|
|
458
|
+
|
|
459
|
+
### Q: 实时语音模型支持哪些语音类型?
|
|
460
|
+
|
|
461
|
+
A: 实时语音模型支持多种预训练语音,包括:
|
|
462
|
+
- `zh_female_vv_jupiter_bigtts` - 女声 Jupiter 大模型语音
|
|
463
|
+
- `zh_male_vv_jupiter_bigtts` - 男声 Jupiter 大模型语音
|
|
464
|
+
- 其他火山引擎TTS支持的语音类型
|
|
465
|
+
|
|
466
|
+
### Q: 如何配置网络搜索功能?
|
|
467
|
+
|
|
468
|
+
A: 要启用网络搜索功能,需要设置以下参数:
|
|
469
|
+
```python
|
|
470
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
471
|
+
enable_volc_websearch=True,
|
|
472
|
+
volc_websearch_type="web_summary", # 或 "web"
|
|
473
|
+
volc_websearch_api_key="your_websearch_key"
|
|
474
|
+
)
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
### Q: 什么是RAG功能,如何使用?
|
|
478
|
+
|
|
479
|
+
A: RAG(Retrieval-Augmented Generation)可以为模型提供额外的上下文信息:
|
|
480
|
+
```python
|
|
481
|
+
def my_rag_function(query: str) -> str:
|
|
482
|
+
# 根据用户查询返回相关的上下文信息
|
|
483
|
+
return "相关的背景知识和信息"
|
|
484
|
+
|
|
485
|
+
realtime_llm = volcengine.RealtimeModel(
|
|
486
|
+
rag_fn=my_rag_function
|
|
487
|
+
)
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### Q: 实时语音模型和普通LLM/TTS的区别是什么?
|
|
491
|
+
|
|
492
|
+
A: 实时语音模型是端到端的解决方案:
|
|
493
|
+
- **集成度高**:语音识别、对话生成、语音合成一体化
|
|
494
|
+
- **实时性强**:支持全双工实时对话
|
|
495
|
+
- **智能化**:内置角色配置、网络搜索、RAG等高级功能
|
|
496
|
+
- **简单配置**:一个模型即可完成语音交互全流程
|
|
497
|
+
|
|
498
|
+
普通LLM+TTS组合需要分别配置和处理各个组件的数据流,而实时模型内部集成了这些功能。
|
|
499
|
+
|
|
500
|
+
### Q: 如何选择O版本和SC版本?
|
|
501
|
+
|
|
502
|
+
A: 根据您的应用需求选择合适的版本:
|
|
503
|
+
|
|
504
|
+
**选择O版本的情况:**
|
|
505
|
+
- 需要联网搜索功能的应用
|
|
506
|
+
- 需要外部RAG集成的场景
|
|
507
|
+
- 对音质要求较高,需要精品音色的应用
|
|
508
|
+
- 需要灵活配置bot_name、system_role、speaking_style的场景
|
|
509
|
+
- 大多数通用应用场景
|
|
510
|
+
|
|
511
|
+
**选择SC版本的情况:**
|
|
512
|
+
- 专注于角色扮演的应用
|
|
513
|
+
- 需要使用克隆音色(ICL_或S_开头)的场景
|
|
514
|
+
- 需要character_manifest进行角色配置的场景
|
|
515
|
+
- 对角色个性化要求较高的应用
|
|
516
|
+
|
|
517
|
+
**版本对比:**
|
|
518
|
+
- **O版本**:功能全面,适合大多数应用场景,支持联网搜索、RAG、精品音色等
|
|
519
|
+
- **SC版本**:专注于角色扮演,支持角色描述和克隆音色,但不支持联网搜索等功能
|
|
520
|
+
|
|
521
|
+
**使用建议:**
|
|
522
|
+
- 如果您的应用需要联网搜索、RAG或精品音色,选择O版本
|
|
523
|
+
- 如果您的应用专注于角色扮演和个性化音色,选择SC版本
|
|
524
|
+
- 建议根据具体需求测试两个版本,选择最合适的
|
|
525
|
+
|
|
526
|
+
## 📝 更新日志
|
|
527
|
+
|
|
528
|
+
### v1.2.9
|
|
529
|
+
- ✨ **新增实时语音模型**:支持端到端全双工语音交互
|
|
530
|
+
- 🎯 **增强大模型语音识别**:优化BigModelSTT性能和稳定性
|
|
531
|
+
- 🔧 **改进API设计**:RealtimeModel支持丰富的配置选项
|
|
532
|
+
- 🌐 **集成网络搜索**:支持实时网络信息检索和摘要
|
|
533
|
+
- 🧠 **RAG功能支持**:可配置检索增强生成回调函数
|
|
534
|
+
- 🎭 **角色配置系统**:支持自定义AI助手角色和性格
|
|
535
|
+
- 🔊 **多语音类型**:支持多种预训练语音模型
|
|
536
|
+
- 📚 **完善文档**:详细的使用指南和API参考
|
|
537
|
+
- 🐛 **修复已知问题**:提升整体稳定性和兼容性
|
|
538
|
+
|
|
539
|
+
## 🤝 贡献
|
|
540
|
+
|
|
541
|
+
欢迎提交 Issue 和 Pull Request!
|
|
542
|
+
|
|
543
|
+
1. Fork 本项目
|
|
544
|
+
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
545
|
+
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
|
|
546
|
+
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
547
|
+
5. 打开 Pull Request
|
|
548
|
+
|
|
549
|
+
## 📄 许可证
|
|
550
|
+
|
|
551
|
+
本项目采用 Apache 2.0 许可证 - 查看 [LICENSE](../LICENSE) 文件了解详情。
|
|
552
|
+
|
|
553
|
+
## 📞 联系我们
|
|
554
|
+
|
|
555
|
+
- 项目主页: [GitHub](https://github.com/your-repo/livekit-plugins-volcengine)
|
|
556
|
+
- 问题反馈: [Issues](https://github.com/your-repo/livekit-plugins-volcengine/issues)
|
|
557
|
+
- 邮箱: 790990241@qq.com
|
|
558
|
+
|
|
559
|
+
## 🙏 致谢
|
|
560
|
+
|
|
561
|
+
- [LiveKit](https://github.com/livekit/agents) - 优秀的实时通信框架
|
|
562
|
+
- [火山引擎](https://www.volcengine.com/) - 强大的AI服务提供商
|
|
563
|
+
|
|
@@ -287,7 +287,7 @@ class RealtimeModel(llm.RealtimeModel):
|
|
|
287
287
|
user_transcription=True,
|
|
288
288
|
auto_tool_reply_generation=False,
|
|
289
289
|
audio_output=("audio" in modalities),
|
|
290
|
-
manual_function_calls=True
|
|
290
|
+
manual_function_calls=True,
|
|
291
291
|
)
|
|
292
292
|
)
|
|
293
293
|
logger.info(f"Model: {model}")
|
|
@@ -626,9 +626,13 @@ class RealtimeSession(
|
|
|
626
626
|
payload_bytes = gzip.compress(payload_bytes)
|
|
627
627
|
chat_rag_text_request = bytearray(generate_header())
|
|
628
628
|
chat_rag_text_request.extend(int(502).to_bytes(4, "big"))
|
|
629
|
-
chat_rag_text_request.extend(
|
|
629
|
+
chat_rag_text_request.extend(
|
|
630
|
+
(len(self.session_id)).to_bytes(4, "big")
|
|
631
|
+
)
|
|
630
632
|
chat_rag_text_request.extend(str.encode(self.session_id))
|
|
631
|
-
chat_rag_text_request.extend(
|
|
633
|
+
chat_rag_text_request.extend(
|
|
634
|
+
(len(payload_bytes)).to_bytes(4, "big")
|
|
635
|
+
)
|
|
632
636
|
chat_rag_text_request.extend(payload_bytes)
|
|
633
637
|
await ws_conn.send_bytes(chat_rag_text_request)
|
|
634
638
|
logger.info("rag end")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.3.0"
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: livekit-plugins-volcengine
|
|
3
|
-
Version: 1.2.9
|
|
4
|
-
Summary: LiveKit Agent Plugins for Volcengine
|
|
5
|
-
Author-email: wangmengdi <790990241@qq.com>
|
|
6
|
-
Keywords: audio,livekit,realtime,video,webrtc
|
|
7
|
-
Classifier: Intended Audience :: Developers
|
|
8
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Topic :: Multimedia :: Sound/Audio
|
|
14
|
-
Classifier: Topic :: Multimedia :: Video
|
|
15
|
-
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
-
Requires-Python: >=3.9
|
|
17
|
-
Requires-Dist: livekit-agents>=1.2.9
|
|
18
|
-
Requires-Dist: numpy
|
|
19
|
-
Requires-Dist: openai>=1.75.0
|
|
20
|
-
Requires-Dist: osc-data==0.2.2
|
|
21
|
-
Requires-Dist: pydantic
|
|
22
|
-
Description-Content-Type: text/markdown
|
|
23
|
-
|
|
24
|
-
# livekit-plugins-volcengine
|
|
25
|
-
|
|
26
|
-
适配火山引擎服务的[livekit-agent](https://github.com/livekit/agents)框架插件。目前支持[TTS](https://www.volcengine.com/docs/6561/79817), [LLM](https://www.volcengine.com/docs/82379/1298454#%E6%B5%81%E5%BC%8F%E8%B0%83%E7%94%A8), [STT](https://www.volcengine.com/docs/6561/80818#python),[BigModelSTT](https://www.volcengine.com/docs/6561/1354869),[Realtime](https://www.volcengine.com/docs/6561/1594356)
|
|
27
|
-
|
|
28
|
-
## 安装
|
|
29
|
-
```python
|
|
30
|
-
pip install livekit-plugins-volcengine
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
## 环境变量
|
|
34
|
-
|
|
35
|
-
- Volcengine TTS: `VOLCENGINE_TTS_ACCESS_TOKEN`
|
|
36
|
-
- Volcengine STT: `VOLCENGINE_STT_ACCESS_TOKEN`
|
|
37
|
-
- Volcengine LLM: `VOLCENGINE_LLM_API_KEY`
|
|
38
|
-
- Volcengine Realtime: `VOLCENGINE_REALTIME_ACCESS_TOKEN`
|
|
39
|
-
|
|
40
|
-
## 使用示例
|
|
41
|
-
|
|
42
|
-
以下代码展示了如何在`livekit-agent`中使用`livekit-plugins-volcengine`插件。
|
|
43
|
-
|
|
44
|
-
```python
|
|
45
|
-
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
46
|
-
from livekit.plugins import volcengine, deepgram, silero
|
|
47
|
-
from dotenv import load_dotenv
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
async def entry_point(ctx: JobContext):
|
|
51
|
-
|
|
52
|
-
await ctx.connect()
|
|
53
|
-
|
|
54
|
-
agent = Agent(instructions="You are a helpful assistant.")
|
|
55
|
-
|
|
56
|
-
session = AgentSession(
|
|
57
|
-
# 语音识别:https://console.volcengine.com/speech/service/16
|
|
58
|
-
stt=volcengine.STT(app_id="xxx", cluster="xxx"),
|
|
59
|
-
# 大模型语音识别:https://console.volcengine.com/speech/service/10011
|
|
60
|
-
stt = volcengine.BigModelSTT(app_id="xxx"),
|
|
61
|
-
# 语音识别:https://www.volcengine.com/docs/6561/97465
|
|
62
|
-
tts=volcengine.TTS(app_id="xxx", cluster="xxx", vioce_type="BV001_V2_streaming"),
|
|
63
|
-
# 大语言模型:https://www.volcengine.com/docs/82379/1513689
|
|
64
|
-
llm=volcengine.LLM(model="doubao-1-5-lite-32k-250115"),
|
|
65
|
-
# 端到端实时语音大模型:https://www.volcengine.com/docs/6561/1594356
|
|
66
|
-
llm=volcengine.RealtimeModel(app_id="xxxx",
|
|
67
|
-
speaking_style="xxxx", # 回复语音风格
|
|
68
|
-
system_role="xxx", # 系统提示词
|
|
69
|
-
opening="xxx") # 开场词
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
await session.start(agent=agent, room=ctx.room)
|
|
73
|
-
|
|
74
|
-
await session.generate_reply()
|
|
75
|
-
|
|
76
|
-
if __name__ == "__main__":
|
|
77
|
-
load_dotenv()
|
|
78
|
-
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
79
|
-
```
|
|
80
|
-
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
# livekit-plugins-volcengine
|
|
2
|
-
|
|
3
|
-
适配火山引擎服务的[livekit-agent](https://github.com/livekit/agents)框架插件。目前支持[TTS](https://www.volcengine.com/docs/6561/79817), [LLM](https://www.volcengine.com/docs/82379/1298454#%E6%B5%81%E5%BC%8F%E8%B0%83%E7%94%A8), [STT](https://www.volcengine.com/docs/6561/80818#python),[BigModelSTT](https://www.volcengine.com/docs/6561/1354869),[Realtime](https://www.volcengine.com/docs/6561/1594356)
|
|
4
|
-
|
|
5
|
-
## 安装
|
|
6
|
-
```python
|
|
7
|
-
pip install livekit-plugins-volcengine
|
|
8
|
-
```
|
|
9
|
-
|
|
10
|
-
## 环境变量
|
|
11
|
-
|
|
12
|
-
- Volcengine TTS: `VOLCENGINE_TTS_ACCESS_TOKEN`
|
|
13
|
-
- Volcengine STT: `VOLCENGINE_STT_ACCESS_TOKEN`
|
|
14
|
-
- Volcengine LLM: `VOLCENGINE_LLM_API_KEY`
|
|
15
|
-
- Volcengine Realtime: `VOLCENGINE_REALTIME_ACCESS_TOKEN`
|
|
16
|
-
|
|
17
|
-
## 使用示例
|
|
18
|
-
|
|
19
|
-
以下代码展示了如何在`livekit-agent`中使用`livekit-plugins-volcengine`插件。
|
|
20
|
-
|
|
21
|
-
```python
|
|
22
|
-
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
|
|
23
|
-
from livekit.plugins import volcengine, deepgram, silero
|
|
24
|
-
from dotenv import load_dotenv
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
async def entry_point(ctx: JobContext):
|
|
28
|
-
|
|
29
|
-
await ctx.connect()
|
|
30
|
-
|
|
31
|
-
agent = Agent(instructions="You are a helpful assistant.")
|
|
32
|
-
|
|
33
|
-
session = AgentSession(
|
|
34
|
-
# 语音识别:https://console.volcengine.com/speech/service/16
|
|
35
|
-
stt=volcengine.STT(app_id="xxx", cluster="xxx"),
|
|
36
|
-
# 大模型语音识别:https://console.volcengine.com/speech/service/10011
|
|
37
|
-
stt = volcengine.BigModelSTT(app_id="xxx"),
|
|
38
|
-
# 语音识别:https://www.volcengine.com/docs/6561/97465
|
|
39
|
-
tts=volcengine.TTS(app_id="xxx", cluster="xxx", vioce_type="BV001_V2_streaming"),
|
|
40
|
-
# 大语言模型:https://www.volcengine.com/docs/82379/1513689
|
|
41
|
-
llm=volcengine.LLM(model="doubao-1-5-lite-32k-250115"),
|
|
42
|
-
# 端到端实时语音大模型:https://www.volcengine.com/docs/6561/1594356
|
|
43
|
-
llm=volcengine.RealtimeModel(app_id="xxxx",
|
|
44
|
-
speaking_style="xxxx", # 回复语音风格
|
|
45
|
-
system_role="xxx", # 系统提示词
|
|
46
|
-
opening="xxx") # 开场词
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
await session.start(agent=agent, room=ctx.room)
|
|
50
|
-
|
|
51
|
-
await session.generate_reply()
|
|
52
|
-
|
|
53
|
-
if __name__ == "__main__":
|
|
54
|
-
load_dotenv()
|
|
55
|
-
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
|
|
56
|
-
```
|
|
57
|
-
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.2.9"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|