<p align="center">
<img width="100%" src="https://yellow-cdn.veclightyear.com/835a84d5/e5fb634b-b3ab-4b32-b78a-77ad7abae57d.jpg?raw=true" title="diart标志" />
</p>
<p align="center">
<i>🌿 轻松构建基于AI的实时音频应用 🌿</i>
</p>
<p align="center">
<img alt="PyPI版本" src="https://img.shields.io/pypi/v/diart?color=g">
<img alt="PyPI下载量" src="https://static.pepy.tech/personalized-badge/diart?period=total&units=international_system&left_color=grey&right_color=brightgreen&left_text=下载量">
<img alt="Python版本" src="https://img.shields.io/badge/python-3.8%20%7C%203.9%20%7C%203.10-dark_green">
<img alt="代码大小(字节)" src="https://img.shields.io/github/languages/code-size/juanmc2005/StreamingSpeakerDiarization?color=g">
<img alt="许可证" src="https://img.shields.io/github/license/juanmc2005/StreamingSpeakerDiarization?color=g">
<a href="https://joss.theoj.org/papers/cc9807c6de75ea4c29025c7bd0d31996"><img src="https://yellow-cdn.veclightyear.com/835a84d5/4bf1e52d-5b52-4aae-bbc9-7b3cd88d6c52.svg"></a>
</p>
<div align="center">
<h4>
<a href="#-installation">
💾 安装
</a>
<span> | </span>
<a href="#%EF%B8%8F-stream-audio">
🎙️ 音频流
</a>
<span> | </span>
<a href="#-models">
🧠 模型
</a>
<br />
<a href="#-tune-hyper-parameters">
📈 调优
</a>
<span> | </span>
<a href="#-build-pipelines">
🧠🔗 流水线
</a>
<span> | </span>
<a href="#-websockets">
🌐 WebSocket
</a>
<span> | </span>
<a href="#-powered-by-research">
🔬 研究支持
</a>
</h4>
</div>
<br/>
<p align="center">
<img width="100%" src="https://yellow-cdn.veclightyear.com/835a84d5/b118eaf7-be37-431f-96d9-b8f4baf51795.gif?raw=true" title="实时说话人分类示例" />
</p>
⚡ 快速介绍
Diart是一个用于构建基于AI的实时音频应用的Python框架。其主要特点是能够以最先进的性能实时识别不同的说话人,这项任务通常被称为"说话人分类"。
diart.SpeakerDiarization
流水线结合了说话人分割和说话人嵌入模型,为增量聚类算法提供支持,随着对话的进行,其准确性不断提高:
<p align="center">
<img width="100%" src="https://yellow-cdn.veclightyear.com/835a84d5/5480bcde-8f51-40d3-ade4-bf02cc42514f.gif?raw=true" title="实时说话人分类流水线" />
</p>
使用diart,您还可以创建自定义AI流水线、对其进行基准测试、调整超参数,甚至使用WebSocket在网络上提供服务。
我们提供以下预训练流水线:
- 说话人分类
- 语音活动检测
- 转录(即将推出)
- 说话人感知转录(即将推出)
💾 安装
1) 确保您的系统具备以下依赖项:
ffmpeg < 4.4
portaudio == 19.6.X
libsndfile >= 1.2.2
或者,我们提供了一个environment.yml
文件用于预配置的conda环境:
conda env create -f diart/environment.yml
conda activate diart
2) 安装软件包:
pip install diart
获取 🎹 pyannote模型的访问权限
默认情况下,diart基于huggingface hub上的pyannote.audio模型。要使用这些模型,请按以下步骤操作:
- 接受
pyannote/segmentation
模型的用户条款
- 接受最新的
pyannote/segmentation-3.0
模型的用户条款
- 接受
pyannote/embedding
模型的用户条款
- 安装huggingface-cli并使用您的用户访问令牌登录(或在diart CLI或API中手动提供)
🎙️ 音频流
从命令行
录制的对话:
diart.stream /path/to/audio.wav
实时对话:
# 使用"microphone:ID"选择非默认设备
# 查看`python -m sounddevice`获取可用设备
diart.stream microphone
默认情况下,diart运行说话人分类流水线,相当于设置--pipeline SpeakerDiarization
,但您也可以将其设置为--pipeline VoiceActivityDetection
。更多选项请参见diart.stream -h
。
从Python
使用StreamingInference
在音频源上运行流水线并将结果写入磁盘:
from diart import SpeakerDiarization
from diart.sources import MicrophoneAudioSource
from diart.inference import StreamingInference
from diart.sinks import RTTMWriter
pipeline = SpeakerDiarization()
mic = MicrophoneAudioSource()
inference = StreamingInference(pipeline, mic, do_plot=True)
inference.attach_observers(RTTMWriter(mic.uri, "/output/file.rttm"))
prediction = inference()
对于数据集的推理和评估,我们建议使用Benchmark
(参见关于可重复性的说明)。
🧠 模型
您可以使用--segmentation
和--embedding
参数来使用其他模型。
或在Python中:
import diart.models as m
segmentation = m.SegmentationModel.from_pretrained("model_name")
embedding = m.EmbeddingModel.from_pretrained("model_name")
预训练模型
以下是diart当前支持的所有模型列表:
模型名称 | 模型类型 | CPU时间* | GPU时间* |
---|
🤗 pyannote/segmentation (默认) | 分割 | 12ms | 8ms |
🤗 pyannote/segmentation-3.0 | 分割 | 11ms | 8ms |
🤗 pyannote/embedding (默认) | 嵌入 | 26ms | 12ms |
|