📦 Speech Recognition — 语音识别
v1.0.0使用 pysilk 解码和 faster-whisper 转录,将 AMR/SILK 格式的 QQ 语音消息转换为文本。
运行时依赖
安装命令
点击复制技能文档
Speech Recognition 语音识别
将 AMR/SILK 格式的语音转换为文字。
环境要求 Python 虚拟环境:source /opt/conda/bin/activate py314 依赖包:pysilk, faster-whisper 模型路径:/opt/workspace/yby_workspace/whisper-模型 使用方式 from 技能s.speech_recognition 导入 transcribe_audio
text = transcribe_audio("/path/to/audio.amr") print(text)
实现逻辑 读取 AMR/SILK 格式文件 使用 pysilk 解码为 PCM 数据 保存为 WAV 文件 使用 faster-whisper 转写为文字 返回识别结果 支持格式 QQ 语音:.amr (SILK_V3 编码) 标准 AMR:amr, amrnb, amrwb 依赖安装 source /opt/conda/bin/activate py314 pip 安装 pysilk faster-whisper
模型下载
需要从 HuggingFace 下载 faster-whisper 模型:
python3 -m huggingface_hub snapshot-下载 \ --repo-type 模型 \ --repo-id Systran/faster-whisper-base \ --local-dir /opt/workspace/yby_workspace/whisper-模型
需要的文件:
模型.bin config.json 令牌izer.json vocabulary.txt