LiveKit Agent Plugins for Alibaba Cloud
Project description
livekit-plugins-aliyun
阿里云服务专用的 LiveKit Agents 插件,提供完整的语音和语言模型集成解决方案。
✨ 特性
- 🎤 语音识别 (STT) - 支持阿里云Paraformer语音识别服务
- 🗣️ 语音合成 (TTS) - 支持阿里云CosyVoice文本转语音服务
- 🤖 大语言模型 (LLM) - 支持阿里云Qwen系列大模型
- 🔧 热词功能 - 支持STT热词识别增强
- 📦 开箱即用 - 完整的 Python 包支持
📋 支持的服务
| 服务 | 描述 | 文档链接 |
|---|---|---|
| TTS | 文本转语音 | 阿里云TTS |
| STT | 语音识别 | 阿里云ASR |
| LLM | 大语言模型 | 阿里云LLM |
🛠️ 安装
使用 pip 安装
pip install livekit-plugins-aliyun
从源码安装
git clone https://github.com/your-repo/livekit-plugins-volcengine.git
cd livekit-plugins-volcengine
pip install -e ./livekit-plugins/livekit-plugins-aliyun
系统要求
- Python >= 3.9
- LiveKit Agents >= 1.2.9
⚙️ 配置
环境变量
在使用插件前,请配置以下环境变量:
| 环境变量 | 描述 | 获取方式 |
|---|---|---|
DASHSCOPE_API_KEY |
DashScope API 密钥 | 阿里云控制台 |
.env 文件示例
# .env
DASHSCOPE_API_KEY=your_dashscope_api_key_here
📖 使用指南
基础使用
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
from livekit.plugins import aliyun
from dotenv import load_dotenv
async def entry_point(ctx: JobContext):
agent = Agent(instructions="You are a helpful assistant.")
session = AgentSession(
# 语音识别
stt=aliyun.STT(model="paraformer-realtime-v2"),
# 语音合成
tts=aliyun.TTS(model="cosyvoice-v2", voice="longcheng_v2"),
# 大语言模型
llm=aliyun.LLM(model="qwen-plus")
)
await session.start(agent=agent, room=ctx.room)
await ctx.connect()
if __name__ == "__main__":
load_dotenv()
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
STT热词功能
阿里云STT支持热词功能,可以提高特定词汇的识别准确率:
from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
from livekit.plugins import aliyun
from dotenv import load_dotenv
async def entry_point(ctx: JobContext):
agent = Agent(instructions="You are a helpful assistant.")
session = AgentSession(
# 配置热词功能的STT
stt=aliyun.STT(
model="paraformer-realtime-v2",
vocabulary_id="your_vocabulary_id" # 热词表ID
),
tts=aliyun.TTS(model="cosyvoice-v2", voice="longcheng_v2"),
llm=aliyun.LLM(model="qwen-plus")
)
await session.start(agent=agent, room=ctx.room)
await ctx.connect()
if __name__ == "__main__":
load_dotenv()
cli.run_app(WorkerOptions(entrypoint_fnc=entry_point))
高级配置
from livekit.plugins import aliyun
# 自定义TTS配置
tts = aliyun.TTS(
model="cosyvoice-v2",
voice="longcheng_v2", # 语音类型
speech_rate=1.0, # 语速 (0.5-2.0)
pitch_rate=1.0, # 音调 (0.5-2.0)
volume=50 # 音量 (0-100)
)
# 自定义LLM配置
llm = aliyun.LLM(
model="qwen-max", # 模型名称
temperature=0.7, # 温度
max_tokens=2000 # 最大token数
)
# 自定义STT配置
stt = aliyun.STT(
model="paraformer-realtime-v2",
vocabulary_id="your_vocabulary_id", # 热词表ID
format="wav", # 音频格式
sample_rate=16000 # 采样率
)
🔧 API 参考
TTS (文本转语音)
aliyun.TTS(
model: str = "cosyvoice-v2", # 模型名称
voice: str = "longcheng_v2", # 语音类型
speech_rate: float = 1.0, # 语速 (0.5-2.0)
pitch_rate: float = 1.0, # 音调 (0.5-2.0)
volume: int = 50 # 音量 (0-100)
)
STT (语音识别)
aliyun.STT(
model: str = "paraformer-realtime-v2", # 模型名称
vocabulary_id: str = None, # 热词表ID
format: str = "wav", # 音频格式
sample_rate: int = 16000 # 采样率
)
LLM (大语言模型)
aliyun.LLM(
model: str = "qwen-plus", # 模型名称
temperature: float = 0.7, # 温度
max_tokens: int = 2000 # 最大token数
)
❓ 常见问题
Q: 如何获取 DashScope API 密钥?
A: 请访问阿里云控制台,在DashScope服务页面创建API密钥。
Q: 支持哪些语音合成模型?
A: 支持多种阿里云语音合成模型,包括:
cosyvoice-v2- CosyVoice v2 模型sambert-zhichu- 智谱系列模型- 其他阿里云TTS支持的模型
Q: 如何创建和管理热词表?
A: 在阿里云控制台的语音识别服务中,可以创建热词表来提高特定词汇的识别准确率。创建后会获得 vocabulary_id,在STT配置中使用。
Q: 支持哪些大语言模型?
A: 支持阿里云Qwen系列模型,包括:
qwen-plus- Qwen Plus 模型qwen-max- Qwen Max 模型qwen-turbo- Qwen Turbo 模型- 其他Qwen系列模型
📝 更新日志
v1.2.9
- 支持阿里云TTS、STT、LLM服务
- 支持STT热词功能
- 完善的API文档和使用示例
🤝 贡献
欢迎提交 Issue 和 Pull Request!
- Fork 本项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 打开 Pull Request
📄 许可证
本项目采用 Apache 2.0 许可证 - 查看 LICENSE 文件了解详情。
📞 联系我们
- 项目主页: GitHub
- 问题反馈: Issues
- 邮箱: 790990241@qq.com
🙏 致谢
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file livekit_plugins_aliyun-1.2.9.post0.tar.gz.
File metadata
- Download URL: livekit_plugins_aliyun-1.2.9.post0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab710edab1c1f5a090c626eadaab181d36c52964e2a8e4b77ddaf6cbe027ae88
|
|
| MD5 |
d00e6d3b7c60e15d2cd4f2401cf7751f
|
|
| BLAKE2b-256 |
39f6069c6d01485c3ee65601fe208de611978874e81b0444881981f3193ea1d5
|
File details
Details for the file livekit_plugins_aliyun-1.2.9.post0-py3-none-any.whl.
File metadata
- Download URL: livekit_plugins_aliyun-1.2.9.post0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe8fc3467d98a5aaf45d206cf7c77aa48654283b4988c0c842ec401f25a9c50c
|
|
| MD5 |
06692cdf3b5c0eee48268e1cb814ce1d
|
|
| BLAKE2b-256 |
141350f8009ea1424bfd549667f14946117f770148e2c0912d8222391d3584dd
|