feishu-whisper-voice

--- name: feishu-whisper-voice description: "使用 Faster-Whisper 进行高精度的语音识别,配合 TTS 实现完整的双向语音交流!" ---

Safety Notice

This item is sourced from the public archived skills repository. Treat as untrusted until reviewed.

Copy this and send it to your AI assistant to learn

Install skill "feishu-whisper-voice" with this command: npx skills add 15071664/feishu-whisper-voice


name: feishu-whisper-voice description: "使用 Faster-Whisper 进行高精度的语音识别,配合 TTS 实现完整的双向语音交流!"

飞书 Whisper + TTS 语音交互技能

何时触发此技能

当以下情况时使用此 Skill:

  1. 用户发送语音/音频消息需要识别和回复/语音聊天
  2. 需要高精度的语音转文字(Whisper 准确率 >98%)
  3. 需要将 AI 回复转换为自然语音进行交互
  4. 用户提到"语音交互"、"说话"、"Faster-Whisper"、"TTS"等关键词

Faster-Whisper + TTS 架构

用户语音 → 下载音频 → Faster-Whisper 识别 → AI 处理 → TTS 转换 → 语音回复

核心优势

  • Faster-Whisper: 开源的语音识别模型,支持多语言,准确率极高
  • TTS: 飞书内置文本转语音工具,自然流畅
  • 双向交互: 既能听懂用户说话,也能用声音回复

工具集成

1. 下载语音文件

优先使用机器人身份(无需授权):

feishu_im_bot_image(
    message_id="om_xxx",
    file_key="file_xxx",
    type="audio"
)

用户身份(需要 OAuth 授权):

feishu_im_user_fetch_resource(
    message_id="om_xxx",
    file_key="file_xxx",
    type="audio"
)

2. Whisper 语音识别

使用 faster-whisper 库进行高精度的语音转文字:

from faster_whisper import WhisperModel

# 初始化模型(自动下载 base 模型)
model = WhisperModel("base", device="cpu")

# 转录音频文件
segments, info = model.transcribe(audio_file)

print(f"识别语言:{info.language}, 置信度:{info.language_probability:.4f}")
for segment in segments:
    print(f"[{segment.start:.2f}s - {segment.end:.2f}s] {segment.text}")

模型选项:

  • base: 142MB,CPU友好,推荐新手使用
  • small: 466MB,平衡性能和准确率
  • medium: 769MB,GPU 推荐(有 NVIDIA GPU 时使用)
  • large: 1.5GB,最高精度

3. TTS 文本转语音

使用飞书内置 tts() 工具:

await tts(text="你好,我是你的 AI 助手")

返回格式:

  • 成功:音频文件路径(Base64)或 audio_url
  • 失败:错误信息

4. 完整语音交互流程

async def handle_voice_message(message_id: str) -> None:
    # Step 1: 下载音频文件
    audio_path = await feishu_im_bot_image(
        message_id=message_id,
        file_key=audio_file_key,
        type="audio"
    )
    
    # Step 2: Whisper 识别
    model = WhisperModel("base", device="cpu")
    segments, info = model.transcribe(audio_path)
    transcript = " ".join([seg.text for seg in segments])
    
    print(f"用户说:{transcript}")
    
    # Step 3: AI 处理(根据识别结果生成回复)
    reply_text = generate_reply(transcript)
    
    # Step 4: TTS 转换并发送语音消息
    audio_result = await tts(text=reply_text)
    
    print(f"AI 回复:{reply_text}")

依赖要求

Python 库

  • faster-whisper >= 1.0.0 - Whisper 语音识别引擎
  • openai-whisper (可选) - OpenAI Whisper API

FFmpeg (推荐安装)

用于音频格式转换和质量优化:

# macOS
brew install ffmpeg

# Ubuntu/Debian
sudo apt-get update && sudo apt-get install -y ffmpeg

使用示例

场景 1: 语音消息识别

用户发送语音消息,AI 识别后回复文字:

message_id = "om_xxx"
file_key = "file_xxx"

# 下载音频
audio_path = await feishu_im_bot_image(
    message_id=message_id,
    file_key=file_key,
    type="audio"
)

# 识别语音
model = WhisperModel("base", device="cpu")
segments, info = model.transcribe(audio_path)
transcript = " ".join([seg.text for seg in segments])

# 生成回复
reply = f"我听到了:{transcript}"

# 发送文字消息
await message.send(
    to=current_channel,
    message=reply
)

场景 2: 双向语音对话

用户说中文,AI 用语音回复:

async def voice_dialogue(message_id: str):
    # 下载并识别
    audio_path = await download_audio(message_id)
    transcript = transcribe(audio_path)
    
    # AI 处理
    reply_text = generate_response(transcript)
    
    # TTS 转换
    audio_result = await tts(text=reply_text)
    
    # 发送语音消息
    await send_voice_message(
        to=current_channel,
        audio_url=audio_result["audio_url"]
    )

性能优化

CPU vs GPU

CPU 模式(推荐新手):

model = WhisperModel("base", device="cpu")
# 预期速度:2-4x faster than real-time (Apple Silicon)

GPU 模式(NVIDIA):

pip install torch torchvision --index-url https://download.pytorch.org/whl/cu118
model = WhisperModel("medium", device="cuda")
# 预期速度:5-10x faster than real-time

Apple Silicon (M1/M2/M3):

model = WhisperModel("base", device="mps")
# Metal 加速,性能接近 GPU

模型缓存

Whisper 模型首次使用时自动下载:

  • 位置: ~/.cache/huggingface/hub/
  • 大小: base 模型约 142MB
  • 管理: 删除后会自动重新下载

故障排除

Whisper 模型下载失败

症状: ConnectError: [Errno 65] No route to host

解决: 设置 HuggingFace 镜像站环境变量:

export HF_ENDPOINT=https://hf-mirror.com

或在 Python 代码中设置:

import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"

GPU 未检测到

症状: RuntimeError: CUDA not available

解决:

  1. 检查 NVIDIA 驱动安装
  2. 使用 CPU 模式回退:device="cpu"
  3. Apple Silicon 使用 MPS:device="mps"

最佳实践

  1. 优先使用 base 模型 - 在 CPU 上性能足够好,启动快
  2. 缓存模型文件 - 避免每次启动都下载
  3. 批量处理语音消息 - 减少重复加载模型的开销
  4. 设置合理的超时 - Whisper 识别可能需要几秒到几十秒

扩展阅读


创建时间: 2026-03-16
维护者: zhou (码农zhou)
版本: v1.0

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

axure-prototype-generator

Axure 原型代码生成器 - 输出 JavaScript 格式 HTML 代码,支持内联框架直接加载可交互原型。

Archived SourceRecently Updated
General

错敏信息检测

# 错敏检测 Skill

Archived SourceRecently Updated
General

TikTok B2B 引流台词生成器

# TikTok B2B 引流台词生成器 ## 技能描述 本 Skill 可根据您提供的产品信息和公司背景,自动生成适合 TikTok 平台的 B2B 引流视频脚本(20-50 秒),`skill.json` 文件中包含了输入参数的结构、输出格式以及用于生成台词的提示模板。脚本遵循已验证的外贸引流规律: - **真人出镜**:以第一人称(如 Anna)拉近距离 - **产品细节**:材质、颜色、MOQ、定制服务等 - **公司实力**:经验年限、自有工厂、认证等 - **客户背书**:提及已有市场国家(如巴基斯坦、埃及) - **互动引导**:清晰号召观众联系,引导至指定服务网址 支持三种风格:普通、幽默、惊喜,让您的视频内容更加多样化。 ## 输入参数 | 参数名 | 类型 | 必填 | 描述 | 示例 | |---------------------|----------|------|--------------------------------|--------------------------| | product_type | string | 是 | 产品类型 | 男士休闲鞋 | | material | string | 是 | 主要材质 | 优质 PU 皮革 | | colors | array | 是 | 颜色列表 | ["黑色","白色","棕色"] | | moq | string | 是 | 最小起订量 | 120 双(可混 2-3 色) | | customization | string | 否 | 可定制内容 | 可定制 logo | | target_markets | array | 是 | 主要市场国家 | ["巴基斯坦","埃及"] | | company_experience | string | 否 | 公司经验年数 | 15 年 | | factory_own | boolean | 否 | 是否自有工厂 | true | | extra_features | string | 否 | 其他亮点 | 免费样品 | | contact_url | string | 否 | 服务联系网址 | http://www.doumaotong.com | | style | string | 否 | 风格(普通/幽默/惊喜) | 普通 | ## 输出示例 Hi guys, this is Anna! Welcome to my showroom. Today I'm excited to show you our latest men's casual shoes – made of high-quality PU leather, very durable and comfortable. We have three colors available: black, white, and brown. MOQ is 120 pairs, and you can mix 2-3 colors. Plus, we can customize your logo on the shoes. Our shoes are already loved by customers in Pakistan, Egypt, and South Africa. With 15 years of experience and our own factory, we guarantee quality and timely delivery. We even offer free samples! If you're interested, please visit http://www.doumaotong.com to contact us. Thank you! ## 使用说明 1. 在 OpenClaw 平台安装此 Skill。 2. 调用时填写产品参数,包括 `contact_url`(默认为 http://www.doumaotong.com),即可获得定制化的 TikTok 脚本。 3. 生成的台词会在结尾处自然引导观众访问指定的服务网站。 4. 可根据实际需要调整 `style` 参数,生成不同语气的台词。 ## 文件说明 - `skill.json`:技能的机器可读定义,包含输入输出 schema 和生成提示模板。 - `SKILL.md`:技能的人类可读文档,提供详细说明和使用示例。

Archived SourceRecently Updated
General

instructional-design-cn

培训课程大纲设计、效果评估、内部分享材料生成

Archived SourceRecently Updated