kotoba-whisper-v2.0で日本語高速文字起こし

先日OpenAIのWhisperという文字起こしソフトウェアで新しいlarge-v3-turboというモデルを試しました.

今回 whisper-large-v3 を蒸留技術により日本語に最適化して6.3倍に高速化したという kotoba-whisper を知りました.
日本語に限れば良さそう.ということで試してみました.

前回OpenAI Whisperを利用しましたが,今回ggml版のkotoba-whisper-v2.0も見つけたのでC++実装のWhisper.cppで試しました.

Whisper.cppの用意

Tip
CPUで利用する場合OpenVINOを利用しているのでIntel Corei 6世代以上が必要.
Whisper.cpp導入
$ git clone https://github.com/ggerganov/whisper.cpp (1)
$ cd whisper.cpp
$ make -j`nproc` (2)
$ ./main -f samples/jfk.wav (3)
  1. sourceの入手

  2. build

  3. サンプル音声で動作テスト

モデルの入手

今回, kotoba-whisper-v2.0 のモデルと,比較のために large-v3 large-v3-turbo のggmlモデルを用意しました.

Note
Download link は 「Files and Versions」→該当ファイルの「Download file」
$ wget2 -c https://huggingface.co/kotoba-tech/kotoba-whisper-v2.0-ggml/resolve/main/ggml-kotoba-whisper-v2.0.bin -P ./models
$ wget2 -c "https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-large-v3.bin?download=true" -O models/ggml-large-v3.bin
$ wget2 -c "https://huggingface.co/cstr/whisper-large-v3-turbo-german-ggml/resolve/main/ggml-model.bin?download=true" -O models/ggml-large-v3-turbo.bin
Note

Whisper.cppはモデルダウンロードスクリプトが付属しているが,正常系しか無いので不安定な回線などで途中で失敗した場合は以下を

モデルサイズ

kotoba-whisper-v2.0, large-v3-turboは同じくらいのサイズ.

$ ls -1s models/ggml-kotoba-whisper-v2.0.bin models/ggml-large-v3-turbo.bin models/ggml-large-v3.bin
1483916 models/ggml-kotoba-whisper-v2.0.bin
1586492 models/ggml-large-v3-turbo.bin
3022500 models/ggml-large-v3.bin

文字起こしデータの用意

文字起こしデータは前回試したNHKラジオニュースの約5分の.mp3が残っていたのでこれを利用しました.
OpenAI Whisperはいろいろなデータを読んでくれるのですが,Whisper.cppは16kbit wavのみ対応なので前もって変換してあげる必要があります.ここではffmpegに変換してもらいました.

$ ffmpeg -i input.mp3 \
  -ar 16000 -ac 1 -c:a pcm_s16le \
  output.wav

実際の文字起こし

Note

主な環境

  • CPU: Intel® Core™ i7-10510U CPU @ 1.80GHz

  • RAM: DDR4 16GB

  • ストレージ: NvME SSD

  • OS: Debian sid amd64

large-v3

$ time ./main -t `nproc` -m models/ggml-large-v3.bin -l ja -f ./output.wav
    :
real    25m54.494s
user    175m39.723s
sys     1m4.334s

large-v3-turbo

$ time ./main -t `nproc` -m models/ggml-large-v3-turbo.bin -l ja -f ./output.wav
    :
real    11m10.153s
user    80m42.460s
sys     0m8.764s

kotoba-whisper-v2.0

$ time ./main -t `nproc` -m models/ggml-kotoba-whisper-v2.0.bin -l ja -f ./output.wav
    :
real    10m7.137s
user    74m48.509s
sys     0m6.373s

速度比較

モデル処理時間多国言語対応

large-v3

26min

OK

large-v3-turbo

11min

OK

kotoba-whisper-v2.0

10min

NG

今回の環境ではkotoba-whisper-v2.0はlarge-v3より6.3倍とまでは行かないが高速,しかし多他国言語対応のlarge-v3-turboとそこまで変わらない.

余録

計測した後端末をハイバネーションしようとしたらswapが足りず失敗.

$ systemctl hibernate
Call to Hibernate failed: Not enough suitable swap space for hibernation available on compatible block devices and file systems
$ free
               total        used        free      shared  buff/cache   available
Mem:        15992640     9952748     1965752     1276452     5725024     6039892
Swap:       17575932    11481084     6094848

メモリ不足が響いて遅いのではと思い再起動して再計測したがあまり変わらなかった.

large-v3-turbo
real    9m47.796s
user    76m7.572s
sys     0m3.873s
kotoba-whisper-v2.0
real    9m22.681s
user    72m32.067s
sys     0m4.110s

まとめ

今回日本語に特化したWhisperモデルの kotoba-whisper-v2.0 をWhisper.cppで試してみました.
元となったlarge-v3より確かに高速になっていますが,OpenAIのlarge-v3-turboとそこまで変わらない速度なので他国言語対応のこちらのほうが良いかもしれないと思いました.環境により変わるのかもしれません.

とやっていたら kotoba-whisper-v2.1 が出ているようです.

速度については変わらなそうですが,Whisper.cpp側の問題もあるかもしれないので次はOpenAI Whisper+koeoto-whisper-v2.1を試してみようと思います.

Note
Whisper.cppには8coreまでしか使えないという制限があるらしいです.自分の環境では8coreまでなので関係ないかもしれませんが.
kotoba whisper htop

環境

$ git -C whisper.cpp log -1
commit 31aea563a83803c710691fed3e8d700e06ae6788 (HEAD -> master, origin/master, origin/HEAD)
Author: Vin Misra <vinith@alum.mit.edu>
Date:   Wed Nov 6 13:02:11 2024 -0800

    whisper : fix extra memory usage (#2534)

    * passing samples_padded by ref to the threads.

    * passing samples_padded by ref to the threads.

    ---------

    Co-authored-by: Vinith Misra <physicsdemon@gmail.com>
$ lsb_release -dr
Description:    Debian GNU/Linux trixie/sid
Release:        n/a
$ arch
x86_64
$ lscpu | grep ^Model\ name:
Model name:                           Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
$ head -1 /proc/meminfo
MemTotal:       15992644 kB

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)