🚀 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 許可證。