Views
No views yet
1import torch
2from TTS.api import TTS
3
4# Initialize TTS with your fine-tuned model
5device = "cuda" if torch.cuda.is_available() else "cpu"
6
7# Load the model (replace with your downloaded path)
8tts = TTS(model_path="path/to/model", config_path="path/to/config.json").to(device)
9
10# Generate speech
11tts.tts_to_file(
12 text="नमस्ते, आज मौसम कैसा है?",
13 file_path="output.wav",
14 speaker_wav="path/to/reference_speaker.wav", # Optional: for voice cloning
15 language="hi"
16)1from TTS.tts.models.xtts import Xtts
2from TTS.tts.configs.xtts_config import XttsConfig
3import torch
4
5# Load config
6config = XttsConfig()
7config.load_json("config.json")
8
9# Load model
10model = Xtts.init_from_config(config)
11model.load_checkpoint(config, checkpoint_dir=".")
12
13# Move to GPU
14device = "cuda" if torch.cuda.is_available() else "cpu"
15model = model.to(device)
16
17# Generate speech
18outputs = model.synthesize(
19 text="नमस्ते, मैं आपकी हिंदी टीटीएस मॉडल हूं।",
20 config=config,
21 speaker_wav="reference_speaker.wav",
22 language="hi",
23 temperature=0.65,
24 repetition_penalty=10.0,
25 top_p=0.85
26)
27
28# Save audio
29import torchaudio
30wav = torch.from_numpy(outputs["wav"]).unsqueeze(0)
31torchaudio.save("output.wav", wav, config.audio.sample_rate)1tts --model_path . \
2 --text "नमस्ते, कैसे हैं आप?" \
3 --speaker_wav reference.wav \
4 --language_idx hi \
5 --out_path output.wav1# Install Coqui TTS
2pip install TTS torch torchaudio
3
4# Download this model
5# Via Hugging Face Hub
6from huggingface_hub import snapshot_download
7model_path = snapshot_download(repo_id="YOUR_USERNAME/hindi-tts-finetuned")model.pth - Final trained modelbest_model.pth - Best performing checkpointconfig.json - Model configurationvocab.json - Vocabulary (if applicable)1# Greetings
2"नमस्ते, कैसे हैं आप?"
3"शुभ प्रभात, आज का दिन शुभ हो।"
4
5# Conversational
6"आज मौसम बहुत अच्छा है।"
7"क्या मैं आपकी मदद कर सकता हूं?"
8
9# Formal
10"मैं आपकी सहायता के लिए यहां हूं।"
11"कृपया अपना प्रश्न पूछें।"1@misc{hindi-xtts-finetuned-2025,
2 title={Hindi Fine-tuned XTTS v2 Model},
3 author={Your Name},
4 year={2025},
5 publisher={Hugging Face},
6 howpublished={\url{https://huggingface.co/YOUR_USERNAME/hindi-tts-finetuned}}
7}