livekit-plugins-volcenginee 1.3.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-volcenginee
3
- Version: 1.3.1
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
@@ -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
- | `VOLCENGINE_REALTIME_ACCESS_TOKEN` | 实时服务的访问令牌 | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
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
- VOLCENGINE_REALTIME_ACCESS_TOKEN=your_realtime_token_here
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
- app_id="your_app_id",
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
- app_id="your_app_id",
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
- app_id="your_app_id",
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
- app_id="your_app_id",
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字符串格式的角色配置
@@ -400,9 +397,11 @@ volcengine.TTS(
400
397
  api_key: str, # API Key(新版控制台)
401
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, # 已废弃,保留仅用于兼容
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 音色暂不支持)
406
405
  sample_rate: Literal[24000, 16000, 8000] = 16000,
407
406
  )
408
407
  ```
@@ -450,8 +449,7 @@ volcengine.LLM(
450
449
  ```python
451
450
  volcengine.RealtimeModel(
452
451
  # 必需参数
453
- app_id: str = None, # 应用ID,从环境变量 VOLCENGINE_REALTIME_APP_ID 获取
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 = "豆包", # 机器人名称
@@ -590,6 +588,7 @@ A: 根据您的应用需求选择合适的版本:
590
588
  - `volcengine.STT` 补齐 `X-Api-Connect-Id` 握手头
591
589
  - `volcengine.STT` 切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
592
590
  - `volcengine.TTS` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
591
+ - `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
593
592
 
594
593
  ## 🤝 贡献
595
594
 
@@ -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
- | `VOLCENGINE_REALTIME_ACCESS_TOKEN` | 实时服务的访问令牌 | [实时语音控制台](https://console.volcengine.com/speech/service/10011) |
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
- VOLCENGINE_REALTIME_ACCESS_TOKEN=your_realtime_token_here
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
- app_id="your_app_id",
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
- app_id="your_app_id",
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
- app_id="your_app_id",
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
- app_id="your_app_id",
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字符串格式的角色配置
@@ -378,9 +375,11 @@ volcengine.TTS(
378
375
  api_key: str, # API Key(新版控制台)
379
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, # 已废弃,保留仅用于兼容
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 音色暂不支持)
384
383
  sample_rate: Literal[24000, 16000, 8000] = 16000,
385
384
  )
386
385
  ```
@@ -428,8 +427,7 @@ volcengine.LLM(
428
427
  ```python
429
428
  volcengine.RealtimeModel(
430
429
  # 必需参数
431
- app_id: str = None, # 应用ID,从环境变量 VOLCENGINE_REALTIME_APP_ID 获取
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 = "豆包", # 机器人名称
@@ -568,6 +566,7 @@ A: 根据您的应用需求选择合适的版本:
568
566
  - `volcengine.STT` 补齐 `X-Api-Connect-Id` 握手头
569
567
  - `volcengine.STT` 切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
570
568
  - `volcengine.TTS` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
569
+ - `volcengine.RealtimeModel` 同步切换到新版控制台鉴权,移除 `app_id` / `access_token`,改用单一 `api_key` 并发送 `X-Api-Key` 头
571
570
 
572
571
  ## 🤝 贡献
573
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
- app_id: str
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-App-ID": self.app_id,
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
- app_id: str | None = None,
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
- app_id = app_id or os.environ.get("VOLCENGINE_REALTIME_APP_ID")
303
- if app_id is None:
304
- raise ValueError("VOLCENGINE_REALTIME_APP_ID is required")
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
- app_id=app_id,
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,
@@ -34,6 +34,8 @@ class _TTSOptions(BaseModel):
34
34
  speed: float = Field(1.0, ge=0.2, le=3.0)
35
35
  volume: float = Field(1.0, gt=0.1, le=3.0)
36
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)
37
39
 
38
40
  def get_http_url(self) -> str:
39
41
  return f"{self.base_url}/api/v3/tts/unidirectional"
@@ -53,6 +55,8 @@ class _TTSOptions(BaseModel):
53
55
  "audio_params": {
54
56
  "format": self.encoding,
55
57
  "sample_rate": self.sample_rate,
58
+ "loudness_rate": self.loudness_rate,
59
+ "speech_rate": self.speech_rate,
56
60
  },
57
61
  "request_id": reqid,
58
62
  },
@@ -81,6 +85,8 @@ class TTS(tts.TTS):
81
85
  speed: float = 1.0,
82
86
  volume: float = 1.0,
83
87
  pitch: float = 1.0,
88
+ speech_rate: int = 0,
89
+ loudness_rate: int = 0,
84
90
  sample_rate: Literal[24000, 16000, 8000] = 16000,
85
91
  http_session: aiohttp.ClientSession | None = None,
86
92
  ):
@@ -90,6 +96,11 @@ class TTS(tts.TTS):
90
96
  api_key (str): the API key of the tts, you can get it from the new console.
91
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.
92
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).
93
104
  sample_rate (Literal[24000, 16000, 8000], optional): the sample rate of the tts. Defaults to 24000.
94
105
  streaming (bool, optional): whether to use the streaming api. Defaults to True.
95
106
  http_session (aiohttp.ClientSession | None, optional): the http session to use. Defaults to None.
@@ -107,6 +118,8 @@ class TTS(tts.TTS):
107
118
  speed=speed,
108
119
  volume=volume,
109
120
  pitch=pitch,
121
+ speech_rate=speech_rate,
122
+ loudness_rate=loudness_rate,
110
123
  )
111
124
  self._session = http_session
112
125
  self._streams = weakref.WeakSet[SynthesizeStream]()
@@ -0,0 +1 @@
1
+ __version__ = "1.3.2"
@@ -1 +0,0 @@
1
- __version__ = "1.3.1"