livekit-plugins-volcenginee 1.3.1__tar.gz → 1.3.3__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.1 → livekit_plugins_volcenginee-1.3.3}/PKG-INFO +19 -18
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/README.md +18 -17
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/llm.py +19 -4
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/realtime.py +7 -17
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/tts.py +29 -1
- livekit_plugins_volcenginee-1.3.3/livekit/plugins/volcengine/version.py +1 -0
- livekit_plugins_volcenginee-1.3.1/livekit/plugins/volcengine/version.py +0 -1
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/.gitignore +0 -0
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/__init__.py +0 -0
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/log.py +0 -0
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/py.typed +0 -0
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/stt.py +0 -0
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/livekit/plugins/volcengine/utils.py +0 -0
- {livekit_plugins_volcenginee-1.3.1 → livekit_plugins_volcenginee-1.3.3}/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.3
|
|
4
4
|
Summary: LiveKit Agent Plugins for Volcengine
|
|
5
5
|
Author-email: linsanzhu <2287225730@qq.com>
|
|
6
6
|
Keywords: audio,livekit,realtime,video,webrtc
|
|
@@ -40,6 +40,7 @@ Description-Content-Type: text/markdown
|
|
|
40
40
|
- `volcengine.STT` 已补齐新版握手头 `X-Api-Connect-Id`
|
|
41
41
|
- `volcengine.STT` 切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
42
42
|
- `volcengine.TTS` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
43
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
43
44
|
|
|
44
45
|
## ✨ 特性
|
|
45
46
|
|
|
@@ -100,7 +101,7 @@ pip install -e .
|
|
|
100
101
|
| `VOLCENGINE_TTS_API_KEY` | TTS 服务的 API Key(新版控制台) | [语音合成控制台](https://console.volcengine.com/speech/service/16) |
|
|
101
102
|
| `VOLCENGINE_STT_API_KEY` | STT 服务的 API Key(新版控制台) | [语音识别控制台](https://console.volcengine.com/speech/service/16) |
|
|
102
103
|
| `VOLCENGINE_LLM_API_KEY` | LLM 服务的 API 密钥 | [大模型控制台](https://console.volcengine.com/ark/) |
|
|
103
|
-
| `
|
|
104
|
+
| `VOLCENGINE_REALTIME_API_KEY` | 实时服务的 API Key(新版控制台) | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
|
|
104
105
|
| `VOLCENGINE_TTS_RESOURCE_ID` | TTS 资源 ID,默认 `seed-tts-2.0` | [豆包语音合成接口文档](https://www.volcengine.com/docs/6561/1257584) |
|
|
105
106
|
|
|
106
107
|
### .env 文件示例
|
|
@@ -110,7 +111,7 @@ pip install -e .
|
|
|
110
111
|
VOLCENGINE_TTS_API_KEY=your_tts_api_key_here
|
|
111
112
|
VOLCENGINE_STT_API_KEY=your_stt_api_key_here
|
|
112
113
|
VOLCENGINE_LLM_API_KEY=your_llm_api_key_here
|
|
113
|
-
|
|
114
|
+
VOLCENGINE_REALTIME_API_KEY=your_realtime_api_key_here
|
|
114
115
|
```
|
|
115
116
|
|
|
116
117
|
## 📖 使用指南
|
|
@@ -127,8 +128,7 @@ async def entry_point(ctx: JobContext):
|
|
|
127
128
|
|
|
128
129
|
# 使用实时语音模型
|
|
129
130
|
llm = volcengine.RealtimeModel(
|
|
130
|
-
|
|
131
|
-
access_token="your_access_token",
|
|
131
|
+
api_key="your_api_key",
|
|
132
132
|
bot_name="智能助手",
|
|
133
133
|
model="O" # 或 "SC"
|
|
134
134
|
)
|
|
@@ -186,8 +186,7 @@ async def entry_point(ctx: JobContext):
|
|
|
186
186
|
|
|
187
187
|
# 基础实时语音模型配置
|
|
188
188
|
realtime_llm = volcengine.RealtimeModel(
|
|
189
|
-
|
|
190
|
-
access_token="your_access_token",
|
|
189
|
+
api_key="your_api_key",
|
|
191
190
|
bot_name="豆包", # 机器人名称
|
|
192
191
|
model="O" # 默认使用O版本,功能全面
|
|
193
192
|
)
|
|
@@ -220,8 +219,7 @@ async def entry_point(ctx: JobContext):
|
|
|
220
219
|
|
|
221
220
|
# 高级配置 - 包含网络搜索和RAG功能
|
|
222
221
|
realtime_llm = volcengine.RealtimeModel(
|
|
223
|
-
|
|
224
|
-
access_token="your_access_token",
|
|
222
|
+
api_key="your_api_key",
|
|
225
223
|
bot_name="智能助手",
|
|
226
224
|
model="O", # O版本支持联网搜索和RAG,SC版本专注角色扮演
|
|
227
225
|
enable_volc_websearch=True, # 启用联网搜索
|
|
@@ -329,8 +327,7 @@ async def entry_point(ctx: JobContext):
|
|
|
329
327
|
|
|
330
328
|
# SC版本支持角色配置和克隆音色
|
|
331
329
|
realtime_llm = volcengine.RealtimeModel(
|
|
332
|
-
|
|
333
|
-
access_token="your_access_token",
|
|
330
|
+
api_key="your_api_key",
|
|
334
331
|
bot_name="小智",
|
|
335
332
|
model="SC", # SC版本支持character_manifest
|
|
336
333
|
character_manifest='{ # JSON字符串格式的角色配置
|
|
@@ -397,16 +394,20 @@ if __name__ == "__main__":
|
|
|
397
394
|
|
|
398
395
|
```python
|
|
399
396
|
volcengine.TTS(
|
|
400
|
-
api_key: str,
|
|
401
|
-
resource_id: str | None = None,
|
|
397
|
+
api_key: str, # API Key(新版控制台)
|
|
398
|
+
resource_id: str | None = None, # 默认 seed-tts-2.0
|
|
402
399
|
voice: str = "zh_female_xiaohe_uranus_bigtts",
|
|
403
|
-
speed: float = 1.0,
|
|
404
|
-
volume: float = 1.0,
|
|
405
|
-
pitch: float = 1.0,
|
|
400
|
+
speed: float = 1.0, # 语速倍率(OpenAI 规范),[0.2, 3.0],1.0=正常
|
|
401
|
+
volume: float = 1.0, # 音量倍率(OpenAI 规范),(0.1, 3.0],1.0=正常(mix 音色暂不支持)
|
|
402
|
+
pitch: float = 1.0, # 已废弃,保留仅用于兼容
|
|
406
403
|
sample_rate: Literal[24000, 16000, 8000] = 16000,
|
|
407
404
|
)
|
|
408
405
|
```
|
|
409
406
|
|
|
407
|
+
> `speed` / `volume` 遵循 OpenAI 接口规范(float 倍率),请求时按
|
|
408
|
+
> `speech_rate = round((speed - 1.0) * 200)`(clamp 到 `[-50, 100]`)转换为火山原生
|
|
409
|
+
> `speech_rate` / `loudness_rate` 整型字段。
|
|
410
|
+
|
|
410
411
|
### TTS 资源 ID 说明
|
|
411
412
|
|
|
412
413
|
- `seed-tts-2.0`:豆包语音合成模型 2.0
|
|
@@ -450,8 +451,7 @@ volcengine.LLM(
|
|
|
450
451
|
```python
|
|
451
452
|
volcengine.RealtimeModel(
|
|
452
453
|
# 必需参数
|
|
453
|
-
|
|
454
|
-
access_token: str = None, # 访问令牌,从环境变量 VOLCENGINE_REALTIME_ACCESS_TOKEN 获取
|
|
454
|
+
api_key: str = None, # API Key(新版控制台),从环境变量 VOLCENGINE_REALTIME_API_KEY 获取
|
|
455
455
|
|
|
456
456
|
# 基本配置
|
|
457
457
|
bot_name: str = "豆包", # 机器人名称
|
|
@@ -590,6 +590,7 @@ A: 根据您的应用需求选择合适的版本:
|
|
|
590
590
|
- `volcengine.STT` 补齐 `X-Api-Connect-Id` 握手头
|
|
591
591
|
- `volcengine.STT` 切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
592
592
|
- `volcengine.TTS` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
593
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
593
594
|
|
|
594
595
|
## 🤝 贡献
|
|
595
596
|
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- `volcengine.STT` 已补齐新版握手头 `X-Api-Connect-Id`
|
|
19
19
|
- `volcengine.STT` 切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
20
20
|
- `volcengine.TTS` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
21
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,仅使用 `X-Api-Key` 头
|
|
21
22
|
|
|
22
23
|
## ✨ 特性
|
|
23
24
|
|
|
@@ -78,7 +79,7 @@ pip install -e .
|
|
|
78
79
|
| `VOLCENGINE_TTS_API_KEY` | TTS 服务的 API Key(新版控制台) | [语音合成控制台](https://console.volcengine.com/speech/service/16) |
|
|
79
80
|
| `VOLCENGINE_STT_API_KEY` | STT 服务的 API Key(新版控制台) | [语音识别控制台](https://console.volcengine.com/speech/service/16) |
|
|
80
81
|
| `VOLCENGINE_LLM_API_KEY` | LLM 服务的 API 密钥 | [大模型控制台](https://console.volcengine.com/ark/) |
|
|
81
|
-
| `
|
|
82
|
+
| `VOLCENGINE_REALTIME_API_KEY` | 实时服务的 API Key(新版控制台) | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
|
|
82
83
|
| `VOLCENGINE_TTS_RESOURCE_ID` | TTS 资源 ID,默认 `seed-tts-2.0` | [豆包语音合成接口文档](https://www.volcengine.com/docs/6561/1257584) |
|
|
83
84
|
|
|
84
85
|
### .env 文件示例
|
|
@@ -88,7 +89,7 @@ pip install -e .
|
|
|
88
89
|
VOLCENGINE_TTS_API_KEY=your_tts_api_key_here
|
|
89
90
|
VOLCENGINE_STT_API_KEY=your_stt_api_key_here
|
|
90
91
|
VOLCENGINE_LLM_API_KEY=your_llm_api_key_here
|
|
91
|
-
|
|
92
|
+
VOLCENGINE_REALTIME_API_KEY=your_realtime_api_key_here
|
|
92
93
|
```
|
|
93
94
|
|
|
94
95
|
## 📖 使用指南
|
|
@@ -105,8 +106,7 @@ async def entry_point(ctx: JobContext):
|
|
|
105
106
|
|
|
106
107
|
# 使用实时语音模型
|
|
107
108
|
llm = volcengine.RealtimeModel(
|
|
108
|
-
|
|
109
|
-
access_token="your_access_token",
|
|
109
|
+
api_key="your_api_key",
|
|
110
110
|
bot_name="智能助手",
|
|
111
111
|
model="O" # 或 "SC"
|
|
112
112
|
)
|
|
@@ -164,8 +164,7 @@ async def entry_point(ctx: JobContext):
|
|
|
164
164
|
|
|
165
165
|
# 基础实时语音模型配置
|
|
166
166
|
realtime_llm = volcengine.RealtimeModel(
|
|
167
|
-
|
|
168
|
-
access_token="your_access_token",
|
|
167
|
+
api_key="your_api_key",
|
|
169
168
|
bot_name="豆包", # 机器人名称
|
|
170
169
|
model="O" # 默认使用O版本,功能全面
|
|
171
170
|
)
|
|
@@ -198,8 +197,7 @@ async def entry_point(ctx: JobContext):
|
|
|
198
197
|
|
|
199
198
|
# 高级配置 - 包含网络搜索和RAG功能
|
|
200
199
|
realtime_llm = volcengine.RealtimeModel(
|
|
201
|
-
|
|
202
|
-
access_token="your_access_token",
|
|
200
|
+
api_key="your_api_key",
|
|
203
201
|
bot_name="智能助手",
|
|
204
202
|
model="O", # O版本支持联网搜索和RAG,SC版本专注角色扮演
|
|
205
203
|
enable_volc_websearch=True, # 启用联网搜索
|
|
@@ -307,8 +305,7 @@ async def entry_point(ctx: JobContext):
|
|
|
307
305
|
|
|
308
306
|
# SC版本支持角色配置和克隆音色
|
|
309
307
|
realtime_llm = volcengine.RealtimeModel(
|
|
310
|
-
|
|
311
|
-
access_token="your_access_token",
|
|
308
|
+
api_key="your_api_key",
|
|
312
309
|
bot_name="小智",
|
|
313
310
|
model="SC", # SC版本支持character_manifest
|
|
314
311
|
character_manifest='{ # JSON字符串格式的角色配置
|
|
@@ -375,16 +372,20 @@ if __name__ == "__main__":
|
|
|
375
372
|
|
|
376
373
|
```python
|
|
377
374
|
volcengine.TTS(
|
|
378
|
-
api_key: str,
|
|
379
|
-
resource_id: str | None = None,
|
|
375
|
+
api_key: str, # API Key(新版控制台)
|
|
376
|
+
resource_id: str | None = None, # 默认 seed-tts-2.0
|
|
380
377
|
voice: str = "zh_female_xiaohe_uranus_bigtts",
|
|
381
|
-
speed: float = 1.0,
|
|
382
|
-
volume: float = 1.0,
|
|
383
|
-
pitch: float = 1.0,
|
|
378
|
+
speed: float = 1.0, # 语速倍率(OpenAI 规范),[0.2, 3.0],1.0=正常
|
|
379
|
+
volume: float = 1.0, # 音量倍率(OpenAI 规范),(0.1, 3.0],1.0=正常(mix 音色暂不支持)
|
|
380
|
+
pitch: float = 1.0, # 已废弃,保留仅用于兼容
|
|
384
381
|
sample_rate: Literal[24000, 16000, 8000] = 16000,
|
|
385
382
|
)
|
|
386
383
|
```
|
|
387
384
|
|
|
385
|
+
> `speed` / `volume` 遵循 OpenAI 接口规范(float 倍率),请求时按
|
|
386
|
+
> `speech_rate = round((speed - 1.0) * 200)`(clamp 到 `[-50, 100]`)转换为火山原生
|
|
387
|
+
> `speech_rate` / `loudness_rate` 整型字段。
|
|
388
|
+
|
|
388
389
|
### TTS 资源 ID 说明
|
|
389
390
|
|
|
390
391
|
- `seed-tts-2.0`:豆包语音合成模型 2.0
|
|
@@ -428,8 +429,7 @@ volcengine.LLM(
|
|
|
428
429
|
```python
|
|
429
430
|
volcengine.RealtimeModel(
|
|
430
431
|
# 必需参数
|
|
431
|
-
|
|
432
|
-
access_token: str = None, # 访问令牌,从环境变量 VOLCENGINE_REALTIME_ACCESS_TOKEN 获取
|
|
432
|
+
api_key: str = None, # API Key(新版控制台),从环境变量 VOLCENGINE_REALTIME_API_KEY 获取
|
|
433
433
|
|
|
434
434
|
# 基本配置
|
|
435
435
|
bot_name: str = "豆包", # 机器人名称
|
|
@@ -568,6 +568,7 @@ A: 根据您的应用需求选择合适的版本:
|
|
|
568
568
|
- `volcengine.STT` 补齐 `X-Api-Connect-Id` 握手头
|
|
569
569
|
- `volcengine.STT` 切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
570
570
|
- `volcengine.TTS` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
571
|
+
- `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
|
|
571
572
|
|
|
572
573
|
## 🤝 贡献
|
|
573
574
|
|
|
@@ -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,
|
|
@@ -24,6 +24,27 @@ from livekit.agents.types import DEFAULT_API_CONNECT_OPTIONS
|
|
|
24
24
|
from .log import logger
|
|
25
25
|
|
|
26
26
|
|
|
27
|
+
def _speed_to_speech_rate(speed: float) -> int:
|
|
28
|
+
"""Convert OpenAI-style ``speed`` (1.0 = normal) to Volcengine ``speech_rate``.
|
|
29
|
+
|
|
30
|
+
Mapping: ``speech_rate = round((speed - 1.0) * 200)``, clamped to ``[-50, 100]``.
|
|
31
|
+
|
|
32
|
+
1.0 -> 0, 1.5 -> 100, 0.5 -> -50. Values outside the OpenAI-allowed range
|
|
33
|
+
are clamped at the same boundaries used by the underlying API.
|
|
34
|
+
"""
|
|
35
|
+
rate = round((speed - 1.0) * 200)
|
|
36
|
+
return max(-50, min(100, rate))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def _volume_to_loudness_rate(volume: float) -> int:
|
|
40
|
+
"""Convert OpenAI-style ``volume`` (1.0 = normal) to Volcengine ``loudness_rate``.
|
|
41
|
+
|
|
42
|
+
Same mapping as ``_speed_to_speech_rate``.
|
|
43
|
+
"""
|
|
44
|
+
rate = round((volume - 1.0) * 200)
|
|
45
|
+
return max(-50, min(100, rate))
|
|
46
|
+
|
|
47
|
+
|
|
27
48
|
class _TTSOptions(BaseModel):
|
|
28
49
|
api_key: str
|
|
29
50
|
resource_id: str | None = None
|
|
@@ -31,6 +52,8 @@ class _TTSOptions(BaseModel):
|
|
|
31
52
|
base_url: str = "https://openspeech.bytedance.com"
|
|
32
53
|
sample_rate: Literal[24000, 16000, 8000] = 24000
|
|
33
54
|
encoding: Literal["mp3", "pcm"] = "pcm"
|
|
55
|
+
# OpenAI-style primary interface; converted to Volcengine speech_rate/loudness_rate
|
|
56
|
+
# at request time (see _speed_to_speech_rate / _volume_to_loudness_rate).
|
|
34
57
|
speed: float = Field(1.0, ge=0.2, le=3.0)
|
|
35
58
|
volume: float = Field(1.0, gt=0.1, le=3.0)
|
|
36
59
|
pitch: float = Field(1.0, ge=0.1, le=3.0)
|
|
@@ -53,6 +76,8 @@ class _TTSOptions(BaseModel):
|
|
|
53
76
|
"audio_params": {
|
|
54
77
|
"format": self.encoding,
|
|
55
78
|
"sample_rate": self.sample_rate,
|
|
79
|
+
"loudness_rate": _volume_to_loudness_rate(self.volume),
|
|
80
|
+
"speech_rate": _speed_to_speech_rate(self.speed),
|
|
56
81
|
},
|
|
57
82
|
"request_id": reqid,
|
|
58
83
|
},
|
|
@@ -90,7 +115,10 @@ class TTS(tts.TTS):
|
|
|
90
115
|
api_key (str): the API key of the tts, you can get it from the new console.
|
|
91
116
|
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.
|
|
92
117
|
voice (str, optional): the voice id used by the tts request. Defaults to `zh_female_xiaohe_uranus_bigtts`.
|
|
93
|
-
|
|
118
|
+
speed (float, optional): speech rate multiplier (OpenAI-style). Range [0.2, 3.0]; 1.0 = normal, 2.0 = 2x, 0.5 = 0.5x. Internally converted to the Volcengine ``speech_rate`` int. Defaults to 1.0.
|
|
119
|
+
volume (float, optional): volume multiplier (OpenAI-style). Range (0.1, 3.0]; 1.0 = normal, 2.0 = 2x, 0.5 = 0.5x. Internally converted to the Volcengine ``loudness_rate`` int. Not supported for mix voices. Defaults to 1.0.
|
|
120
|
+
pitch (float, optional): kept for backwards compatibility, not currently sent to the API. Defaults to 1.0.
|
|
121
|
+
sample_rate (Literal[24000, 16000, 8000], optional): the sample rate of the tts. Defaults to 16000.
|
|
94
122
|
streaming (bool, optional): whether to use the streaming api. Defaults to True.
|
|
95
123
|
http_session (aiohttp.ClientSession | None, optional): the http session to use. Defaults to None.
|
|
96
124
|
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.3.3"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.3.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|