Instructions to use mispeech/dasheng-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mispeech/dasheng-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("audio-classification", model="mispeech/dasheng-base", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("mispeech/dasheng-base", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Fix batched inputs longer than target_length (clips mixed) and keep the last full segment
#2
by Wataru - opened
- modeling_dasheng.py +3 -2
modeling_dasheng.py
CHANGED
|
@@ -381,14 +381,15 @@ class AudioTransformerMAE_Encoder(nn.Module):
|
|
| 381 |
else:
|
| 382 |
splits = torch.stack(splits[:-1], dim=0)
|
| 383 |
else:
|
| 384 |
-
splits = torch.stack(splits
|
| 385 |
n_splits = len(splits)
|
| 386 |
x = torch.flatten(splits, 0, 1) # spl b c f t-> (spl b) c f t
|
| 387 |
else:
|
| 388 |
n_splits = 1
|
| 389 |
|
| 390 |
x = self.forward_features(x)
|
| 391 |
-
|
|
|
|
| 392 |
if padding_start:
|
| 393 |
x = x[:,:padding_start, :]
|
| 394 |
return x
|
|
|
|
| 381 |
else:
|
| 382 |
splits = torch.stack(splits[:-1], dim=0)
|
| 383 |
else:
|
| 384 |
+
splits = torch.stack(splits, dim=0)
|
| 385 |
n_splits = len(splits)
|
| 386 |
x = torch.flatten(splits, 0, 1) # spl b c f t-> (spl b) c f t
|
| 387 |
else:
|
| 388 |
n_splits = 1
|
| 389 |
|
| 390 |
x = self.forward_features(x)
|
| 391 |
+
# (spl b) t c -> b (spl t) c: each clip's own segments, in time order
|
| 392 |
+
x = x.reshape(n_splits, -1, *x.shape[1:]).transpose(0, 1).flatten(1, 2)
|
| 393 |
if padding_start:
|
| 394 |
x = x[:,:padding_start, :]
|
| 395 |
return x
|