Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple improvements: language detection per segment, VAD min duration on/off, unique speakers, pyproject.toml and more. #900

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
whisperx.egg-info/
**/__pycache__/
.ipynb_checkpoints
build/
dist/
.vscode/
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ Bug finding and pull requests are also highly appreciated to keep this project g

* [ ] Add benchmarking code (TEDLIUM for spd/WER & word segmentation)

* [ ] Allow silero-vad as alternative VAD option
* [x] Allow silero-vad as alternative VAD option

* [ ] Improve diarization (word level). *Harder than first thought...*

Expand All @@ -281,7 +281,9 @@ Borrows important alignment code from [PyTorch tutorial on forced alignment](htt
And uses the wonderful pyannote VAD / Diarization https://github.com/pyannote/pyannote-audio


Valuable VAD & Diarization Models from [pyannote audio][https://github.com/pyannote/pyannote-audio]
Valuable VAD & Diarization Models from:
- [pyannote audio][https://github.com/pyannote/pyannote-audio]
- [silero vad][https://github.com/snakers4/silero-vad]

Great backend from [faster-whisper](https://github.com/guillaumekln/faster-whisper) and [CTranslate2](https://github.com/OpenNMT/CTranslate2)

Expand Down
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[build-system]
requires = ["setuptools>=65", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "whisperx"
version = "3.1.1"
description = "Time-Accurate Automatic Speech Recognition using Whisper."
readme = "README.md"
requires-python = ">=3.8"
authors = [
{name = "Max Bain"}
]
license = {text = "MIT"}
dependencies = [
"torch>=2",
"torchaudio>=2",
"faster-whisper==1.0.3",
"transformers",
"pandas",
"setuptools>=65",
"nltk",
"pyannote.audio==3.3.2"
]

[project.optional-dependencies]
dev = ["pytest"]

[project.scripts]
whisperx = "whisperx.transcribe:cli"

[tool.setuptools.packages.find]
exclude = ["tests*"]

[tool.setuptools]
include-package-data = true
7 changes: 0 additions & 7 deletions requirements.txt

This file was deleted.

30 changes: 0 additions & 30 deletions setup.py

This file was deleted.

4 changes: 2 additions & 2 deletions whisperx/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .transcribe import load_model
from .alignment import load_align_model, align
from .audio import load_audio
from .diarize import assign_word_speakers, DiarizationPipeline
from .diarize import assign_word_speakers, DiarizationPipeline
from .asr import load_model
5 changes: 4 additions & 1 deletion whisperx/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,13 @@ def align(
t1 = segment["start"]
t2 = segment["end"]
text = segment["text"]
language = segment["language"]

aligned_seg: SingleAlignedSegment = {
"start": t1,
"end": t2,
"text": text,
"language": language,
"words": [],
}

Expand Down Expand Up @@ -324,6 +326,7 @@ def align(
"start": sentence_start,
"end": sentence_end,
"words": sentence_words,
"language": language
})

if return_char_alignments:
Expand All @@ -337,7 +340,7 @@ def align(
aligned_subsegments["start"] = interpolate_nans(aligned_subsegments["start"], method=interpolate_method)
aligned_subsegments["end"] = interpolate_nans(aligned_subsegments["end"], method=interpolate_method)
# concatenate sentences with same timestamps
agg_dict = {"text": " ".join, "words": "sum"}
agg_dict = {"text": " ".join, "words": "sum", "language": "first"}
if model_lang in LANGUAGES_WITHOUT_SPACES:
agg_dict["text"] = "".join
if return_char_alignments:
Expand Down
Loading