segmentation 3.0

提供商fatymatariq
分类voice-activity-detection
许可证mit
下载量2.7K
星标0

简介

Segmentation 3.0 是一款专注于语音活动检测(VAD)的轻量级模型。对于开发者而言,它解决了音频处理中最基础但关键的“静音剔除”和“人声切分”问题。相比于复杂的全量语音识别模型,它上手难度极低,能够高效地从连续音频流中精准识别出有人说话的时段。它非常适合作为语音管线(Pipeline)的第一道预处理工序,与 Whisper 等 ASR 工具配合使用,可以显著降低后续识别的计算量并提升时间戳的准确度。

核心亮点

  • 精准识别语音活动,高效剔除背景静音
  • 轻量化设计,极低延迟,适合实时流处理
  • MIT 协议开源,方便商业集成与二次开发
  • 理想的 ASR 预处理插件,提升语音识别效率

使用方法

安装依赖
# 安装 Hugging Face transformers
pip install transformers torch
SDK 使用
# 使用 transformers 加载模型
from transformers import AutoModel, AutoTokenizer

model = AutoModel.from_pretrained("fatymatariq/segmentation-3.0")
tokenizer = AutoTokenizer.from_pretrained("fatymatariq/segmentation-3.0")

Hugging Face 下载

我们推荐使用命令行或者 Hugging Face Hub SDK 来进行模型的下载。

操作指引:在下载前,请先通过如下命令安装 huggingface_hub:

操作指引
pip install -U huggingface_hub

命令行下载

下载完整模型库

下载完整模型库
huggingface-cli download fatymatariq/segmentation-3.0

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)

下载单个文件到指定本地文件夹(以下载 config.json 到当前路径下 ./dir 目录为例)
huggingface-cli download fatymatariq/segmentation-3.0 config.json --local-dir ./dir

更多命令行下载选项,可参见官方文档

SDK 下载

SDK 下载
# 模型下载
from huggingface_hub import snapshot_download
model_dir = snapshot_download('fatymatariq/segmentation-3.0')

Git 下载

请确保 lfs 已经被正确安装

Git 下载
git lfs install
git clone https://huggingface.co/fatymatariq/segmentation-3.0

如果您希望跳过 lfs 大文件下载,可以使用如下命令

跳过 LFS
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/fatymatariq/segmentation-3.0

模型文件托管在 Hugging Face Hub,使用 HF CLI / SDK / Git 直接下载,不经过本站。

PyTorch / Transformers 使用

安装 Transformers

安装 Transformers
pip install -U transformers torch

模型加载和推理

模型加载和推理
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained('fatymatariq/segmentation-3.0')
tokenizer = AutoTokenizer.from_pretrained('fatymatariq/segmentation-3.0')

完整文档

来源: HuggingFace

---
tags:

  • pyannote

  • pyannote-audio

  • pyannote-audio-model

  • audio

  • voice

  • speech

  • speaker

  • speaker-diarization

  • speaker-change-detection

  • speaker-segmentation

  • voice-activity-detection

  • overlapped-speech-detection

  • resegmentation

license: mit
inference: false
extra_gated_prompt: "The collected information will help acquire a better knowledge of pyannote.audio userbase and help its maintainers improve it further. Though this model uses MIT license and will always remain open-source, we will occasionnally email you about premium models and paid services around pyannote."
extra_gated_fields:
Company/university: text
Website: text
---

Using this open-source model in production?
Consider switching to pyannoteAI for better and faster options.

🎹 "Powerset" speaker segmentation

This model ingests 10 seconds of mono audio sampled at 16kHz and outputs speaker diarization as a (num_frames, num_classes) matrix where the 7 classes are _non-speech_, _speaker #1_, _speaker #2_, _speaker #3_, _speakers #1 and #2_, _speakers #1 and #3_, and _speakers #2 and #3_.

!Example output

python
# waveform (first row)
duration, sample_rate, num_channels = 10, 16000, 1
waveform = torch.randn(batch_size, num_channels, duration * sample_rate)

powerset multi-class encoding (second row)

powerset_encoding = model(waveform)

multi-label encoding (third row)

from pyannote.audio.utils.powerset import Powerset max_speakers_per_chunk, max_speakers_per_frame = 3, 2 to_multilabel = Powerset( max_speakers_per_chunk, max_speakers_per_frame).to_multilabel multilabel_encoding = to_multilabel(powerset_encoding)

The various concepts behind this model are described in details in this paper.

It has been trained by Séverin Baroudi with pyannote.audio 3.0.0 using the combination of the training sets of AISHELL, AliMeeting, AMI, AVA-AVD, DIHARD, Ego4D, MSDWild, REPERE, and VoxConverse.

This companion repository by Alexis Plaquet also provides instructions on how to train or finetune such a model on your own data.

Requirements

1. Install pyannote.audio 3.0 with pip install pyannote.audio
2. Accept pyannote/segmentation-3.0 user conditions
3. Create access token at hf.co/settings/tokens.

Usage

python
# instantiate the model
from pyannote.audio import Model
model = Model.from_pretrained(
  "pyannote/segmentation-3.0", 
  use_auth_token="HUGGINGFACE_ACCESS_TOKEN_GOES_HERE")

Speaker diarization

This model cannot be used to perform speaker diarization of full recordings on its own (it only processes 10s chunks).

See pyannote/speaker-diarization-3.0 pipeline that uses an additional speaker embedding model to perform full recording speaker diarization.

Voice activity detection

python
from pyannote.audio.pipelines import VoiceActivityDetection
pipeline = VoiceActivityDetection(segmentation=model)
HYPER_PARAMETERS = {
  # remove speech regions shorter than that many seconds.
  "min_duration_on": 0.0,
  # fill non-speech regions shorter than that many seconds.
  "min_duration_off": 0.0
}
pipeline.instantiate(HYPER_PARAMETERS)
vad = pipeline("audio.wav")

vad is a pyannote.core.Annotation instance containing speech regions

Overlapped speech detection

python
from pyannote.audio.pipelines import OverlappedSpeechDetection
pipeline = OverlappedSpeechDetection(segmentation=model)
HYPER_PARAMETERS = {
  # remove overlapped speech regions shorter than that many seconds.
  "min_duration_on": 0.0,
  # fill non-overlapped speech regions shorter than that many seconds.
  "min_duration_off": 0.0
}
pipeline.instantiate(HYPER_PARAMETERS)
osd = pipeline("audio.wav")

osd is a pyannote.core.Annotation instance containing overlapped speech regions

Citations

bibtex
@inproceedings{Plaquet23,
  author={Alexis Plaquet and Hervé Bredin},
  title={{Powerset multi-class cross entropy loss for neural speaker diarization}},
  year=2023,
  booktitle={Proc. INTERSPEECH 2023},
}
bibtex
@inproceedings{Bredin23,
  author={Hervé Bredin},
  title={{pyannote.audio 2.1 speaker diarization pipeline: principle, benchmark, and recipe}},
  year=2023,
  booktitle={Proc. INTERSPEECH 2023},
}