Speaker diarization is the process of dividing an audio stream into distinct segments based on speaker identity. In simpler terms, it answers the question, "Who spoke when?"
Previously, we introduced you to some of the Top Speaker Diarization APIs and SDKs currently available in the market. In this article, we'll dive into practical demonstrations of three Python-based speaker diarization frameworks, showcasing their capabilities through a straightforward speaker diarization task.
pyannote.audio
Getting started with pyannote.audio for speaker diarization is straightforward. Follow these steps:
- Install the
pyannote.audio
package using pip:
Obtain your authentication token to download pretrained models by visiting their Hugging Face pages.
Use the following Python code to perform speaker diarization on an audio file:
This code will perform speaker diarization and print out the identified speakers along with their corresponding segments in the audio file.
NVIDIA NeMo
To perform speaker diarization using NVIDIA NeMo, follow these steps:
- Install dependencies:
- Install NeMo:
Download the config file for the inference from the NeMo GitHub repository.
Generate and store the manifest file by running the following code:
Replace /PATH/TO/AUDIO_FILE.wav
with the path to your audio file and /PATH/TO/MANIFEST_FILE.json
with the desired
path for your manifest file.
- Load the config file and define a
ClusteringDiarizer
object:
Replace /PATH/TO/OUTPUT_DIR
and /PATH/TO/CONFIG_FILE.yaml
with the desired paths for your output directory and
config file, respectively.
- Perform speaker diarization on the audio file:
The output of the speaker diarization will be stored in the OUTPUT_DIR
directory as
a Rich Transcription Time Marked (RTTM) file.
Simple Diarizer
Simple Diarizer is a speaker diarization library that utilizes pretrained
models
from SpeechBrain. To get started with simple_diarizer
, follow these steps:
- Install the package using pip:
- Define a
Diarizer
object:
- Perform speaker diarization on an audio file by either passing the number of speakers:
Or by passing a threshold value:
The speaker information and timing details, including the start and end times of each segment, are stored in the segment variable.
Falcon Speaker Diarization
Falcon Speaker Diarization is an on-device speaker diarization engine powered by deep learning. To get started with Falcon Speaker Diarization
, follow these steps:
- Install the package using pip:
Sign up for Picovoice Console for free and copy your
AccessKey
. It handles authentication and authorization.Create an instance of the engine:
- Perform speaker diarization on an audio file:
The segments
variable represents an array of segments, each of which includes the segment's timing and speaker information.
For more information about Falcon Speaker Diarization
, check out the Falcon Speaker Diarization product page or refer to the Falcon Speaker Diarization Python SDK quick start guide.