🚀 Whisper kotoba-whisper-v2.0 用于 CTranslate2 模型
本仓库包含将 kotoba-tech/kotoba-whisper-v2.0 转换为 CTranslate2 模型格式的内容。
该模型可用于 CTranslate2 或基于 CTranslate2 的项目,如 faster-whisper。
🚀 快速开始
安装库并下载示例音频
pip install faster-whisper
wget https://huggingface.co/kotoba-tech/kotoba-whisper-v1.0-ggml/resolve/main/sample_ja_speech.wav
使用 kotoba-whisper-v2.0-faster 进行推理
from faster_whisper import WhisperModel
model = WhisperModel("kotoba-tech/kotoba-whisper-v2.0-faster")
segments, info = model.transcribe("sample_ja_speech.wav", language="ja", chunk_length=15, condition_on_previous_text=False)
for segment in segments:
print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
💻 使用示例
基础用法
from faster_whisper import WhisperModel
model = WhisperModel("kotoba-tech/kotoba-whisper-v2.0-faster")
segments, info = model.transcribe("sample_ja_speech.wav", language="ja", chunk_length=15, condition_on_previous_text=False)
for segment in segments:
print("[%.2fs -> %.2fs] %s" % (segment.start, segment.end, segment.text))
🔧 技术细节
基准测试
我们在以下配置的 MacBook Pro 上,使用四个不同的日语语音音频测量了不同 kotoba-whisper-v2.0 实现的推理速度:
- Apple M2 Pro
- 32GB 内存
- 14 英寸,2023 款
- 操作系统:Sonoma 版本 14.4.1 (23E224)
重新运行实验的脚本可在以下位置找到:
此外,目前 whisper.cpp 和 faster-whisper 支持 顺序长格式解码,而只有 Huggingface pipeline 支持 分块长格式解码,我们通过经验发现分块长格式解码优于顺序长格式解码。
转换细节
原始模型使用以下命令进行转换:
ct2-transformers-converter --model kotoba-tech/kotoba-whisper-v2.0 --output_dir kotoba-whisper-v2.0-faster \
--copy_files tokenizer.json preprocessor_config.json --quantization float16
请注意,模型权重以 FP16 格式保存。在使用 CTranslate2 中的 compute_type
选项 加载模型时,可以更改此类型。
📚 详细文档
如需了解有关 kotoba-whisper-v2.0 的更多信息,请参考原始 模型卡片。
📄 许可证
本项目采用 MIT 许可证。