Skip to main content

PyDiar

This repo contains simple to use, pretrained/training-less models for speaker diarization.

Supported Models

  • Binary Key Speaker Modeling

    Based on pyBK by Jose Patino which implements the diarization system from "The EURECOM submission to the first DIHARD Challenge" by Patino, Jose and Delgado, Héctor and Evans, Nicholas

If you have any other models you would like to see added, please open an issue.

Usage

This library seeks to provide a very basic interface. To use the Binary Key model on a file, do something like this:

import numpy as np
from pydiar.models import BinaryKeyDiarizationModel, Segment
from pydiar.util.misc import optimize_segments
from pydub import AudioSegment

INPUT_FILE = "test.wav"

sample_rate = 32000
audio = AudioSegment.from_wav("test.wav")
audio = audio.set_frame_rate(sample_rate)
audio = audio.set_channels(1)

diarization_model = BinaryKeyDiarizationModel()
segments = diarization_model.diarize(
    sample_rate, np.array(audio.get_array_of_samples())
)
optimized_segments = optimize_segments(segments)

Now optimized_segments contains a list of segments with their start, length and speaker id

Example

A simple script which reads an audio file, diarizes it and transcribes it into the WebVTT format can be found in examples/generate_webvtt.py. To use it, download a vosk model from https://alphacephei.com/vosk/models and then run the script using

poetry install
poetry run python -m examples.generate_webvtt -i PATH/TO/INPUT.wav -m PATH/TO/VOSK_MODEL

Release files for pydiar 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pydiar 0.0.7
File Size Uploaded
PyDiar-0.0.7.tar.gz 28.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pydiar 0.0.7
File Interpreter ABI Platform
PyDiar-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 57.1 kB

Release files / PyDiar-0.0.7.tar.gz

Download URL PyDiar-0.0.7.tar.gz
Size 28.1 kB
Tags Source
SHA-256 checksum
How to use checksums
6f5ed827b655a774e7b67648f565d663523b710c4a51b5df69ce0dadadcc6ef2
BLAKE2b-256 checksum
How to use checksums
1696e82f6c7d79f7d1b272d28b209bedd9b659f726c95ee51b573640ddf5a146
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.10 CPython/3.9.6 Darwin/21.3.0

Release files / PyDiar-0.0.7-py3-none-any.whl

Download URL PyDiar-0.0.7-py3-none-any.whl
Size 29.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e592afd4f8c753b6763f8049030838c72b337f44282549846a126dadee951d82
BLAKE2b-256 checksum
How to use checksums
1ff6f7f38c693e6ed735aed2f194e0642c100b3ad63f7448ee31ff5dc68bd6ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.10 CPython/3.9.6 Darwin/21.3.0

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page