Views
No views yet
pip install chatterbox-tts torch torchaudio huggingface_hub1import torch
2import torchaudio as ta
3from chatterbox.mtl_tts import ChatterboxMultilingualTTS
4from huggingface_hub import hf_hub_download
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8# Load base multilingual model
9model = ChatterboxMultilingualTTS.from_pretrained(device=device)
10
11# Download and apply Arabic fine-tuned weights
12t3_path = hf_hub_download(
13 repo_id="YOUR-USERNAME/chatterbox-arabic-finetuned",
14 filename="t3_cfg.pt"
15)
16t3_state = torch.load(t3_path, map_location="cpu")
17model.t3.load_state_dict(t3_state)
18
19# Generate Arabic speech
20arabic_text = "مرحباً بك في نموذج تحويل النص إلى كلام المحسّن للغة العربية"
21wav = model.generate(arabic_text, language_id="ar")
22ta.save("arabic_output.wav", wav, model.sr)1import torch
2from chatterbox.mtl_tts import ChatterboxMultilingualTTS
3from huggingface_hub import hf_hub_download
4
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7# Load base model
8model = ChatterboxMultilingualTTS.from_pretrained(device=device)
9
10# Download all fine-tuned weights
11repo_id = "YOUR-USERNAME/chatterbox-arabic-finetuned"
12
13t3_path = hf_hub_download(repo_id=repo_id, filename="t3_cfg.pt")
14conds_path = hf_hub_download(repo_id=repo_id, filename="conds.pt")
15s3gen_path = hf_hub_download(repo_id=repo_id, filename="s3gen.pt")
16ve_path = hf_hub_download(repo_id=repo_id, filename="ve.pt")
17
18# Load all components
19model.t3.load_state_dict(torch.load(t3_path, map_location="cpu"))
20model.conds.load_state_dict(torch.load(conds_path, map_location="cpu"))
21model.s3gen.load_state_dict(torch.load(s3gen_path, map_location="cpu"))
22model.ve.load_state_dict(torch.load(ve_path, map_location="cpu"))
23
24# Generate
25arabic_text = "هذا اختبار للنموذج المحسّن"
26wav = model.generate(arabic_text, language_id="ar")1import torch
2import torchaudio as ta
3from chatterbox.mtl_tts import ChatterboxMultilingualTTS
4from huggingface_hub import hf_hub_download
5
6device = "cuda" if torch.cuda.is_available() else "cpu"
7
8# Load model with fine-tuned weights
9model = ChatterboxMultilingualTTS.from_pretrained(device=device)
10t3_path = hf_hub_download(
11 repo_id="YOUR-USERNAME/chatterbox-arabic-finetuned",
12 filename="t3_cfg.pt"
13)
14model.t3.load_state_dict(torch.load(t3_path, map_location="cpu"))
15
16# Generate with reference audio (voice cloning)
17arabic_text = "السلام عليكم ورحمة الله وبركاته"
18reference_audio = "path/to/arabic_speaker.wav" # 6+ seconds recommended
19
20wav = model.generate(
21 arabic_text,
22 language_id="ar",
23 audio_prompt_path=reference_audio,
24 exaggeration=0.5, # Control expressiveness (0.0-2.0)
25 cfg_weight=0.5 # Control adherence to prompt (0.0-1.0)
26)
27
28ta.save("arabic_cloned_voice.wav", wav, model.sr)1# The model handles Arabic text with or without diacritics
2text_with_tashkeel = "مَرْحَباً بِكَ فِي عَالَمِ الذَّكَاءِ الاصْطِنَاعِيِّ"
3text_without_tashkeel = "مرحبا بك في عالم الذكاء الاصطناعي"
4
5# Both work well
6wav1 = model.generate(text_with_tashkeel, language_id="ar")
7wav2 = model.generate(text_without_tashkeel, language_id="ar")0.25: More monotone, robotic0.5: Natural (default)1.0-2.0: More dramatic and expressive0.3: Faster pacing0.5: Balanced (default)0.7+: More similar to referencet3_cfg.pt - Text-to-speech transformer (main component) - 2.1 GBconds.pt - Conditioning model - 107 KBs3gen.pt - Speech generation model - 1.06 GBve.pt - Voice encoder - [size]tokenizer.json - Tokenizer configurationtext = "الذكاء الاصطناعي يغير العالم من حولنا بطرق لم نتخيلها من قبل"1greetings = [
2 "السلام عليكم ورحمة الله وبركاته",
3 "صباح الخير",
4 "مساء الخير",
5 "أهلاً وسهلاً",
6 "كيف حالك؟"
7]text = "اليوم هو الخامس عشر من يناير عام ألفين وستة وعشرين"1@misc{chatterboxtts2025,
2 author = {{Resemble AI}},
3 title = {{Chatterbox-TTS}},
4 year = {2025},
5 howpublished = {\url{https://github.com/resemble-ai/chatterbox}},
6 note = {GitHub repository}
7}