Skip to content

Commit fefaf46

Browse files
committed
fixed denoiser="demucs" + suppress_silence=False error (#441)
-fixed tensor to numpy conversion error caused by using `denoiser="demucs"` with `suppress_silence=False` when device is not CPU (#441) -fixed incorrect return type hint for `.stabilization.nonvad.wav2mask()`
1 parent a44ebf3 commit fefaf46

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

stable_whisper/stabilization/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ def reset(self):
9898
def _silent_mask_test(self, mask, min_unit_per_word) -> bool:
9999
if self.ignore_is_silent or mask is None:
100100
return False
101-
non_silent_unit_count = mask.shape[-1] - np.flatnonzero(mask).shape[-1]
101+
nonzero_count = torch.count_nonzero(mask) if torch.is_tensor(mask) else np.count_nonzero(mask)
102+
non_silent_unit_count = mask.shape[-1] - nonzero_count
102103
return non_silent_unit_count < min_unit_per_word
103104

104105
def _append_timings(self, timings: np.ndarray):

stable_whisper/stabilization/nonvad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def wav2mask(
4545
q_levels: int = 20,
4646
k_size: int = 5,
4747
sr: int = None
48-
) -> (Tuple[torch.Tensor, Tuple[np.ndarray, np.ndarray]], None):
48+
) -> (torch.Tensor, None):
4949
"""
5050
Generate 1D mask from waveform for suppressing timestamp tokens.
5151
"""

0 commit comments

Comments
 (0)