livekit-plugins-volcenginee 1.3.0__tar.gz → 1.3.2__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_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/PKG-INFO +30 -29
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/README.md +29 -28
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/llm.py +19 -4
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/realtime.py +7 -17
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/stt.py +8 -16
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/tts.py +18 -15
- livekit_plugins_volcenginee-1.3.2/livekit/plugins/volcengine/version.py +1 -0
- livekit_plugins_volcenginee-1.3.0/livekit/plugins/volcengine/version.py +0 -1
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/.gitignore +0 -0
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/__init__.py +0 -0
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/log.py +0 -0
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/py.typed +0 -0
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/livekit/plugins/volcengine/utils.py +0 -0
- {livekit_plugins_volcenginee-1.3.0 → livekit_plugins_volcenginee-1.3.2}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: livekit-plugins-volcenginee
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.2
|
|
4
4
|
Summary: LiveKit Agent Plugins for Volcengine
|
|
5
5
|
Author-email: linsanzhu <2287225730@qq.com>
|
|
6
6
|
Keywords: audio,livekit,realtime,video,webrtc
|
|
@@ -38,6 +38,9 @@ Description-Content-Type: text/markdown
|
|
|
38
38
|
- `volcengine.TTS` 默认音色为 `zh_female_xiaohe_uranus_bigtts`
|
|
39
39
|
- `volcengine.STT` 现已直接使用豆包大模型流式语音识别接口
|
|
40
40
|
- `volcengine.STT` 已补齐新版握手头 `X-Api-Connect-Id`
|
|
41
|
+
- `volcengine.STT` 切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
42
|
+
- `volcengine.TTS` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
43
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
41
44
|
|
|
42
45
|
## ✨ 特性
|
|
43
46
|
|
|
@@ -95,20 +98,20 @@ pip install -e .
|
|
|
95
98
|
|
|
96
99
|
| 环境变量 | 描述 | 获取方式 |
|
|
97
100
|
|----------|------|----------|
|
|
98
|
-
| `
|
|
99
|
-
| `
|
|
101
|
+
| `VOLCENGINE_TTS_API_KEY` | TTS 服务的 API Key(新版控制台) | [语音合成控制台](https://console.volcengine.com/speech/service/16) |
|
|
102
|
+
| `VOLCENGINE_STT_API_KEY` | STT 服务的 API Key(新版控制台) | [语音识别控制台](https://console.volcengine.com/speech/service/16) |
|
|
100
103
|
| `VOLCENGINE_LLM_API_KEY` | LLM 服务的 API 密钥 | [大模型控制台](https://console.volcengine.com/ark/) |
|
|
101
|
-
| `
|
|
104
|
+
| `VOLCENGINE_REALTIME_API_KEY` | 实时服务的 API Key(新版控制台) | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
|
|
102
105
|
| `VOLCENGINE_TTS_RESOURCE_ID` | TTS 资源 ID,默认 `seed-tts-2.0` | [豆包语音合成接口文档](https://www.volcengine.com/docs/6561/1257584) |
|
|
103
106
|
|
|
104
107
|
### .env 文件示例
|
|
105
108
|
|
|
106
109
|
```bash
|
|
107
110
|
# .env
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
VOLCENGINE_TTS_API_KEY=your_tts_api_key_here
|
|
112
|
+
VOLCENGINE_STT_API_KEY=your_stt_api_key_here
|
|
110
113
|
VOLCENGINE_LLM_API_KEY=your_llm_api_key_here
|
|
111
|
-
|
|
114
|
+
VOLCENGINE_REALTIME_API_KEY=your_realtime_api_key_here
|
|
112
115
|
```
|
|
113
116
|
|
|
114
117
|
## 📖 使用指南
|
|
@@ -125,8 +128,7 @@ async def entry_point(ctx: JobContext):
|
|
|
125
128
|
|
|
126
129
|
# 使用实时语音模型
|
|
127
130
|
llm = volcengine.RealtimeModel(
|
|
128
|
-
|
|
129
|
-
access_token="your_access_token",
|
|
131
|
+
api_key="your_api_key",
|
|
130
132
|
bot_name="智能助手",
|
|
131
133
|
model="O" # 或 "SC"
|
|
132
134
|
)
|
|
@@ -152,11 +154,11 @@ async def entry_point(ctx: JobContext):
|
|
|
152
154
|
agent = Agent(instructions="You are a helpful assistant.")
|
|
153
155
|
|
|
154
156
|
# 使用豆包大模型流式语音识别
|
|
155
|
-
stt = volcengine.STT(
|
|
157
|
+
stt = volcengine.STT(api_key="your_api_key")
|
|
156
158
|
|
|
157
159
|
session = AgentSession(
|
|
158
160
|
stt=stt,
|
|
159
|
-
tts=volcengine.TTS(
|
|
161
|
+
tts=volcengine.TTS(api_key="your_tts_api_key"),
|
|
160
162
|
llm=volcengine.LLM(model="doubao-1-5-pro-32k-250115")
|
|
161
163
|
)
|
|
162
164
|
|
|
@@ -184,8 +186,7 @@ async def entry_point(ctx: JobContext):
|
|
|
184
186
|
|
|
185
187
|
# 基础实时语音模型配置
|
|
186
188
|
realtime_llm = volcengine.RealtimeModel(
|
|
187
|
-
|
|
188
|
-
access_token="your_access_token",
|
|
189
|
+
api_key="your_api_key",
|
|
189
190
|
bot_name="豆包", # 机器人名称
|
|
190
191
|
model="O" # 默认使用O版本,功能全面
|
|
191
192
|
)
|
|
@@ -218,8 +219,7 @@ async def entry_point(ctx: JobContext):
|
|
|
218
219
|
|
|
219
220
|
# 高级配置 - 包含网络搜索和RAG功能
|
|
220
221
|
realtime_llm = volcengine.RealtimeModel(
|
|
221
|
-
|
|
222
|
-
access_token="your_access_token",
|
|
222
|
+
api_key="your_api_key",
|
|
223
223
|
bot_name="智能助手",
|
|
224
224
|
model="O", # O版本支持联网搜索和RAG,SC版本专注角色扮演
|
|
225
225
|
enable_volc_websearch=True, # 启用联网搜索
|
|
@@ -327,8 +327,7 @@ async def entry_point(ctx: JobContext):
|
|
|
327
327
|
|
|
328
328
|
# SC版本支持角色配置和克隆音色
|
|
329
329
|
realtime_llm = volcengine.RealtimeModel(
|
|
330
|
-
|
|
331
|
-
access_token="your_access_token",
|
|
330
|
+
api_key="your_api_key",
|
|
332
331
|
bot_name="小智",
|
|
333
332
|
model="SC", # SC版本支持character_manifest
|
|
334
333
|
character_manifest='{ # JSON字符串格式的角色配置
|
|
@@ -366,12 +365,12 @@ async def entry_point(ctx: JobContext):
|
|
|
366
365
|
session = AgentSession(
|
|
367
366
|
# 语音识别
|
|
368
367
|
stt=volcengine.STT(
|
|
369
|
-
|
|
368
|
+
api_key="your_stt_api_key",
|
|
370
369
|
resource_id="volc.seedasr.sauc.duration"
|
|
371
370
|
),
|
|
372
371
|
# 语音合成
|
|
373
372
|
tts=volcengine.TTS(
|
|
374
|
-
|
|
373
|
+
api_key="your_tts_api_key",
|
|
375
374
|
resource_id="seed-tts-2.0",
|
|
376
375
|
voice="zh_female_xiaohe_uranus_bigtts"
|
|
377
376
|
),
|
|
@@ -395,13 +394,14 @@ if __name__ == "__main__":
|
|
|
395
394
|
|
|
396
395
|
```python
|
|
397
396
|
volcengine.TTS(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
resource_id: str | None = None, # 默认 seed-tts-2.0
|
|
397
|
+
api_key: str, # API Key(新版控制台)
|
|
398
|
+
resource_id: str | None = None, # 默认 seed-tts-2.0
|
|
401
399
|
voice: str = "zh_female_xiaohe_uranus_bigtts",
|
|
402
|
-
speed: float = 1.0,
|
|
403
|
-
volume: float = 1.0,
|
|
404
|
-
pitch: float = 1.0,
|
|
400
|
+
speed: float = 1.0, # 已废弃,保留仅用于兼容
|
|
401
|
+
volume: float = 1.0, # 已废弃,保留仅用于兼容
|
|
402
|
+
pitch: float = 1.0, # 已废弃,保留仅用于兼容
|
|
403
|
+
speech_rate: int = 0, # 语速,[-50, 100],100=2.0x,-50=0.5x
|
|
404
|
+
loudness_rate: int = 0, # 音量,[-50, 100],100=2.0x,-50=0.5x(mix 音色暂不支持)
|
|
405
405
|
sample_rate: Literal[24000, 16000, 8000] = 16000,
|
|
406
406
|
)
|
|
407
407
|
```
|
|
@@ -421,8 +421,7 @@ volcengine.TTS(
|
|
|
421
421
|
|
|
422
422
|
```python
|
|
423
423
|
volcengine.STT(
|
|
424
|
-
|
|
425
|
-
access_token: str | None = None,
|
|
424
|
+
api_key: str | None = None, # API Key(新版控制台),可用环境变量 VOLCENGINE_STT_API_KEY
|
|
426
425
|
resource_id: str | None = None, # 例如 volc.bigasr.sauc.duration / volc.seedasr.sauc.duration
|
|
427
426
|
model_name: str = "bigmodel",
|
|
428
427
|
enable_itn: bool = False,
|
|
@@ -450,8 +449,7 @@ volcengine.LLM(
|
|
|
450
449
|
```python
|
|
451
450
|
volcengine.RealtimeModel(
|
|
452
451
|
# 必需参数
|
|
453
|
-
|
|
454
|
-
access_token: str = None, # 访问令牌,从环境变量 VOLCENGINE_REALTIME_ACCESS_TOKEN 获取
|
|
452
|
+
api_key: str = None, # API Key(新版控制台),从环境变量 VOLCENGINE_REALTIME_API_KEY 获取
|
|
455
453
|
|
|
456
454
|
# 基本配置
|
|
457
455
|
bot_name: str = "豆包", # 机器人名称
|
|
@@ -588,6 +586,9 @@ A: 根据您的应用需求选择合适的版本:
|
|
|
588
586
|
- 修复无音频返回时静默失败的问题
|
|
589
587
|
- 删除旧版普通 STT,实现统一为豆包大模型流式语音识别
|
|
590
588
|
- `volcengine.STT` 补齐 `X-Api-Connect-Id` 握手头
|
|
589
|
+
- `volcengine.STT` 切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
590
|
+
- `volcengine.TTS` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
591
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
591
592
|
|
|
592
593
|
## 🤝 贡献
|
|
593
594
|
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
- `volcengine.TTS` 默认音色为 `zh_female_xiaohe_uranus_bigtts`
|
|
17
17
|
- `volcengine.STT` 现已直接使用豆包大模型流式语音识别接口
|
|
18
18
|
- `volcengine.STT` 已补齐新版握手头 `X-Api-Connect-Id`
|
|
19
|
+
- `volcengine.STT` 切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
20
|
+
- `volcengine.TTS` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
21
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
19
22
|
|
|
20
23
|
## ✨ 特性
|
|
21
24
|
|
|
@@ -73,20 +76,20 @@ pip install -e .
|
|
|
73
76
|
|
|
74
77
|
| 环境变量 | 描述 | 获取方式 |
|
|
75
78
|
|----------|------|----------|
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
79
|
+
| `VOLCENGINE_TTS_API_KEY` | TTS 服务的 API Key(新版控制台) | [语音合成控制台](https://console.volcengine.com/speech/service/16) |
|
|
80
|
+
| `VOLCENGINE_STT_API_KEY` | STT 服务的 API Key(新版控制台) | [语音识别控制台](https://console.volcengine.com/speech/service/16) |
|
|
78
81
|
| `VOLCENGINE_LLM_API_KEY` | LLM 服务的 API 密钥 | [大模型控制台](https://console.volcengine.com/ark/) |
|
|
79
|
-
| `
|
|
82
|
+
| `VOLCENGINE_REALTIME_API_KEY` | 实时服务的 API Key(新版控制台) | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
|
|
80
83
|
| `VOLCENGINE_TTS_RESOURCE_ID` | TTS 资源 ID,默认 `seed-tts-2.0` | [豆包语音合成接口文档](https://www.volcengine.com/docs/6561/1257584) |
|
|
81
84
|
|
|
82
85
|
### .env 文件示例
|
|
83
86
|
|
|
84
87
|
```bash
|
|
85
88
|
# .env
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
VOLCENGINE_TTS_API_KEY=your_tts_api_key_here
|
|
90
|
+
VOLCENGINE_STT_API_KEY=your_stt_api_key_here
|
|
88
91
|
VOLCENGINE_LLM_API_KEY=your_llm_api_key_here
|
|
89
|
-
|
|
92
|
+
VOLCENGINE_REALTIME_API_KEY=your_realtime_api_key_here
|
|
90
93
|
```
|
|
91
94
|
|
|
92
95
|
## 📖 使用指南
|
|
@@ -103,8 +106,7 @@ async def entry_point(ctx: JobContext):
|
|
|
103
106
|
|
|
104
107
|
# 使用实时语音模型
|
|
105
108
|
llm = volcengine.RealtimeModel(
|
|
106
|
-
|
|
107
|
-
access_token="your_access_token",
|
|
109
|
+
api_key="your_api_key",
|
|
108
110
|
bot_name="智能助手",
|
|
109
111
|
model="O" # 或 "SC"
|
|
110
112
|
)
|
|
@@ -130,11 +132,11 @@ async def entry_point(ctx: JobContext):
|
|
|
130
132
|
agent = Agent(instructions="You are a helpful assistant.")
|
|
131
133
|
|
|
132
134
|
# 使用豆包大模型流式语音识别
|
|
133
|
-
stt = volcengine.STT(
|
|
135
|
+
stt = volcengine.STT(api_key="your_api_key")
|
|
134
136
|
|
|
135
137
|
session = AgentSession(
|
|
136
138
|
stt=stt,
|
|
137
|
-
tts=volcengine.TTS(
|
|
139
|
+
tts=volcengine.TTS(api_key="your_tts_api_key"),
|
|
138
140
|
llm=volcengine.LLM(model="doubao-1-5-pro-32k-250115")
|
|
139
141
|
)
|
|
140
142
|
|
|
@@ -162,8 +164,7 @@ async def entry_point(ctx: JobContext):
|
|
|
162
164
|
|
|
163
165
|
# 基础实时语音模型配置
|
|
164
166
|
realtime_llm = volcengine.RealtimeModel(
|
|
165
|
-
|
|
166
|
-
access_token="your_access_token",
|
|
167
|
+
api_key="your_api_key",
|
|
167
168
|
bot_name="豆包", # 机器人名称
|
|
168
169
|
model="O" # 默认使用O版本,功能全面
|
|
169
170
|
)
|
|
@@ -196,8 +197,7 @@ async def entry_point(ctx: JobContext):
|
|
|
196
197
|
|
|
197
198
|
# 高级配置 - 包含网络搜索和RAG功能
|
|
198
199
|
realtime_llm = volcengine.RealtimeModel(
|
|
199
|
-
|
|
200
|
-
access_token="your_access_token",
|
|
200
|
+
api_key="your_api_key",
|
|
201
201
|
bot_name="智能助手",
|
|
202
202
|
model="O", # O版本支持联网搜索和RAG,SC版本专注角色扮演
|
|
203
203
|
enable_volc_websearch=True, # 启用联网搜索
|
|
@@ -305,8 +305,7 @@ async def entry_point(ctx: JobContext):
|
|
|
305
305
|
|
|
306
306
|
# SC版本支持角色配置和克隆音色
|
|
307
307
|
realtime_llm = volcengine.RealtimeModel(
|
|
308
|
-
|
|
309
|
-
access_token="your_access_token",
|
|
308
|
+
api_key="your_api_key",
|
|
310
309
|
bot_name="小智",
|
|
311
310
|
model="SC", # SC版本支持character_manifest
|
|
312
311
|
character_manifest='{ # JSON字符串格式的角色配置
|
|
@@ -344,12 +343,12 @@ async def entry_point(ctx: JobContext):
|
|
|
344
343
|
session = AgentSession(
|
|
345
344
|
# 语音识别
|
|
346
345
|
stt=volcengine.STT(
|
|
347
|
-
|
|
346
|
+
api_key="your_stt_api_key",
|
|
348
347
|
resource_id="volc.seedasr.sauc.duration"
|
|
349
348
|
),
|
|
350
349
|
# 语音合成
|
|
351
350
|
tts=volcengine.TTS(
|
|
352
|
-
|
|
351
|
+
api_key="your_tts_api_key",
|
|
353
352
|
resource_id="seed-tts-2.0",
|
|
354
353
|
voice="zh_female_xiaohe_uranus_bigtts"
|
|
355
354
|
),
|
|
@@ -373,13 +372,14 @@ if __name__ == "__main__":
|
|
|
373
372
|
|
|
374
373
|
```python
|
|
375
374
|
volcengine.TTS(
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
resource_id: str | None = None, # 默认 seed-tts-2.0
|
|
375
|
+
api_key: str, # API Key(新版控制台)
|
|
376
|
+
resource_id: str | None = None, # 默认 seed-tts-2.0
|
|
379
377
|
voice: str = "zh_female_xiaohe_uranus_bigtts",
|
|
380
|
-
speed: float = 1.0,
|
|
381
|
-
volume: float = 1.0,
|
|
382
|
-
pitch: float = 1.0,
|
|
378
|
+
speed: float = 1.0, # 已废弃,保留仅用于兼容
|
|
379
|
+
volume: float = 1.0, # 已废弃,保留仅用于兼容
|
|
380
|
+
pitch: float = 1.0, # 已废弃,保留仅用于兼容
|
|
381
|
+
speech_rate: int = 0, # 语速,[-50, 100],100=2.0x,-50=0.5x
|
|
382
|
+
loudness_rate: int = 0, # 音量,[-50, 100],100=2.0x,-50=0.5x(mix 音色暂不支持)
|
|
383
383
|
sample_rate: Literal[24000, 16000, 8000] = 16000,
|
|
384
384
|
)
|
|
385
385
|
```
|
|
@@ -399,8 +399,7 @@ volcengine.TTS(
|
|
|
399
399
|
|
|
400
400
|
```python
|
|
401
401
|
volcengine.STT(
|
|
402
|
-
|
|
403
|
-
access_token: str | None = None,
|
|
402
|
+
api_key: str | None = None, # API Key(新版控制台),可用环境变量 VOLCENGINE_STT_API_KEY
|
|
404
403
|
resource_id: str | None = None, # 例如 volc.bigasr.sauc.duration / volc.seedasr.sauc.duration
|
|
405
404
|
model_name: str = "bigmodel",
|
|
406
405
|
enable_itn: bool = False,
|
|
@@ -428,8 +427,7 @@ volcengine.LLM(
|
|
|
428
427
|
```python
|
|
429
428
|
volcengine.RealtimeModel(
|
|
430
429
|
# 必需参数
|
|
431
|
-
|
|
432
|
-
access_token: str = None, # 访问令牌,从环境变量 VOLCENGINE_REALTIME_ACCESS_TOKEN 获取
|
|
430
|
+
api_key: str = None, # API Key(新版控制台),从环境变量 VOLCENGINE_REALTIME_API_KEY 获取
|
|
433
431
|
|
|
434
432
|
# 基本配置
|
|
435
433
|
bot_name: str = "豆包", # 机器人名称
|
|
@@ -566,6 +564,9 @@ A: 根据您的应用需求选择合适的版本:
|
|
|
566
564
|
- 修复无音频返回时静默失败的问题
|
|
567
565
|
- 删除旧版普通 STT,实现统一为豆包大模型流式语音识别
|
|
568
566
|
- `volcengine.STT` 补齐 `X-Api-Connect-Id` 握手头
|
|
567
|
+
- `volcengine.STT` 切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
568
|
+
- `volcengine.TTS` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
569
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
569
570
|
|
|
570
571
|
## 🤝 贡献
|
|
571
572
|
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import os
|
|
4
4
|
from dataclasses import dataclass
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any, Literal
|
|
6
6
|
|
|
7
7
|
import httpx
|
|
8
8
|
import openai
|
|
@@ -31,8 +31,8 @@ class _LLMOptions:
|
|
|
31
31
|
temperature: NotGivenOr[float]
|
|
32
32
|
parallel_tool_calls: NotGivenOr[bool]
|
|
33
33
|
tool_choice: NotGivenOr[ToolChoice]
|
|
34
|
-
store: NotGivenOr[bool]
|
|
35
34
|
metadata: NotGivenOr[dict[str, str]]
|
|
35
|
+
thinking: NotGivenOr[Literal["enabled", "disabled", "auto"] | dict[str, Any]]
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
class LLM(llm.LLM):
|
|
@@ -47,8 +47,8 @@ class LLM(llm.LLM):
|
|
|
47
47
|
temperature: NotGivenOr[float] = NOT_GIVEN,
|
|
48
48
|
parallel_tool_calls: NotGivenOr[bool] = NOT_GIVEN,
|
|
49
49
|
tool_choice: NotGivenOr[ToolChoice] = NOT_GIVEN,
|
|
50
|
-
store: NotGivenOr[bool] = NOT_GIVEN,
|
|
51
50
|
metadata: NotGivenOr[dict[str, str]] = NOT_GIVEN,
|
|
51
|
+
thinking: NotGivenOr[Literal["enabled", "disabled", "auto"] | dict[str, Any]] = NOT_GIVEN,
|
|
52
52
|
timeout: httpx.Timeout | None = None,
|
|
53
53
|
) -> None:
|
|
54
54
|
"""
|
|
@@ -58,6 +58,11 @@ class LLM(llm.LLM):
|
|
|
58
58
|
model: The model to use for the LLM, end
|
|
59
59
|
api_key: The API key to use for the LLM.
|
|
60
60
|
base_url: The base URL to use for the LLM.
|
|
61
|
+
thinking: Controls deep thinking mode. Pass ``"disabled"`` to turn
|
|
62
|
+
it off, ``"enabled"`` to force it on, ``"auto"`` to let the
|
|
63
|
+
model decide, or a raw ``{"type": "..."}`` dict for extended
|
|
64
|
+
parameters. See the Volcengine Chat Completions API reference
|
|
65
|
+
for details. Omit to use the API default (``enabled``).
|
|
61
66
|
"""
|
|
62
67
|
super().__init__()
|
|
63
68
|
self._opts = _LLMOptions(
|
|
@@ -66,8 +71,8 @@ class LLM(llm.LLM):
|
|
|
66
71
|
temperature=temperature,
|
|
67
72
|
parallel_tool_calls=parallel_tool_calls,
|
|
68
73
|
tool_choice=tool_choice,
|
|
69
|
-
store=store,
|
|
70
74
|
metadata=metadata,
|
|
75
|
+
thinking=thinking,
|
|
71
76
|
)
|
|
72
77
|
api_key = api_key if is_given(api_key) else os.getenv("VOLCENGINE_LLM_API_KEY")
|
|
73
78
|
if api_key is None:
|
|
@@ -110,6 +115,16 @@ class LLM(llm.LLM):
|
|
|
110
115
|
if is_given(self._opts.user):
|
|
111
116
|
extra["user"] = self._opts.user
|
|
112
117
|
|
|
118
|
+
if is_given(self._opts.temperature):
|
|
119
|
+
extra["temperature"] = self._opts.temperature
|
|
120
|
+
|
|
121
|
+
if is_given(self._opts.thinking):
|
|
122
|
+
extra["thinking"] = (
|
|
123
|
+
self._opts.thinking
|
|
124
|
+
if isinstance(self._opts.thinking, dict)
|
|
125
|
+
else {"type": self._opts.thinking}
|
|
126
|
+
)
|
|
127
|
+
|
|
113
128
|
parallel_tool_calls = (
|
|
114
129
|
parallel_tool_calls
|
|
115
130
|
if is_given(parallel_tool_calls)
|
|
@@ -163,8 +163,7 @@ def parse_response(res):
|
|
|
163
163
|
|
|
164
164
|
@dataclass
|
|
165
165
|
class _RealtimeOptions:
|
|
166
|
-
|
|
167
|
-
access_token: str
|
|
166
|
+
api_key: str
|
|
168
167
|
bot_name: str
|
|
169
168
|
system_role: str
|
|
170
169
|
max_session_duration: float | None
|
|
@@ -190,10 +189,8 @@ class _RealtimeOptions:
|
|
|
190
189
|
|
|
191
190
|
def get_ws_headers(self) -> dict:
|
|
192
191
|
headers = {
|
|
193
|
-
"X-Api-
|
|
194
|
-
"X-Api-Access-Key": self.access_token,
|
|
192
|
+
"X-Api-Key": self.api_key,
|
|
195
193
|
"X-Api-Resource-Id": "volc.speech.dialog", # 固定值
|
|
196
|
-
"X-Api-App-Key": "PlgvMymc7f3tQnJ6", # 固定值
|
|
197
194
|
"X-Api-Connect-Id": str(uuid.uuid4()),
|
|
198
195
|
}
|
|
199
196
|
return headers
|
|
@@ -262,8 +259,7 @@ class RealtimeModel(llm.RealtimeModel):
|
|
|
262
259
|
speaking_style: str = "你的说话风格简洁明了,语速适中,语调自然。",
|
|
263
260
|
speaker: str = "zh_female_vv_jupiter_bigtts",
|
|
264
261
|
opening: str | None = None,
|
|
265
|
-
|
|
266
|
-
access_token: str | None = None,
|
|
262
|
+
api_key: str | None = None,
|
|
267
263
|
system_role: str | None = None,
|
|
268
264
|
character_manifest: str = None,
|
|
269
265
|
model: Literal["O", "SC"] = "O",
|
|
@@ -299,17 +295,11 @@ class RealtimeModel(llm.RealtimeModel):
|
|
|
299
295
|
logger.info(
|
|
300
296
|
f"Volc Websearch No Result Message: {volc_websearch_no_result_message}"
|
|
301
297
|
)
|
|
302
|
-
|
|
303
|
-
if
|
|
304
|
-
raise ValueError("
|
|
305
|
-
access_token = access_token or os.environ.get(
|
|
306
|
-
"VOLCENGINE_REALTIME_ACCESS_TOKEN"
|
|
307
|
-
)
|
|
308
|
-
if access_token is None:
|
|
309
|
-
raise ValueError("VOLCENGINE_REALTIME_ACCESS_TOKEN is required")
|
|
298
|
+
api_key = api_key or os.environ.get("VOLCENGINE_REALTIME_API_KEY")
|
|
299
|
+
if api_key is None:
|
|
300
|
+
raise ValueError("VOLCENGINE_REALTIME_API_KEY is required")
|
|
310
301
|
self._opts = _RealtimeOptions(
|
|
311
|
-
|
|
312
|
-
access_token=access_token,
|
|
302
|
+
api_key=api_key,
|
|
313
303
|
bot_name=bot_name,
|
|
314
304
|
system_role=system_role,
|
|
315
305
|
speaker=speaker,
|
|
@@ -76,8 +76,7 @@ def generate_before_payload(sequence: int):
|
|
|
76
76
|
|
|
77
77
|
@dataclass
|
|
78
78
|
class STTOptions:
|
|
79
|
-
|
|
80
|
-
access_token: str | None = None
|
|
79
|
+
api_key: str | None = None
|
|
81
80
|
source_type: Literal["duration", "concurrent"] = "duration"
|
|
82
81
|
resource_id: str | None = None
|
|
83
82
|
|
|
@@ -167,16 +166,11 @@ class STTOptions:
|
|
|
167
166
|
header["X-Api-Resource-Id"] = "volc.bigasr.sauc.duration"
|
|
168
167
|
else:
|
|
169
168
|
header["X-Api-Resource-Id"] = "volc.bigasr.sauc.concurrent"
|
|
170
|
-
if self.
|
|
171
|
-
self.
|
|
172
|
-
if self.
|
|
173
|
-
raise ValueError("
|
|
174
|
-
|
|
175
|
-
self.access_token = os.environ.get("VOLCENGINE_STT_ACCESS_TOKEN", None)
|
|
176
|
-
if self.access_token is None:
|
|
177
|
-
raise ValueError("VOLCENGINE_STT_ACCESS_TOKEN is not set")
|
|
178
|
-
header["X-Api-Access-Key"] = self.access_token
|
|
179
|
-
header["X-Api-App-Key"] = self.app_id
|
|
169
|
+
if self.api_key is None:
|
|
170
|
+
self.api_key = os.environ.get("VOLCENGINE_STT_API_KEY", None)
|
|
171
|
+
if self.api_key is None:
|
|
172
|
+
raise ValueError("VOLCENGINE_STT_API_KEY is not set")
|
|
173
|
+
header["X-Api-Key"] = self.api_key
|
|
180
174
|
header["X-Api-Connect-Id"] = reqid
|
|
181
175
|
header["X-Api-Request-Id"] = reqid
|
|
182
176
|
return header
|
|
@@ -186,9 +180,8 @@ class STT(stt.STT):
|
|
|
186
180
|
def __init__(
|
|
187
181
|
self,
|
|
188
182
|
*,
|
|
189
|
-
|
|
183
|
+
api_key: str | None = None,
|
|
190
184
|
base_url: str = "wss://openspeech.bytedance.com/api/v3/sauc/bigmodel",
|
|
191
|
-
access_token: str | None = None,
|
|
192
185
|
resource_id: str | None = None,
|
|
193
186
|
model_name: str = "bigmodel",
|
|
194
187
|
enable_itn: bool = False,
|
|
@@ -208,8 +201,7 @@ class STT(stt.STT):
|
|
|
208
201
|
|
|
209
202
|
self._opts = STTOptions(
|
|
210
203
|
base_url=base_url,
|
|
211
|
-
|
|
212
|
-
app_id=app_id,
|
|
204
|
+
api_key=api_key,
|
|
213
205
|
resource_id=resource_id,
|
|
214
206
|
model_name=model_name,
|
|
215
207
|
enable_itn=enable_itn,
|
|
@@ -25,8 +25,7 @@ from .log import logger
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class _TTSOptions(BaseModel):
|
|
28
|
-
|
|
29
|
-
access_token: str | None = None
|
|
28
|
+
api_key: str
|
|
30
29
|
resource_id: str | None = None
|
|
31
30
|
voice: str = "zh_female_xiaohe_uranus_bigtts"
|
|
32
31
|
base_url: str = "https://openspeech.bytedance.com"
|
|
@@ -35,6 +34,8 @@ class _TTSOptions(BaseModel):
|
|
|
35
34
|
speed: float = Field(1.0, ge=0.2, le=3.0)
|
|
36
35
|
volume: float = Field(1.0, gt=0.1, le=3.0)
|
|
37
36
|
pitch: float = Field(1.0, ge=0.1, le=3.0)
|
|
37
|
+
speech_rate: int = Field(0, ge=-50, le=100)
|
|
38
|
+
loudness_rate: int = Field(0, ge=-50, le=100)
|
|
38
39
|
|
|
39
40
|
def get_http_url(self) -> str:
|
|
40
41
|
return f"{self.base_url}/api/v3/tts/unidirectional"
|
|
@@ -54,24 +55,20 @@ class _TTSOptions(BaseModel):
|
|
|
54
55
|
"audio_params": {
|
|
55
56
|
"format": self.encoding,
|
|
56
57
|
"sample_rate": self.sample_rate,
|
|
58
|
+
"loudness_rate": self.loudness_rate,
|
|
59
|
+
"speech_rate": self.speech_rate,
|
|
57
60
|
},
|
|
58
61
|
"request_id": reqid,
|
|
59
62
|
},
|
|
60
63
|
}
|
|
61
64
|
|
|
62
65
|
def get_http_header(self, reqid: str | None = None) -> dict[str, str]:
|
|
63
|
-
if self.access_token is None:
|
|
64
|
-
self.access_token = os.getenv("VOLCENGINE_TTS_ACCESS_TOKEN")
|
|
65
|
-
if self.access_token is None:
|
|
66
|
-
raise ValueError("VOLCENGINE_TTS_ACCESS_TOKEN is not set")
|
|
67
66
|
resource_id = self.resource_id or os.getenv(
|
|
68
67
|
"VOLCENGINE_TTS_RESOURCE_ID", "seed-tts-2.0"
|
|
69
68
|
)
|
|
70
69
|
headers = {
|
|
71
70
|
"Content-Type": "application/json",
|
|
72
|
-
"X-Api-
|
|
73
|
-
"X-Api-App-Key": self.app_id,
|
|
74
|
-
"X-Api-Access-Key": self.access_token,
|
|
71
|
+
"X-Api-Key": self.api_key,
|
|
75
72
|
"X-Api-Resource-Id": resource_id,
|
|
76
73
|
}
|
|
77
74
|
if reqid is not None:
|
|
@@ -82,23 +79,28 @@ class _TTSOptions(BaseModel):
|
|
|
82
79
|
class TTS(tts.TTS):
|
|
83
80
|
def __init__(
|
|
84
81
|
self,
|
|
85
|
-
|
|
86
|
-
access_token: str | None = None,
|
|
82
|
+
api_key: str,
|
|
87
83
|
resource_id: str | None = None,
|
|
88
84
|
voice: str = "zh_female_xiaohe_uranus_bigtts",
|
|
89
85
|
speed: float = 1.0,
|
|
90
86
|
volume: float = 1.0,
|
|
91
87
|
pitch: float = 1.0,
|
|
88
|
+
speech_rate: int = 0,
|
|
89
|
+
loudness_rate: int = 0,
|
|
92
90
|
sample_rate: Literal[24000, 16000, 8000] = 16000,
|
|
93
91
|
http_session: aiohttp.ClientSession | None = None,
|
|
94
92
|
):
|
|
95
93
|
"""VolcEngine TTS
|
|
96
94
|
|
|
97
95
|
Args:
|
|
98
|
-
|
|
99
|
-
access_token (str | None, optional): the access token of the tts, if not provided, the value of the environment variable VOLCENGINE_TTS_ACCESS_TOKEN will be used. Defaults to None.
|
|
96
|
+
api_key (str): the API key of the tts, you can get it from the new console.
|
|
100
97
|
resource_id (str | None, optional): VolcEngine TTS resource id. Use `seed-tts-2.0` for Doubao TTS 2.0 voices, `seed-tts-1.0` / `seed-tts-1.0-concurr` for Doubao TTS 1.0 voices, `seed-icl-2.0` for voice cloning 2.0, and `seed-icl-1.0` / `seed-icl-1.0-concurr` for voice cloning 1.0. Defaults to None.
|
|
101
98
|
voice (str, optional): the voice id used by the tts request. Defaults to `zh_female_xiaohe_uranus_bigtts`.
|
|
99
|
+
speed (float, optional): kept for backwards compatibility, no longer sent to the API. Defaults to 1.0.
|
|
100
|
+
volume (float, optional): kept for backwards compatibility, no longer sent to the API. Defaults to 1.0.
|
|
101
|
+
pitch (float, optional): kept for backwards compatibility, no longer sent to the API. Defaults to 1.0.
|
|
102
|
+
speech_rate (int, optional): speech rate, range [-50, 100]. 100 = 2.0x, -50 = 0.5x. Defaults to 0 (normal).
|
|
103
|
+
loudness_rate (int, optional): volume gain, range [-50, 100]. 100 = 2.0x, -50 = 0.5x. Not supported for mix voices. Defaults to 0 (normal).
|
|
102
104
|
sample_rate (Literal[24000, 16000, 8000], optional): the sample rate of the tts. Defaults to 24000.
|
|
103
105
|
streaming (bool, optional): whether to use the streaming api. Defaults to True.
|
|
104
106
|
http_session (aiohttp.ClientSession | None, optional): the http session to use. Defaults to None.
|
|
@@ -109,14 +111,15 @@ class TTS(tts.TTS):
|
|
|
109
111
|
num_channels=1,
|
|
110
112
|
)
|
|
111
113
|
self._opts = _TTSOptions(
|
|
112
|
-
|
|
113
|
-
access_token=access_token,
|
|
114
|
+
api_key=api_key,
|
|
114
115
|
resource_id=resource_id,
|
|
115
116
|
voice=voice,
|
|
116
117
|
sample_rate=sample_rate,
|
|
117
118
|
speed=speed,
|
|
118
119
|
volume=volume,
|
|
119
120
|
pitch=pitch,
|
|
121
|
+
speech_rate=speech_rate,
|
|
122
|
+
loudness_rate=loudness_rate,
|
|
120
123
|
)
|
|
121
124
|
self._session = http_session
|
|
122
125
|
self._streams = weakref.WeakSet[SynthesizeStream]()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.3.2"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.3.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|