Text-to-Speech
Transformers
Safetensors
Kabyle
agbalu_speech
feature-extraction
kabyle
taqbaylit
berber
amazigh
speech-synthesis
voice-cloning
cross-lingual-voice-cloning
expressive-speech
low-resource
custom_code
Instructions to use agbalu/Matoub-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use agbalu/Matoub-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="agbalu/Matoub-4B", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("agbalu/Matoub-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download objective.py from agbalu/Matoub-4B: direct link, hf CLI and curl.
- Browser
- Download file 1.24 kB
-
https://huggingface.co/agbalu/Matoub-4B/resolve/main/objective.py
- Command line
-
hf download hf://agbalu/Matoub-4B/objective.py
-
curl -L -o objective.py https://huggingface.co/agbalu/Matoub-4B/resolve/main/objective.py
1.24 kB
| """Compute token-summed codec loss without weighting short microbatches equally.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass | |
| from torch import Tensor | |
| from torch.nn import functional | |
| from .layout import CODEBOOKS, IGNORE, VOCABULARY | |
| class CodecLoss: | |
| stream_nats: Tensor | |
| stream_counts: Tensor | |
| def numerator(self) -> Tensor: | |
| return self.stream_nats.sum() | |
| def count(self) -> Tensor: | |
| return self.stream_counts.sum() | |
| def codec_loss(logits: Tensor, labels: Tensor) -> CodecLoss: | |
| if logits.shape[:-1] != labels.shape or logits.shape[-2:] != (CODEBOOKS, VOCABULARY): | |
| message = f'codec loss shape mismatch logits={tuple(logits.shape)}, labels={tuple(labels.shape)}' | |
| raise ValueError(message) | |
| valid = labels.ne(IGNORE) | |
| if not bool(valid.any().item()): | |
| message = 'codec loss has zero supervised targets' | |
| raise ValueError(message) | |
| losses = functional.cross_entropy(logits.float().reshape(-1, VOCABULARY), labels.reshape(-1), ignore_index=IGNORE, reduction='none').reshape(labels.shape) | |
| axes = tuple(range(labels.ndim - 1)) | |
| return CodecLoss(losses.sum(dim=axes), valid.sum(dim=axes)) | |