Skip to content

Commit

Permalink
Merge pull request #317 from pipecat-ai/aleix/silero-repo-params
Browse files Browse the repository at this point in the history
vad(silero): expose cache and repo parameters
  • Loading branch information
aconchillo authored Jul 23, 2024
2 parents 0a6ddbf + ad88925 commit 5fcc964
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added `force_reload`, `skip_validation` and `trust_repo` to `SileroVAD` and
`SileroVADAnalyzer`. This allows caching and various GitHub repo validations.

- Added `send_initial_empty_metrics` flag to `PipelineParams` to request for
initial empty metrics (zero values). True by default.

Expand Down
18 changes: 15 additions & 3 deletions src/pipecat/vad/silero.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def __init__(
*,
sample_rate: int = 16000,
version: str = "v5.0",
force_reload: bool = False,
skip_validation: bool = True,
trust_repo: bool = True,
params: VADParams = VADParams()):
super().__init__(sample_rate=sample_rate, num_channels=1, params=params)

Expand All @@ -48,8 +51,9 @@ def __init__(

(self._model, _) = torch.hub.load(repo_or_dir=f"snakers4/silero-vad:{version}",
model="silero_vad",
force_reload=False,
trust_repo=True)
force_reload=force_reload,
skip_validation=skip_validation,
trust_repo=trust_repo)

self._last_reset_time = 0

Expand Down Expand Up @@ -91,12 +95,20 @@ def __init__(
*,
sample_rate: int = 16000,
version: str = "v5.0",
force_reload: bool = False,
skip_validation: bool = True,
trust_repo: bool = True,
vad_params: VADParams = VADParams(),
audio_passthrough: bool = False):
super().__init__()

self._vad_analyzer = SileroVADAnalyzer(
sample_rate=sample_rate, version=version, params=vad_params)
sample_rate=sample_rate,
version=version,
force_reload=force_reload,
skip_validation=skip_validation,
trust_repo=trust_repo,
params=vad_params)
self._audio_passthrough = audio_passthrough

self._processor_vad_state: VADState = VADState.QUIET
Expand Down

0 comments on commit 5fcc964

Please sign in to comment.