← 返回
未分类

feishu-asr

使用本地Whisper模型识别飞书语音消息。离线免费,不需要注册,不需要联网。
本地Whisper模型识别飞书语音,离线免费,无需注册联网。
richardcoder849 richardcoder849 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 368
下载
💾 0
安装
1
版本
#latest

概述

飞书语音识别 ASR

触发条件

  • 用户发送飞书语音消息
  • 用户要求将语音转为文字
  • 用户提到"语音识别"、"转文字"

工作流程

1. 获取语音文件

从飞书消息中获取语音文件的file_key,下载为.ogg或.m4a格式。

2. 音频格式转换

使用Python soundfile将音频转换为16kHz采样的WAV格式:

import soundfile as sf
audio, sr = sf.read(voice_file)
# 如果是立体声,转为单声道
if len(audio.shape) > 1:
    audio = audio.mean(axis=1)
sf.write('output.wav', audio, 16000)

3. 使用Whisper识别

import os
os.environ['HF_ENDPOINT'] = 'https://hf-mirror.com'  # 国内镜像

from transformers import WhisperForConditionalGeneration, WhisperProcessor, WhisperFeatureExtractor
import soundfile as sf

# 读取音频
audio, sr = sf.read('output.wav')
if len(audio.shape) > 1:
    audio = audio.mean(axis=1)

# 加载模型
processor = WhisperProcessor.from_pretrained('openai/whisper-tiny')
model = WhisperForConditionalGeneration.from_pretrained('openai/whisper-tiny')
feature_extractor = WhisperFeatureExtractor.from_pretrained('openai/whisper-tiny')

# 识别
input_features = feature_extractor(audio, sampling_rate=16000, return_tensors='pt').input_features
with torch.no_grad():
    predicted_ids = model.generate(input_features)

result = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]

依赖安装

pip install torch transformers soundfile

模型选择

  • whisper-tiny: 75MB,适合CPU,最快
  • whisper-base: 142MB,精度更好
  • whisper-small: 466MB,精度高

注意事项

  • 首次运行需要下载模型(约75MB-3GB)
  • 建议使用国内镜像:HF_ENDPOINT=https://hf-mirror.com
  • 模型会自动检测语言

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-07 08:10 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

design-media

UI/UX Pro Max

xobi667
提供 UI/UX 设计智能与实现指导,帮助打造精美界面。适用于 UI 设计、UX 流程、信息架构、视觉风格、设计系统/标记、组件规格、文案/微文案、无障碍及前端 UI(HTML/CSS/JS、React、Next.js、Vue、Svelte
★ 217 📥 47,468
design-media

Nano Banana Pro

steipete
使用 Nano Banana Pro (Gemini 3 Pro Image) 生成或编辑图像。支持文生图、图生图及 1K/2K/4K 分辨率,适用于图像创建、修改及编辑请求,使用 --input-image 指定输入图像。
★ 429 📥 116,865
ai-agent

Multi-agent-bot-feishu

richardcoder849
在 OpenClaw 中创建新的 Agent 并绑定到新的飞书机器人/群聊。用于:(1) 添加新 Agent 管理不同飞书群聊 (2) 实现多机器人路由 (3) 为不同业务线创建独立 Agent。需修改 ~/.openclaw/opencl
★ 1 📥 691