Skip to content

Commit

Permalink
feat: add "hidden" option to ProgressHook (#1761)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbredin authored Oct 8, 2024
1 parent 5832510 commit 5ae7a48
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## develop

### New features

- feat: add `"hidden"` option to `ProgressHook`

### Fixes

- fix: fix clipping issue in speech separation pipeline ([@joonaskalda](https://github.com/joonaskalda/))
Expand Down
13 changes: 12 additions & 1 deletion pyannote/audio/pipelines/utils/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,14 @@ class ProgressHook:
output = pipeline(file, hook=hook)
"""

def __init__(self, transient: bool = False):
def __init__(self, transient: bool = False, hidden: bool = False):
self.transient = transient
self.hidden = hidden

def __enter__(self):
if self.hidden:
return self

self.progress = Progress(
TextColumn("[progress.description]{task.description}"),
BarColumn(),
Expand All @@ -112,7 +116,11 @@ def __enter__(self):
return self

def __exit__(self, *args):
if self.hidden:
return

self.progress.stop()
return

def __call__(
self,
Expand All @@ -122,6 +130,9 @@ def __call__(
total: Optional[int] = None,
completed: Optional[int] = None,
):
if self.hidden:
return

if completed is None:
completed = total = 1

Expand Down

0 comments on commit 5ae7a48

Please sign in to comment.