Text-to-Speech
F5-TTS
Hindi

instead of hindi its speak some weird language

#19
by littlelostsoul - opened

instead of hindi it speaks some weird languae, and indic mio only 2 languages showsing english and japan

littlelostsoul changed discussion title from instead of hindi its speakers someweird language to instead of hindi its speak some weird language
SPRINGLab org

Please verify that you are using Indic-Mio checkpoint.

i re-tried this f5 one it works this time...but i m unable to add any emotion to the text every thing is said in a regular tone

use this code:
import os
import sys
import shutil
from pathlib import Path
import numpy as np
import torch

--- 1. DEFINE YOUR LOCAL PATHS ---

ENGINE_BASE = Path(r"D:\TTS_Engine")
CKPT_BASE = ENGINE_BASE / "ckpts"
F5_DIR = CKPT_BASE / "f5_hindi"
VOCOS_DIR = CKPT_BASE / "vocos-mel-24khz"
FFMPEG_BIN = ENGINE_BASE / "ffmpeg" / "bin"

if FFMPEG_BIN.exists():
os.environ["PATH"] += os.pathsep + str(FFMPEG_BIN)

--- 2. FORCE HINDI VOCABULARY ---

default_vocab_path = ENGINE_BASE / "venv" / "Lib" / "site-packages" / "f5_tts" / "infer" / "examples" / "vocab.txt"
hindi_vocab_path = F5_DIR / "vocab.txt"

if hindi_vocab_path.exists() and default_vocab_path.exists():
shutil.copy(hindi_vocab_path, default_vocab_path)

--- 3. MONKEYPATCH HUGGINGFACE ---

import huggingface_hub
def mocked_hf_download(repo_id, filename, **kwargs):
if "vocos" in repo_id:
return str(VOCOS_DIR / filename)
if "F5-TTS" in repo_id or "f5tts" in repo_id or "SPRINGLab" in repo_id:
if "safetensors" in filename or "model.safetensors" in filename:
return str(F5_DIR / "model_2500000.safetensors")
if "vocab.txt" in filename:
return str(F5_DIR / "vocab.txt")
return str(F5_DIR / filename)
return ""
huggingface_hub.hf_hub_download = mocked_hf_download

--- 4. DISABLE WHISPER ---

import f5_tts.infer.utils_infer as utils_infer
utils_infer.initialize_asr_pipeline = lambda *args, **kwargs: print("ASR Disabled")
utils_infer.transcribe = lambda *args, **kwargs: ""

--- 5. TEXT FILTER BYPASS ---

def bypassed_pinyin(texts, **kwargs):
return texts
utils_infer.convert_char_to_pinyin = bypassed_pinyin

--- 6. FORCE HINDI ARCHITECTURE (Fixes the RoPE Scramble) ---

original_load_model = utils_infer.load_model
def mocked_load_model(model_cls, model_cfg, ckpt_path, **kwargs):
# Added pe_attn_head=1 & checkpoint_activations=False
# Without these, the attention mechanism scrambles the audio into static!
model_cfg = dict(
dim=768,
depth=18,
heads=12,
ff_mult=2,
text_dim=512,
text_mask_padding=False,
conv_layers=4,
pe_attn_head=1,
checkpoint_activations=False
)
ckpt_path = str(F5_DIR / "model_2500000.safetensors")
kwargs["vocab_file"] = str(F5_DIR / "vocab.txt")
return original_load_model(model_cls, model_cfg, ckpt_path, **kwargs)
utils_infer.load_model = mocked_load_model

--- 7. SAFE INFER (Fixes the CFG Burn) ---

original_infer_process = utils_infer.infer_process
def safe_infer_process(*args, **kwargs):
# FORCE CFG to 1.0 to prevent the ODE solver from amplifying noise
kwargs['cfg_strength'] = 1.0

wave, sr, spec = original_infer_process(*args, **kwargs)

if isinstance(wave, torch.Tensor):
    wave = wave.squeeze().cpu().numpy()
    
if np.isnan(wave).any():
    wave = np.nan_to_num(wave)
    
max_amp = np.max(np.abs(wave))
if max_amp > 1.0 or max_amp == 0.0:
    if max_amp > 0:
        wave = (wave / max_amp) * 0.95 
        
# Force float32 to prevent Gradio wrapping
wave = wave.astype(np.float32)
    
return wave, sr, spec

utils_infer.infer_process = safe_infer_process

--- 8. LAUNCH ---

os.environ["CUDA_VISIBLE_DEVICES"] = "0"
os.environ["HF_HUB_OFFLINE"] = "1"
os.environ["PYTHONHTTPSVERIFY"] = "0"

if name == "main":
from f5_tts.infer.infer_gradio import main
print("\n" + "="*50)
print("RTX 6000 Ada: F5-TTS FINAL NOISE CURE")
print("Fix 1: pe_attn_head=1 applied (Time Alignment Restored)")
print("Fix 2: CFG forced to 1.0 (ODE Explosion Prevented)")
print("="*50 + "\n")
main()

Sign up or log in to comment