Audio-to-Audio
Transformers
Safetensors
dashengdenoiser
feature-extraction
signal-processing
custom_code
Instructions to use mispeech/dasheng-denoiser with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mispeech/dasheng-denoiser with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mispeech/dasheng-denoiser", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Heinrich Dinkel commited on
Commit ·
ec2e819
1
Parent(s): 7a87364
Fix crash when last audio chunk has fewer frames than patch stride
Browse filesPad the last chunk to self.time_patches frames when it's shorter after
splitting, preventing a RuntimeError in the Conv2d patch embedding when
input is not a multiple of target_length.
modeling_dasheng_encoder.py
CHANGED
|
@@ -283,10 +283,16 @@ class DashengEncoder(nn.Module):
|
|
| 283 |
x = rearrange(x, "b f t -> b 1 f t")
|
| 284 |
x = self.init_bn(x)
|
| 285 |
|
| 286 |
-
input_splits = x.split(self.target_length, dim=-1)
|
| 287 |
masks = [None for _ in range(len(input_splits))]
|
| 288 |
if attention_mask is not None:
|
| 289 |
-
masks = attention_mask.split(self.target_length, dim=-1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
outputs = []
|
| 292 |
for i, (input_split_x, mask) in enumerate(zip(input_splits, masks)):
|
|
|
|
| 283 |
x = rearrange(x, "b f t -> b 1 f t")
|
| 284 |
x = self.init_bn(x)
|
| 285 |
|
| 286 |
+
input_splits = list(x.split(self.target_length, dim=-1))
|
| 287 |
masks = [None for _ in range(len(input_splits))]
|
| 288 |
if attention_mask is not None:
|
| 289 |
+
masks = list(attention_mask.split(self.target_length, dim=-1))
|
| 290 |
+
|
| 291 |
+
if input_splits[-1].shape[-1] < self.time_patches:
|
| 292 |
+
pad_size = self.time_patches - input_splits[-1].shape[-1]
|
| 293 |
+
input_splits[-1] = torch.nn.functional.pad(input_splits[-1], (0, pad_size))
|
| 294 |
+
if masks[-1] is not None:
|
| 295 |
+
masks[-1] = torch.nn.functional.pad(masks[-1], (0, pad_size), value=0)
|
| 296 |
|
| 297 |
outputs = []
|
| 298 |
for i, (input_split_x, mask) in enumerate(zip(input_splits, masks)):
|