mirror of
https://github.com/pyannote/pyannote-audio.git
synced 2026-11-20 13:07:51 +09:00
feat: add option to make progress hook transient (#1264)
This commit is contained in:
1 parent
2a9a892726
commit
d4ff0bd23d
1 file changed
+10
@@ -51,6 +51,11 @@ def logging_hook(
|
||||
class ProgressHook:
|
||||
"""Hook to show progress of each internal step
|
||||
|
||||
Parameters
|
||||
----------
|
||||
transient: bool, optional
|
||||
Clear the progress on exit. Defaults to False.
|
||||
|
||||
Example
|
||||
-------
|
||||
pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization")
|
||||
@@ -58,6 +63,10 @@ class ProgressHook:
|
||||
output = pipeline(file, hook=hook)
|
||||
"""
|
||||
|
||||
def __init__(self, transient: bool = False):
|
||||
super().__init__()
|
||||
self.transient = transient
|
||||
|
||||
def __enter__(self):
|
||||
|
||||
self.progress = Progress(
|
||||
@@ -65,6 +74,7 @@ class ProgressHook:
|
||||
BarColumn(),
|
||||
TaskProgressColumn(),
|
||||
TimeRemainingColumn(elapsed_when_finished=True),
|
||||
transient=self.transient,
|
||||
)
|
||||
self.progress.start()
|
||||
return self
|
||||
|
||||
Reference in new issue
Block a user