需要 Python >= 3.10,3.9 需手动逐个安装依赖;安装前必须先装好 FFMPEG 和 Cython;Whisper 与 NeMo 参数写死在 diarize.py 和 helpers.py 中,暂不支持通过 CLI 修改;并行脚本仍属实验性,可能报错。

whisper-diarization
MahmoudAshraf97BSD-2-Clause活跃维护基于 OpenAI Whisper 的语音转写工具,能自动识别不同说话人并切分对话,适合会议记录、访谈整理等多人语音场景。
Automatic Speech Recognition with Speaker Diarization based on OpenAI Whisper
pip install cython
sudo apt update && sudo apt install ffmpeg
pip install -c constraints.txt -r requirements.txt
python diarize.py -a AUDIO_FILE_NAMEREADME 未给出最低显存要求;若显存 >=10GB,可改用 diarize_parallel.py 并行运行 NeMo 与 Whisper;--device 默认在可用时使用 cuda。
基于 Whisper 的语音转写加说话人分离流水线,给每句话标出是谁说的
基于 OpenAI Whisper 的语音转写工具,能自动识别不同说话人并切分对话,适合会议记录、访谈整理等多人语音场景。
核心能力
- 先用 Demucs 分离人声,提升说话人嵌入准确度
- 用 ctc-forced-aligner 校正并对齐时间戳,减少时间偏移导致的分离错误
- 用 MarbleNet 做 VAD 与分段以剔除静音
- 用 TitaNet 提取说话人嵌入,按时间戳为每个词判定说话人
- 提供并行版脚本,让 NeMo 与 Whisper 同时运行
容易踩的坑
暂无 release 数据(可能没有发版,或尚未同步)。
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
Speaker Diarization pipeline based on OpenAI Whisper
Please, star the project on github (see top-right corner) if you appreciate my contribution to the community!
What is it
This repository combines Whisper ASR capabilities with Voice Activity Detection (VAD) and Speaker Embedding to identify the speaker for each sentence in the transcription generated by Whisper. First, the vocals are extracted from the audio to increase the speaker embedding accuracy, then the transcription is generated using Whisper, then the timestamps are corrected and aligned using ctc-forced-aligner to help minimize diarization error due to time shift. The audio is then passed into MarbleNet for VAD and segmentation to exclude silences, TitaNet is then used to extract speaker embeddings to identify the speaker for each segment, the result is then associated with the timestamps generated by ctc-forced-aligner to detect the speaker for each word based on timestamps and then realigned using punctuation models to compensate for minor time shifts.
Whisper and NeMo parameters are coded into diarize.py and helpers.py, I will add the CLI arguments to change them later
Installation
Python >= 3.10 is needed, 3.9 will work but you'll need to manually install the requirements one by one.
FFMPEG and Cython are needed as prerequisites to install the requirements
pip install cython
or
sudo apt update && sudo apt install cython3
# on Ubuntu or Debian
sudo apt update && sudo apt install ffmpeg
# on Arch Linux
sudo pacman -S ffmpeg
# on MacOS using Homebrew (https://brew.sh/)
brew install ffmpeg
# on Windows using Chocolatey (https://chocolatey.org/)
choco install ffmpeg
# on Windows using Scoop (https://scoop.sh/)
scoop install ffmpeg
# on Windows using WinGet (https://github.com/microsoft/winget-cli)
winget install ffmpeg
pip install -c constraints.txt -r requirements.txt
Usage
python diarize.py -a AUDIO_FILE_NAME
If your system has enough VRAM (>=10GB), you can use diarize_parallel.py instead, the difference is that it runs NeMo in parallel with Whisper, this can be beneficial in some cases and the result is the same since the two models are nondependent on each other. This is still experimental, so expect errors and sharp edges. Your feedback is welcome.
Command Line Options
-a AUDIO_FILE_NAME: The name of the audio file to be processed--no-stem: Disables source separation--whisper-model: The model to be used for ASR, default ismedium.en--suppress_numerals: Transcribes numbers in their pronounced letters instead of digits, improves alignment accuracy--device: Choose which device to use, defaults to "cuda" if available--language: Manually select language, useful if language detection failed--batch-size: Batch size for batched inference, reduce if you run out of memory, set to 0 for non-batched inference
Known Limitations
- Overlapping speakers are yet to be addressed, a possible approach would be to separate the audio file and isolate only one speaker, then feed it into the pipeline but this will need much more computation
- There might be some errors, please raise an issue if you encounter any.
Future Improvements
- Implement a maximum length per sentence for SRT
Acknowledgements
Special Thanks for @adamjonas for supporting this project This work is based on OpenAI's Whisper , Faster Whisper , Nvidia NeMo , and Facebook's Demucs
Citation
If you use this in your research, please cite the project:
@unpublished{hassouna2024whisperdiarization,
title={Whisper Diarization: Speaker Diarization Using OpenAI Whisper},
author={Ashraf, Mahmoud},
year={2024}
}