6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

pyannote.audio 3.1 使ってみる

Posted at

pyannote.audio のバージョンを3.1にあげてみる

pyannote.audioとは

pyannote.audioは音声から話者ダイアライゼーション(話者分離)を行うライブラリ

pyannote.audio 2.1からのバージョンアップ

2.1の使い方
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization@2.1",
                                    use_auth_token="ACCESS_TOKEN_GOES_HERE")
diarization = pipeline("audio.wav")
3.1の使い方
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained(
  "pyannote/speaker-diarization-3.1",use_auth_token="HUGGINGFACE_ACCESS_TOKEN_GOES_HERE")

diarization = pipeline("audio.wav")

基本的な使い方は変わってない っが・・・
おかしい。2.1の時は約1時間の音声ファイルの話者分離が3分程度で終わっていたのに、20分立っても終わらない・・・
どうやらGPUがちゃんと使われていないみたい

3.1の使い方(GPUバージョン)
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained(
  "pyannote/speaker-diarization-3.1",use_auth_token="HUGGINGFACE_ACCESS_TOKEN_GOES_HERE")

import torch
pipeline.to(torch.device("cuda"))

waveform, sample_rate = torchaudio.load("audio.wav")
diarization = pipeline({"waveform": waveform, "sample_rate": sample_rate})

これで2.1の時と同じ3分程度で完了した。
3.1 ではどうやらtorch.deviceを明示的に指定と、オーディオファイルを事前にロードする必要があるみたい?

おまけ 3.1の必要なライブラリ

pip install pyannote.audio==3.1.1
pip install pydub==0.25.1
pip install speechbrain==0.5.14
pip install soundfile==0.12.1
pip install lightning==2.0.1
pip install --no-cache-dir \
torch==2.2.0+cu121 \
torchaudio==2.2.0+cu121 \
torchvision==0.17.0+cu121 \
torchtext==0.17.0+cpu \
torchdata==0.7.1 \
--index-url https://download.pytorch.org/whl/cu121

参考ページ

https://huggingface.co/pyannote/speaker-diarization
https://huggingface.co/pyannote/speaker-diarization-3.1

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?