Instructions to use TheBOrganization/Arabic_TTS with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- VibeVoice
How to use TheBOrganization/Arabic_TTS with VibeVoice:
import torch, soundfile as sf, librosa, numpy as np from vibevoice.processor.vibevoice_processor import VibeVoiceProcessor from vibevoice.modular.modeling_vibevoice_inference import VibeVoiceForConditionalGenerationInference # Load voice sample (should be 24kHz mono) voice, sr = sf.read("path/to/voice_sample.wav") if voice.ndim > 1: voice = voice.mean(axis=1) if sr != 24000: voice = librosa.resample(voice, sr, 24000) processor = VibeVoiceProcessor.from_pretrained("TheBOrganization/Arabic_TTS") model = VibeVoiceForConditionalGenerationInference.from_pretrained( "TheBOrganization/Arabic_TTS", torch_dtype=torch.bfloat16 ).to("cuda").eval() model.set_ddpm_inference_steps(5) inputs = processor(text=["Speaker 0: Hello!\nSpeaker 1: Hi there!"], voice_samples=[[voice]], return_tensors="pt") audio = model.generate(**inputs, cfg_scale=1.3, tokenizer=processor.tokenizer).speech_outputs[0] sf.write("output.wav", audio.cpu().numpy().squeeze(), 24000) - Notebooks
- Google Colab
- Kaggle
File size: 6,518 Bytes
34f1ed6 0edbb26 34f1ed6 0edbb26 34f1ed6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
---
language:
- ar
tags:
- text-to-speech
- tts
- arabic
- voice-cloning
- zero-shot
- audio
- vibevoice
license: apache-2.0
pipeline_tag: text-to-speech
---
# ๐๏ธ Arabic_TTS by theBOrganization
<div align="center">
<h3>High-Fidelity, Zero-Shot Arabic Text-to-Speech</h3>
<p>Bringing natural, expressive, and culturally accurate Arabic speech to life.</p>
</div>
<br>
<td align="center">
<audio controls>
<source src="https://huggingface.co/theBOrganization/Arabic_TTS/resolve/main/audio/samp_3.wav" type="audio/wav">
Your browser does not support the audio element.
</audio>
</td>
## ๐ Overview
**Arabic_TTS** is a state-of-the-art Text-to-Speech model specifically optimized for the Arabic language. Built on the powerful **VibeVoice** architecture, this model goes beyond standard TTS by offering **zero-shot voice cloning**.
Simply provide a short reference audio clip, and the model will synthesize your input text in Arabic while perfectly capturing the timbre, tone, and unique characteristics of the reference speaker.
### โจ Key Features
* ๐ฃ๏ธ **Native Arabic Fluency:** Handles complex Arabic morphology, diacritics (Tashkeel) with high fidelity.
* ๐ญ **Zero-Shot Voice Cloning:** Clone any voice from a single reference audio sample without fine-tuning.
* ๐๏ธ **Controllable Generation:** Built-in Classifier-Free Guidance (CFG) and temperature sampling for expressive and diverse outputs.
* โก **Optimized Inference:** Supports CUDA (bfloat16), Apple Silicon MPS (float32), and CPU for maximum efficiency.
---
## ๐ง Audio Samples
Listen to the quality of the model below. We compare the original reference voice against the synthetic generated output.
<table>
<thead>
<tr>
<th align="center">๐ค Original Reference Voice</th>
<th align="center">๐ค Synthetic Generated Voice</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">
<audio controls>
<source src="https://huggingface.co/theBOrganization/Arabic_TTS/resolve/main/audio/samp_2.ogg" type="audio/wav">
Your browser does not support the audio element.
</audio>
</td>
<td align="center">
<audio controls>
<source src="https://huggingface.co/theBOrganization/Arabic_TTS/resolve/main/audio/samp_1.ogg" type="audio/wav">
Your browser does not support the audio element.
</audio>
</td>
</tr>
</tbody>
</table>
---
## ๐ ๏ธ Usage & Inference
### Prerequisites
Ensure you have PyTorch installed. You will also need the `vibevoice` library.
```bash
pip install torch torchaudio
# Install vibevoice (adjust based on your specific package distribution)
pip install vibevoice
```
### Inference Code
Below is the complete script to load the model, process the text and reference audio, and generate high-quality 24kHz speech.
```python
import os
import torch
import torchaudio as ta
from vibevoice.processor.vibevoice_processor import VibeVoiceProcessor
from vibevoice.modular.modeling_vibevoice_inference import VibeVoiceForConditionalGenerationInference
# --- Configuration ---
model_path = "theBOrganization/Arabic_TTS"
text = "SPEAKER 1: ู
ุฑุญุจุงุ ูุฐุง ู
ุซุงู ุนูู ุชูููุฏ ุงูุตูุช ุจุงููุบุฉ ุงูุนุฑุจูุฉ ุจุงุณุชุฎุฏุงู
ูู
ูุฐุฌ ุฌุฏูุฏ."
output_path = "output.wav"
# Device selection with fallback
device = "cuda" if torch.cuda.is_available() else ("mps" if torch.backends.mps.is_available() else "cpu")
print(f"๐ Loading model on {device}...")
# Load Processor
processor = VibeVoiceProcessor.from_pretrained(model_path)
# Set dtype and attention implementation based on device
if device == "mps":
dtype = torch.float32
elif device == "cuda":
dtype = torch.bfloat16
else:
dtype = torch.float32 # Note: float32 is recommended for CPU stability
attn_impl = "sdpa"
# Load Model
model = VibeVoiceForConditionalGenerationInference.from_pretrained(
model_path,
torch_dtype=dtype,
attn_implementation=attn_impl,
device_map=device if device != "mps" else None,
)
if device == "mps":
model.to("mps")
model.eval()
model.set_ddpm_inference_steps(10) # 10 steps for DDPM inference
# --- Prepare Inputs ---
reference_voice = "prompt.wav" # Replace with your reference audio path
print(f"๐๏ธ Using reference voice: {reference_voice}")
inputs = processor(
text=[text],
voice_samples=[[reference_voice]], # Batch of one speaker list
return_tensors="pt",
padding=True,
)
# Move tensors to the correct device
inputs = {
k: v.to(device) if torch.is_tensor(v) else v
for k, v in inputs.items()
}
# --- Generate Audio ---
print("๐ง Generating audio...")
with torch.no_grad():
outputs = model.generate(
**inputs,
cfg_scale=1.3,
tokenizer=processor.tokenizer,
generation_config={
'do_sample': True,
'temperature': 0.5
},
)
# --- Save Output ---
audio = outputs.speech_outputs[0].cpu().float() # shape: [1, T] or [T]
if audio.ndim == 1:
audio = audio.unsqueeze(0).float()
sample_rate = 24000
ta.save(output_path, audio, sample_rate)
print(f"โ
Successfully saved audio to {output_path}")
```
### ๐ Input Formatting
The model expects text to be prefixed with a speaker identifier.
* **Format:** `SPEAKER X: <Your Arabic Text Here>`
* **Example:** `SPEAKER 1: ุฃููุงู ูุณููุงู ุจูู
ูู ู
ููุนูุง.`
---
## โ๏ธ Model Details
| Feature | Specification |
| :--- | :--- |
| **Architecture** | VibeVoice (Diffusion / Flow-Matching based) |
| **Sampling Rate** | 24,000 Hz |
| **Inference Steps** | 10 (DDPM) |
| **Supported Languages** | Arabic (Modern Standard) |
---
## โ ๏ธ Limitations & Ethical Considerations
While **Arabic_TTS** produces highly realistic speech, users must adhere to responsible AI practices:
1. **Consent:** Do not use the zero-shot voice cloning feature to clone voices without the explicit consent of the speaker.
2. **Misinformation:** Do not use this model to generate deceptive audio (deepfakes) for malicious purposes, fraud, or political manipulation.
3. **Dialects:** While the model excels at Modern Standard Arabic (MSA), extreme regional dialects or heavy code-switching (mixing Arabic and English in the same sentence) may result in slight pronunciation artifacts.
---
**Developed with โค๏ธ by [theBOrganization]**
For inquiries, collaborations, or bug reports, please open an issue on the repository or contact us directly.
|