Whisper 音频转写技能用于将音频文件转录为文本,底层使用 OpenAI Whisper。
用途 该技能面向需要把语音内容转换为可编辑文本的场景,例如整理会议录音、访谈记录、字幕素材等。它通过命令行脚本完成转写,不依赖图形界面。
主要能力
- 将音频文件(MP3、WAV、M4A、FLAC、OGG 等)转写为文本。
- 支持 90 多种语言,并可自动检测语言。
- 可选生成时间戳。
- 提供多种模型大小:tiny、base、small、medium、large。
- 输出格式支持纯文本或 JSON。
使用方式 基本转写命令: python3 scripts/transcribe.py <audio_file> <output_file>
带选项的示例:
指定模型大小(默认:base)
python3 scripts/transcribe.py audio.mp3 transcript.txt --model medium
指定语言(可提高准确率)
python3 scripts/transcribe.py audio.mp3 transcript.txt --language zh
包含时间戳
python3 scripts/transcribe.py audio.mp3 transcript.txt --timestamps
输出 JSON 及元数据
python3 scripts/transcribe.py audio.mp3 output.json --format json
参数说明
- audio_file(必填):输入音频文件路径。
- output_file(必填):输出文本或 JSON 文件路径。
- --model:Whisper 模型大小(tiny/base/small/medium/large,默认 base)。
- --language:语言代码(如 en、zh、es、fr,auto 表示自动检测)。
- --timestamps:在输出中包含词级时间戳。
- --format:输出格式(text/json,默认 text)。
模型大小
- tiny:39M 参数,约 32 倍速,准确率 Good,内存约 1GB。
- base:74M 参数,约 16 倍速,准确率 Better,内存约 1GB。
- small:244M 参数,约 6 倍速,准确率 Great,内存约 2GB。
- medium:769M 参数,约 2 倍速,准确率 Excellent,内存约 5GB。
- large:1.5B 参数,1 倍速,准确率 Best,内存约 10GB。
支持的音频格式 MP3、WAV、M4A、FLAC、OGG、AAC、WMA 等(通过 FFmpeg 支持)。
依赖
- Python 3.8+
- openai-whisper
- ffmpeg
安装 pip install openai-whisper sudo apt-get install ffmpeg # Ubuntu/Debian
适用场景 适合需要批量或脚本化处理音频转文字的开发者与内容工作者,可根据对速度、准确率和内存的权衡选择不同模型大小。
限制 资料未提供关于收费、价格、平台支持范围、转写时长上限或并发能力的信息,暂未提供。