🚀 話者分離
このプロジェクトは、音声データ内の話者を識別し、各話者の発話区間を特定する話者分離機能を提供します。pyannote.audio 2.0に依存しており、高精度で効率的な話者分離を実現します。
🚀 クイックスタート
この話者分離パイプラインは pyannote.audio 2.0に依存しています。インストール手順を参照してください。
💻 使用例
基本的な使用法
from pyannote.audio import Pipeline
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization@2022.07")
diarization = pipeline("audio.wav")
with open("audio.rttm", "w") as rttm:
diarization.write_rttm(rttm)
高度な使用法
話者数が事前にわかっている場合は、パラメータ辞書に num_speakers
パラメータを含めることができます。
handler = EndpointHandler()
diarization = handler({"inputs": base64_audio, "parameters": {"num_speakers": 2}})
min_speakers
と max_speakers
パラメータを使用して、話者数の下限と/または上限を指定することもできます。
handler = EndpointHandler()
diarization = handler({"inputs": base64_audio, "parameters": {"min_speakers": 2, "max_speakers": 5}})
冒険的な方は、様々なパイプラインのハイパーパラメータを試すことができます。
たとえば、segmentation_onset
閾値の値を増やすことで、より積極的な音声アクティビティ検出を使用することができます。
hparams = handler.pipeline.parameters(instantiated=True)
hparams["segmentation_onset"] += 0.1
handler.pipeline.instantiate(hparams)
話者数を処理できるAPI推論に更新されたハンドラを適用するには、次のコードを使用します。
from typing import Dict
from pyannote.audio import Pipeline
import torch
import base64
import numpy as np
SAMPLE_RATE = 16000
class EndpointHandler():
def __init__(self, path=""):
self.pipeline = Pipeline.from_pretrained("KIFF/pyannote-speaker-diarization-endpoint")
def __call__(self, data: Dict[str, bytes]) -> Dict[str, str]:
"""
引数:
data (:obj:):
バイト形式でデシリアライズされた音声ファイルを含む
戻り値:
:obj:`dict`: base64エンコードされた画像
"""
inputs = data.pop("inputs", data)
parameters = data.pop("parameters", None)
audio_data = base64.b64decode(inputs)
audio_nparray = np.frombuffer(audio_data, dtype=np.int16)
audio_tensor= torch.from_numpy(audio_nparray).float().unsqueeze(0)
pyannote_input = {"waveform": audio_tensor, "sample_rate": SAMPLE_RATE}
if parameters is not None:
diarization = self.pipeline(pyannote_input, **parameters)
else:
diarization = self.pipeline(pyannote_input)
processed_diarization = [
{"label": str(label), "start": str(segment.start), "stop": str(segment.end)}
for segment, _, label in diarization.itertracks(yield_label=True)
]
return {"diarization": processed_diarization}
📚 詳細ドキュメント
ベンチマーク
リアルタイム係数
1台のNvidia Tesla V100 SXM2 GPU(ニューラル推論部分)と1台のIntel Cascade Lake 6248 CPU(クラスタリング部分)を使用すると、リアルタイム係数は約5%です。
言い換えると、1時間の会話を処理するのに約3分かかります。
精度
このパイプラインは、増え続けるデータセットでベンチマークされています。
処理は完全に自動化されています。
- 手動による音声アクティビティ検出は行われません(文献で時々見られるような場合)
- 手動による話者数の指定は不要です(ただし、パイプラインに指定することも可能)
- 内部モデルの微調整やパイプラインのハイパーパラメータの調整は、各データセットに対して行われません
... 最も厳格な話者分離誤差率(DER)設定(この論文で "Full" と呼ばれる)で:
サポート
商用のお問い合わせや科学的なコンサルティングについては、こちらまでご連絡ください。
技術的な質問やバグ報告については、pyannote.audioのGitHubリポジトリをご確認ください。
引用
@inproceedings{Bredin2021,
Title = {{End-to-end speaker segmentation for overlap-aware resegmentation}},
Author = {{Bredin}, Herv{\'e} and {Laurent}, Antoine},
Booktitle = {Proc. Interspeech 2021},
Address = {Brno, Czech Republic},
Month = {August},
Year = {2021},
}
@inproceedings{Bredin2020,
Title = {{pyannote.audio: neural building blocks for speaker diarization}},
Author = {{Bredin}, Herv{\'e} and {Yin}, Ruiqing and {Coria}, Juan Manuel and {Gelly}, Gregory and {Korshunov}, Pavel and {Lavechin}, Marvin and {Fustes}, Diego and {Titeux}, Hadrien and {Bouaziz}, Wassim and {Gill}, Marie-Philippe},
Booktitle = {ICASSP 2020, IEEE International Conference on Acoustics, Speech, and Signal Processing},
Address = {Barcelona, Spain},
Month = {May},
Year = {2020},
}
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。