Add optional Silero VAD backend for longform transcription - #85
Open
gman-dev-nov wants to merge 4 commits into
Open
Add optional Silero VAD backend for longform transcription#85gman-dev-nov wants to merge 4 commits into
gman-dev-nov wants to merge 4 commits into
Conversation
gman-dev-nov
force-pushed
the
feat/silero-vad-backend
branch
2 times, most recently
from
August 10, 2026 13:39
617f562 to
ef2f35b
Compare
No behavior change. The span-merging logic moves verbatim from segment_audio_file into chunking_utils.merge_speech_spans and operates on plain (start, end) tuples, so it no longer depends on which VAD produced the spans; the four tuning knobs are grouped into a frozen ChunkingConfig dataclass. The pyannote pipeline code and the public segment_audio_file signature are untouched.
transcribe_longform(..., vad_backend="silero") segments speech with Silero VAD, whose weights ship inside the silero-vad package (new 'silero' extra), so no Hugging Face account or token is required and the backend is importable without pyannote installed. The silero segment_audio_file takes an optional ChunkingConfig and no device argument (Silero always runs on CPU); the chunk-merging logic is shared with the default pyannote backend, which is unchanged.
The new tests run without HF_TOKEN (silero-vad added to the tests extra), so longform now has CI coverage even where the secret is unavailable, e.g. pull requests from forks. The end-to-end test compares the merged transcription against the pyannote-based reference by similarity instead of exact boundaries, since chunk borders legitimately differ between VADs.
gman-dev-nov
force-pushed
the
feat/silero-vad-backend
branch
from
August 10, 2026 14:42
ef2f35b to
8808e81
Compare
Author
|
@Bobrosoft98 @georgygospodinov @sverdoot @nshmyrev watch please 🙏 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
transcribe_longformdepends on the gatedpyannote/segmentation-3.0model, so the first run requires a Hugging Face account, accepting the model conditions, and anHF_TOKEN. That first step is a real hurdle in corporate and air-gapped environments where creating an HF account or reaching the Hub is not an option.This PR adds an opt-in alternative:
transcribe_longform(..., vad_backend="silero"), using Silero VAD, whose weights ship inside thesilero-vadpip package — no account or token needed.Relation to #24
#24 proposed replacing the pyannote pipeline and was declined. This PR is deliberately different:
transcribe_longform(...)behaves exactly as before; the pyannote pipeline code invad_utils.pyis untouched.Changes
gigaam/chunking_utils.py(new) — the span-merging logic moved verbatim out ofsegment_audio_file; it operates on plain(start, end)tuples, so it is independent of which VAD produced the spans. The four tuning knobs are grouped into a frozenChunkingConfigdataclass.gigaam/vad_utils.py— pyannote code untouched;segment_audio_filekeeps its public signature and delegates merging tochunking_utils.gigaam/silero_vad_utils.py(new) — Silero counterpart ofsegment_audio_filewith a slimmer signature:(wav_file, sr, config: Optional[ChunkingConfig])— nodeviceargument, since Silero VAD always runs on CPU. Importable without pyannote installed; a missingsilero-vadpackage raises an ImportError pointing topip install gigaam[silero].gigaam/model.py—transcribe_longformgains avad_backend: str = "pyannote"keyword (backwards-compatible) and dispatches to the backend module viamatch/case; the import was already function-local upstream. Unknown values are rejected with aValueErrorbefore any audio is decoded.pyproject.toml— newsileroextra (silero-vad==6.2.*— the tested minor, pinned in the repo's style; validated against 6.2.1); also added totestsso CI exercises the new path — happy to drop that if you prefer to keep the tests extra minimal (the new testsimportorskipsilero-vad, so they degrade to skips).tests/test_longform.py— 3 new tests that run withoutHF_TOKEN, giving longform coverage even where the secret is unavailable (e.g. PRs from forks). The e2e test compares merged text against the pyannote-based reference via similarity > 0.9 rather than exact boundaries, since chunk borders legitimately differ between VADs.README.md/README_ru.md— one sentence in the longform setup block.Testing
pytest tests/test_longform.py -k "silero or unknown_backend"— 3 passed (Apple M-series: MPS and CPU; silero-vad 6.2.1).black --check,isort --check-only,flake8(workflow flags),mypy --ignore-missing-imports --no-strict-optional— all clean.gigaam.silero_vad_utilsimports,vad_backend="silero"transcribes end-to-end.vad_backend="silero"on MPS in ~6 s, merged text matching the pyannote-based reference.Note on CI: the pre-existing pyannote longform tests will be red on this PR — GitHub does not expose
secrets.HF_TOKENto pull requests from forks. The new silero tests are unaffected and should pass.