Skip to main content

livekit-plugins-xunfei

PyPI version Python 3.9+ License

科大讯飞服务专用的 LiveKit Agents 插件,提供语音识别集成解决方案。

✨ 特性

  • 🎤 语音识别 (STT) - 支持科大讯飞实时语音识别服务
  • 实时处理 - 支持实时语音转文字
  • 📦 开箱即用 - 完整的 Python 包支持

📋 支持的服务

服务 描述 文档链接
STT 实时语音识别 讯飞实时语音转写

🛠️ 安装

使用 pip 安装

pip install livekit-plugins-xunfei

从源码安装

git clone https://github.com/your-repo/livekit-plugins-volcengine.git
cd livekit-plugins-volcengine
pip install -e ./livekit-plugins/livekit-plugins-xunfei

系统要求

  • Python >= 3.9
  • LiveKit Agents >= 1.2.9

⚙️ 配置

环境变量

在使用插件前,请配置以下环境变量:

环境变量 描述 获取方式
XUNFEI_STT_APP_ID 讯飞应用ID 讯飞开放平台
XUNFEI_STT_API_KEY 讯飞API密钥 讯飞开放平台

.env 文件示例

# .env
XUNFEI_STT_APP_ID=your_app_id
XUNFEI_STT_API_KEY=your_api_key

📖 使用指南

基础使用

from livekit.agents import Agent, AgentSession, JobContext, cli, WorkerOptions
from livekit.plugins import xunfei
from dotenv import load_dotenv

async def entry_point(ctx: JobContext):
    agent = Agent(instructions="You are a helpful assistant.")

    session = AgentSession(
        # 语音识别 - 参数可从讯飞开放平台获取
        stt=xunfei.STT(
            app_id="your_app_id",
            api_key="your_api_key"
        )
    )

    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 xunfei

# 自定义STT配置
stt = xunfei.STT(
    app_id="your_app_id",        # 应用ID
    api_key="your_api_key",      # API密钥
    api_secret="your_api_secret", # API密钥 (可选)
    domain="iat",                # 领域 (iat: 实时语音识别)
    language="zh_cn",            # 语言 (zh_cn: 中文, en_us: 英文)
    accent="mandarin",           # 方言 (mandarin: 普通话)
    sample_rate=16000,           # 采样率
    format="wav"                 # 音频格式
)

🔧 API 参考

STT (语音识别)

xunfei.STT(
    app_id: str,                    # 应用ID
    api_key: str,                   # API密钥
    api_secret: str = None,         # API密钥 (可选)
    domain: str = "iat",            # 领域
    language: str = "zh_cn",        # 语言
    accent: str = "mandarin",       # 方言
    sample_rate: int = 16000,       # 采样率
    format: str = "wav"             # 音频格式
)

❓ 常见问题

Q: 如何获取讯飞的认证信息?

A: 请访问讯飞开放平台,创建语音识别应用并获取:

  • App ID: 应用ID
  • API Key: API密钥
  • API Secret: API密钥 (可选)

Q: 支持哪些语言和方言?

A: 支持多种语言和方言:

  • 中文: zh_cn (普通话、四川话、粤语等)
  • 英文: en_us
  • 其他语言: 根据讯飞平台支持情况

Q: 如何优化识别效果?

A: 可以通过以下方式优化识别效果:

  • 选择合适的语言和方言设置
  • 确保音频采样率匹配 (推荐16000Hz)
  • 使用高质量的音频输入
  • 根据应用场景选择合适的领域参数

📝 更新日志

v1.2.9

  • 支持科大讯飞实时语音识别服务
  • 支持多种语言和方言
  • 完善的API文档和使用示例

🤝 贡献

欢迎提交 Issue 和 Pull Request!

  1. Fork 本项目
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 打开 Pull Request

📄 许可证

本项目采用 Apache 2.0 许可证 - 查看 LICENSE 文件了解详情。

📞 联系我们

🙏 致谢

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

livekit_plugins_xunfei-1.3.0.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

livekit_plugins_xunfei-1.3.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file livekit_plugins_xunfei-1.3.0.tar.gz.

File metadata

  • Download URL: livekit_plugins_xunfei-1.3.0.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for livekit_plugins_xunfei-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5a2268b4c0f7331a28207048bb4392702e4e93537a9ed203991a0a2b7f2144ef
MD5 20b6e44b3249aec1c859d7350d1ce463
BLAKE2b-256 9384c791c40df25e5f19bd7e55b3e7d6c154e55a9882b1a9ce0daab529b072f5

See more details on using hashes here.

File details

Details for the file livekit_plugins_xunfei-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: livekit_plugins_xunfei-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for livekit_plugins_xunfei-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6218ef01d2d036f9a775cafc500bb084f92be6fca581bf7e7e61601b0f583785
MD5 870c0a9d719dc1b4665cc8d8d22510cf
BLAKE2b-256 53fc5add22540855fd1229894cd4229b3be8c97840580d9ec23bbdf6568a5df0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.3.0 This release

2 files

1.2.9.post0

2 files

1.2.9

2 files

1.2.8

2 files

1.2.6

2 files

1.2.3.post1

2 files

1.2.3.post0

2 files

1.2.3

2 files

1.2.2

2 files

1.2.0

2 files

1.1.5.post0

2 files

1.1.5

2 files

1.1.2.post7

2 files

1.1.2.post6

2 files

1.1.2.post5

2 files

1.1.2.post4

2 files

1.1.2.post3

2 files

1.1.2.post2

2 files

1.1.2.post1

2 files

1.1.2.post0

2 files

1.1.2

2 files

1.1.0.post4

2 files

1.1.0.post2

2 files

1.1.0.post1

2 files

1.1.0.post0

2 files

1.1.0

2 files

1.0.23

2 files

1.0.17.post0

2 files

1.0.17

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page