Instructions to use azeddinShr/Spark-TTS-Arabic-Complete with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use azeddinShr/Spark-TTS-Arabic-Complete with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-to-speech", model="azeddinShr/Spark-TTS-Arabic-Complete")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("azeddinShr/Spark-TTS-Arabic-Complete", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,54 +2,265 @@
|
|
| 2 |
language:
|
| 3 |
- ar
|
| 4 |
license: apache-2.0
|
|
|
|
| 5 |
tags:
|
| 6 |
- text-to-speech
|
| 7 |
- arabic
|
| 8 |
- spark-tts
|
| 9 |
- tts
|
| 10 |
-
|
|
|
|
| 11 |
datasets:
|
| 12 |
- MBZUAI/ClArTTS
|
|
|
|
|
|
|
| 13 |
---
|
| 14 |
|
| 15 |
# Spark-TTS Arabic (Fine-tuned on ClArTTS)
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
##
|
| 20 |
```python
|
| 21 |
-
from
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
import torch
|
|
|
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
model = AutoModel.from_pretrained("azeddinShr/Spark-TTS-Arabic-Complete", trust_remote_code=True).eval().to(device)
|
| 28 |
-
processor.model = model
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
|
| 32 |
-
ref_text = "ุงููููุตูู ุงููู
ูุฑูุฌูุนูููู"
|
| 33 |
-
inputs = processor(text=text.lower(), prompt_speech_path="reference.wav", prompt_text=ref_text, return_tensors="pt").to(device)
|
| 34 |
-
global_tokens = inputs.pop("global_token_ids_prompt", None)
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
|
|
|
|
|
|
| 42 |
```
|
| 43 |
|
| 44 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
-
|
| 52 |
|
| 53 |
-
- BiCodec (audio encoder/decoder) - unchanged from base
|
| 54 |
-
- wav2vec2 (speech encoder) - unchanged from base
|
| 55 |
-
- LLM (Qwen2) - **fine-tuned on Arabic**
|
|
|
|
| 2 |
language:
|
| 3 |
- ar
|
| 4 |
license: apache-2.0
|
| 5 |
+
base_model: SparkAudio/Spark-TTS-0.5B
|
| 6 |
tags:
|
| 7 |
- text-to-speech
|
| 8 |
- arabic
|
| 9 |
- spark-tts
|
| 10 |
- tts
|
| 11 |
+
- voice-cloning
|
| 12 |
+
- classical-arabic
|
| 13 |
datasets:
|
| 14 |
- MBZUAI/ClArTTS
|
| 15 |
+
library_name: transformers
|
| 16 |
+
pipeline_tag: text-to-speech
|
| 17 |
---
|
| 18 |
|
| 19 |
# Spark-TTS Arabic (Fine-tuned on ClArTTS)
|
| 20 |
|
| 21 |
+
Fine-tuned version of [SparkAudio/Spark-TTS-0.5B](https://huggingface.co/SparkAudio/Spark-TTS-0.5B) specialized for Arabic text-to-speech synthesis. The LLM component has been fine-tuned on the ClArTTS dataset (Classical Arabic Text-to-Speech corpus) containing 12 hours of high-quality single-speaker recordings.
|
| 22 |
+
|
| 23 |
+
## ๐ Model Description
|
| 24 |
+
|
| 25 |
+
Spark-TTS is a neural text-to-speech system that combines a language model (Qwen2) with a neural audio codec (BiCodec) for high-quality speech synthesis. This version has been specifically optimized for Arabic through fine-tuning on Classical Arabic speech data.
|
| 26 |
+
|
| 27 |
+
**Architecture Components:**
|
| 28 |
+
- **LLM (Qwen2):** Fine-tuned for Arabic text-to-semantic token generation
|
| 29 |
+
- **BiCodec:** Neural audio codec for semantic-to-audio token conversion (unchanged)
|
| 30 |
+
- **wav2vec2-large-xlsr-53:** Speech encoder for voice cloning (unchanged)
|
| 31 |
+
|
| 32 |
+
**What Changed:**
|
| 33 |
+
Only the LLM component was fine-tuned. The audio tokenizer and speech encoder remain identical to the base model, ensuring compatibility with the original Spark-TTS architecture.
|
| 34 |
+
|
| 35 |
+
**Key Features:**
|
| 36 |
+
- Voice cloning with 5-30 seconds of reference audio
|
| 37 |
+
- Natural prosody and intonation for Classical Arabic
|
| 38 |
+
- Single-speaker consistency
|
| 39 |
+
- Controllable generation parameters
|
| 40 |
+
|
| 41 |
+
## ๐ฏ Intended Use
|
| 42 |
+
|
| 43 |
+
### Direct Use
|
| 44 |
+
- Arabic audiobook narration (Classical/MSA)
|
| 45 |
+
- Voice-over for Arabic educational content
|
| 46 |
+
- Accessibility tools for Arabic text
|
| 47 |
+
- Voice cloning for Arabic speakers
|
| 48 |
+
- Arabic language learning applications
|
| 49 |
+
|
| 50 |
+
### Downstream Use
|
| 51 |
+
Can be further fine-tuned for:
|
| 52 |
+
- Dialectal Arabic variants (Egyptian, Levantine, Gulf)
|
| 53 |
+
- Domain-specific terminology (religious texts, literature)
|
| 54 |
+
- Multi-speaker scenarios
|
| 55 |
+
- Emotional or expressive speech
|
| 56 |
+
|
| 57 |
+
### Out-of-Scope Use
|
| 58 |
+
**Not recommended for:**
|
| 59 |
+
- Real-time speech synthesis (model is relatively slow)
|
| 60 |
+
- Non-diacritized Arabic text (requires tashkeel)
|
| 61 |
+
- Languages other than Arabic
|
| 62 |
+
- Singing or non-speech audio generation
|
| 63 |
+
|
| 64 |
+
## ๐ How to Use
|
| 65 |
+
|
| 66 |
+
### Installation
|
| 67 |
+
|
| 68 |
+
First, clone the official Spark-TTS repository (required for inference):
|
| 69 |
+
```bash
|
| 70 |
+
# Clone Spark-TTS
|
| 71 |
+
git clone https://github.com/SparkAudio/Spark-TTS
|
| 72 |
+
cd Spark-TTS
|
| 73 |
+
|
| 74 |
+
# Install dependencies
|
| 75 |
+
pip install transformers soundfile huggingface_hub omegaconf torch
|
| 76 |
+
```
|
| 77 |
|
| 78 |
+
### Download Model
|
| 79 |
```python
|
| 80 |
+
from huggingface_hub import snapshot_download
|
| 81 |
+
|
| 82 |
+
# Download the fine-tuned model
|
| 83 |
+
model_dir = snapshot_download(
|
| 84 |
+
repo_id="azeddinShr/Spark-TTS-Arabic-Complete",
|
| 85 |
+
local_dir="./arabic_model"
|
| 86 |
+
)
|
| 87 |
+
```
|
| 88 |
+
**Very Important Note:** This model requires the official Spark-TTS repository for inference. The model files alone are not sufficient - you must clone the Spark-TTS repo and use their inference pipeline.
|
| 89 |
+
|
| 90 |
+
### Setup Inference Environment
|
| 91 |
+
```python
|
| 92 |
+
import sys
|
| 93 |
import torch
|
| 94 |
+
import soundfile as sf
|
| 95 |
|
| 96 |
+
# Add Spark-TTS to path
|
| 97 |
+
sys.path.insert(0, './cli')
|
|
|
|
|
|
|
| 98 |
|
| 99 |
+
# Import SparkTTS class
|
| 100 |
+
from SparkTTS import SparkTTS
|
|
|
|
|
|
|
|
|
|
| 101 |
|
| 102 |
+
# Initialize device
|
| 103 |
+
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 104 |
+
print(f"Using device: {device}")
|
| 105 |
+
```
|
| 106 |
|
| 107 |
+
### Load Model
|
| 108 |
+
```python
|
| 109 |
+
# Load the fine-tuned Arabic model
|
| 110 |
+
tts = SparkTTS("./arabic_model", device)
|
| 111 |
+
print("โ
Model loaded successfully!")
|
| 112 |
```
|
| 113 |
|
| 114 |
+
### Basic Text-to-Speech
|
| 115 |
+
```python
|
| 116 |
+
# Prepare input text (must include diacritics)
|
| 117 |
+
text = "ู
ูุฑูุญูุจูุง ุจูููู
ู ููู ููู
ููุฐูุฌู ุชูุญูููููู ุงููููุตูู ุฅูููู ููููุงู
ู ุจูุงููููุบูุฉู ุงููุน๏ฟฝ๏ฟฝุฑูุจููููุฉู."
|
| 118 |
+
|
| 119 |
+
# Reference audio and its transcript
|
| 120 |
+
reference_audio = "path/to/reference.wav" # 5-30 seconds of clear Arabic speech
|
| 121 |
+
reference_text = "ุงููููุตูู ุงููู
ูุทูุงุจููู ูููุตููููุชู ุงููู
ูุฑูุฌูุนูููู"
|
| 122 |
+
|
| 123 |
+
# Generate speech
|
| 124 |
+
wav = tts.inference(
|
| 125 |
+
text,
|
| 126 |
+
prompt_speech_path=reference_audio,
|
| 127 |
+
prompt_text=reference_text
|
| 128 |
+
)
|
| 129 |
+
|
| 130 |
+
# Save output
|
| 131 |
+
sf.write("output.wav", wav, samplerate=16000)
|
| 132 |
+
print("โ
Audio generated!")
|
| 133 |
+
```
|
| 134 |
+
|
| 135 |
+
### Advanced Generation with Parameters
|
| 136 |
+
```python
|
| 137 |
+
# Generate with custom parameters
|
| 138 |
+
wav = tts.inference(
|
| 139 |
+
text,
|
| 140 |
+
prompt_speech_path=reference_audio,
|
| 141 |
+
prompt_text=reference_text,
|
| 142 |
+
temperature=0.8, # Controls randomness (0.1-1.5, default: 0.8)
|
| 143 |
+
top_k=50, # Top-k sampling (default: 50)
|
| 144 |
+
top_p=0.95 # Nucleus sampling (default: 0.95)
|
| 145 |
+
)
|
| 146 |
|
| 147 |
+
sf.write("output_custom.wav", wav, samplerate=16000)
|
| 148 |
+
```
|
| 149 |
+
|
| 150 |
+
## โ ๏ธ Important Requirements
|
| 151 |
+
|
| 152 |
+
### Input Text Requirements
|
| 153 |
+
- **Diacritization (Tashkeel) is REQUIRED**
|
| 154 |
+
- Text must include full Arabic diacritics (ููุชูุญูุฉุ ููุณูุฑูุฉุ ุถูู
ููุฉุ ุณูููููุ etc.)
|
| 155 |
+
- Use AI tools (ChatGPT, Claude) or [online diacritizers](https://tahadz.com/mishkal) to add tashkeel
|
| 156 |
+
|
| 157 |
+
**Example:**
|
| 158 |
+
- โ Bad: "ู
ุฑุญุจุง ุจูู
ูู ุงููู
ูุฐุฌ"
|
| 159 |
+
- โ
Good: "ู
ูุฑูุญูุจูุง ุจูููู
ู ููู ุงููููู
ููุฐูุฌู"
|
| 160 |
+
|
| 161 |
+
### Reference Audio Requirements
|
| 162 |
+
- **Duration:** 5-30 seconds of clear speech
|
| 163 |
+
- **Quality:** Clean recording, minimal background noise
|
| 164 |
+
- **Speaker:** Single speaker only
|
| 165 |
+
- **Language:** Arabic (preferably MSA or Classical)
|
| 166 |
+
- **Format:** WAV file recommended
|
| 167 |
+
|
| 168 |
+
### Reference Transcript Requirements
|
| 169 |
+
- Must match reference audio exactly
|
| 170 |
+
- Must include full diacritics
|
| 171 |
+
- Text alignment is critical for quality
|
| 172 |
+
|
| 173 |
+
## ๐ Training Details
|
| 174 |
+
|
| 175 |
+
### Training Data
|
| 176 |
+
|
| 177 |
+
**Dataset:** [MBZUAI/ClArTTS](https://huggingface.co/datasets/MBZUAI/ClArTTS)
|
| 178 |
+
- **Full dataset size:** 12 hours, 9,500 utterances
|
| 179 |
+
- **Training subset:** 30% (~2,850 utterances)
|
| 180 |
+
- **Speaker:** Single male speaker
|
| 181 |
+
- **Language:** Classical Arabic (MSA)
|
| 182 |
+
- **Sample rate:** 40.1 kHz (resampled to 24 kHz for training)
|
| 183 |
+
- **Text quality:** Fully diacritized
|
| 184 |
+
|
| 185 |
+
### Training Procedure
|
| 186 |
+
|
| 187 |
+
**Fine-tuning Framework:** Axolotl + LoRA
|
| 188 |
+
|
| 189 |
+
**Training Configuration:**
|
| 190 |
+
```yaml
|
| 191 |
+
Base Model: SparkAudio/Spark-TTS-0.5B (LLM component only)
|
| 192 |
+
Fine-tuning Method: Full fine-tuning (not LoRA)
|
| 193 |
+
Epochs: 20
|
| 194 |
+
Batch Size: 8 (1 per device ร 8 gradient accumulation)
|
| 195 |
+
Learning Rate: 2e-4
|
| 196 |
+
Optimizer: AdamW (torch fused)
|
| 197 |
+
LR Scheduler: Cosine
|
| 198 |
+
Warmup Steps: 10
|
| 199 |
+
Sequence Length: 1024
|
| 200 |
+
Precision: bfloat16
|
| 201 |
+
Gradient Checkpointing: Enabled
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
**Data Processing:**
|
| 205 |
+
1. Audio resampled to 24 kHz
|
| 206 |
+
2. Semantic tokens extracted using BiCodec
|
| 207 |
+
3. Training pairs: `[text, semantic_tokens]` created for LLM training
|
| 208 |
+
4. Text normalized to lowercase during processing
|
| 209 |
+
|
| 210 |
+
**Training Infrastructure:**
|
| 211 |
+
- Hardware: Single NVIDIA GPU (Colab)
|
| 212 |
+
- Training Time: ~3-4 hours
|
| 213 |
+
- Framework: PyTorch + Transformers + Axolotl
|
| 214 |
+
|
| 215 |
+
**Data Preparation Steps:**
|
| 216 |
+
```python
|
| 217 |
+
# 1. Load ClArTTS from HuggingFace
|
| 218 |
+
# 2. Resample audio from 40.1 kHz โ 24 kHz
|
| 219 |
+
# 3. Extract semantic tokens using BiCodec
|
| 220 |
+
# 4. Create metadata: [audio_path, text]
|
| 221 |
+
# 5. Generate training pairs: [text โ semantic_tokens]
|
| 222 |
+
```
|
| 223 |
+
|
| 224 |
+
**Base Model:**
|
| 225 |
+
```bibtex
|
| 226 |
+
@misc{sparktts2024,
|
| 227 |
+
title={Spark-TTS: Zero-Shot Multi-Style Text-to-Speech via Large Language Models},
|
| 228 |
+
author={SparkAudio Team},
|
| 229 |
+
year={2024},
|
| 230 |
+
url={https://github.com/SparkAudio/Spark-TTS}
|
| 231 |
+
}
|
| 232 |
+
```
|
| 233 |
+
|
| 234 |
+
**Training Dataset:**
|
| 235 |
+
```bibtex
|
| 236 |
+
@inproceedings{kulkarni2023clartts,
|
| 237 |
+
author={Ajinkya Kulkarni and Atharva Kulkarni and Sara Shatnawi and Hanan Aldarmaki},
|
| 238 |
+
title={ClArTTS: An Open-Source Classical Arabic Text-to-Speech Corpus},
|
| 239 |
+
year={2023},
|
| 240 |
+
booktitle={INTERSPEECH 2023},
|
| 241 |
+
pages={5511--5515},
|
| 242 |
+
doi={10.21437/Interspeech.2023-2224}
|
| 243 |
+
}
|
| 244 |
+
```
|
| 245 |
+
|
| 246 |
+
## ๐ Acknowledgments
|
| 247 |
+
|
| 248 |
+
- **Base Model:** [SparkAudio Team](https://github.com/SparkAudio) for Spark-TTS-0.5B
|
| 249 |
+
- **Dataset:** MBZUAI for ClArTTS corpus
|
| 250 |
+
- **Frameworks:** Hugging Face Transformers, Axolotl, PyTorch
|
| 251 |
+
|
| 252 |
+
## ๐ License
|
| 253 |
+
|
| 254 |
+
Apache 2.0 (same as base model)
|
| 255 |
+
|
| 256 |
+
## ๐ง Contact
|
| 257 |
+
|
| 258 |
+
For questions, collaboration, or support:
|
| 259 |
+
- **Email:** azdinsahir11@gmail.com
|
| 260 |
+
- **Hugging Face:** [@azeddinShr](https://huggingface.co/azeddinShr)
|
| 261 |
+
- **Model Discussions:** Use the Community tab above
|
| 262 |
+
|
| 263 |
+
---
|
| 264 |
|
| 265 |
+
**Note:** This model requires the official Spark-TTS repository for inference. The model files alone are not sufficient - you must clone the Spark-TTS repo and use their inference pipeline.
|
| 266 |
|
|
|
|
|
|
|
|
|