Phase 1 Fix: min_frames=2, edge padding, clause chunking, speed=0.92
Browse files13 unmodified lines14151617181915 unmodified lines3536373839404142434445464748495051525354555657585913 unmodified linesfrom models.tts_engine import TTS10MEnginefrom data.text_cleaner import TextTokenizerfrom utils.checkpoint import load_checkpoint# Initialize Model on Startupcfg = TTS10MConfig()15 unmodified linestokenizer = TextTokenizer()def tts_generate(text: str, steps: int = 48, speed: float = 1.0, cfg_scale: float = 1.5, temperature: float = 0.667):text_ids = tokenizer.text_to_ids(text)if text_ids.numel() == 0:return None, "Please enter some valid text."start_t = time.perf_counter()text_ids_batch = text_ids.unsqueeze(0).to(device)with torch.no_grad():out = model.synthesize(text_ids_batch,num_steps=int(steps),speed=float(speed),cfg_scale=float(cfg_scale),temperature=float(temperature),sway_sampling_coef=cfg.model.sway_sampling_coef,return_waveform=True,)waveform = out["waveform"].squeeze(0).cpu().numpy()latency_ms = (time.perf_counter() - start_t) * 1000duration_s = waveform.shape[-1] / float(cfg.audio.sample_rate)13 unmodified lines1415161718192015 unmodified lines3637383940414243444546474849505152535455565758596013 unmodified linesfrom models.tts_engine import TTS10MEnginefrom data.text_cleaner import TextTokenizerfrom utils.checkpoint import load_checkpointfrom utils.long_form import synthesize_long_text# Initialize Model on Startupcfg = TTS10MConfig()15 unmodified linestokenizer = TextTokenizer()def tts_generate(text: str, steps: int = 48, speed: float = 0.92, cfg_scale: float = 1.5, temperature: float = 0.667):text_ids = tokenizer.text_to_ids(text)if text_ids.numel() == 0:return None, "Please enter some valid text."start_t = time.perf_counter()waveform = synthesize_long_text(model=model,tokenizer=tokenizer,text=text,device=torch.device(device),sample_rate=cfg.audio.sample_rate,num_steps=int(steps),speed=float(speed),cfg_scale=float(cfg_scale),temperature=float(temperature),sway_sampling_coef=cfg.model.sway_sampling_coef,min_frames=2,)latency_ms = (time.perf_counter() - start_t) * 1000duration_s = waveform.shape[-1] / float(cfg.audio.sample_rate)
app.py+15-14