feat: add "hidden" option to ProgressHook (#1761)

This commit is contained in:
Hervé BREDIN authored and GitHub committed 2024-10-08 11:09:37 +02:00
1 parent 583251059d
commit 5ae7a48dd2
2 files changed
+16 -1

No files matched your search

+4
View File
@@ -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/))
+12 -1
View File
@@ -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(),
@@ -112,7 +116,11 @@ class ProgressHook:
return self
def __exit__(self, *args):
if self.hidden:
return
self.progress.stop()
return
def __call__(
self,
@@ -122,6 +130,9 @@ class ProgressHook:
total: Optional[int] = None,
completed: Optional[int] = None,
):
if self.hidden:
return
if completed is None:
completed = total = 1