Phase 1 Fix: min_frames=2, edge padding, clause chunking, speed=0.92
Browse files11 unmodified lines1213141516171835 unmodified lines5455565657575960616263646566676869705859606162636465666768697071727374737576773 unmodified lines818283838485866 unmodified lines939495969697989911 unmodified linesfrom data.text_cleaner import TextTokenizerfrom utils.checkpoint import load_checkpointfrom utils.audio_sanity import AudioSanityGuardian, save_audiofrom utils.long_form import synthesize_long_textfrom config import TTS10MConfig
35 unmodified lines print("Note: Running with initialized weights (specify --checkpoint path/to/model.safetensors for trained audio).")
model.eval() text_ids_batch = text_ids.unsqueeze(0).to(target_device)
start_t = time.perf_counter() with torch.no_grad(): out = model.synthesize( text_ids_batch, num_steps=steps, speed=speed, cfg_scale=guidance, temperature=temp, sway_sampling_coef=sway, return_waveform=True, ) waveform = out["waveform"].squeeze(0).cpu() mel = out["mel"].squeeze(0)
wav_np = synthesize_long_text( model=model, tokenizer=tokenizer, text=text, device=target_device, sample_rate=cfg.audio.sample_rate, num_steps=steps, speed=speed, cfg_scale=guidance, temperature=temp, sway_sampling_coef=sway, min_frames=2, ) waveform = torch.from_numpy(wav_np) latency_ms = (time.perf_counter() - start_t) * 1000
_, mel_msg = AudioSanityGuardian.check_spectrogram(mel) _, audio_msg = AudioSanityGuardian.check_audio_waveform(waveform, cfg.audio.sample_rate)
duration_s = waveform.shape[-1] / float(cfg.audio.sample_rate)3 unmodified lines print(f" Latency: {latency_ms:.1f} ms") print(f" Audio Duration: {duration_s:.2f} s") print(f" Real-Time Factor (RTF): {rtf:.3f}x (< 1.0x means faster than real-time!)") print(f" Mel Health: {mel_msg}") print(f" Audio Health: {audio_msg}")
save_audio(output_wav, waveform, cfg.audio.sample_rate)6 unmodified lines parser.add_argument("--checkpoint", type=str, default=None, help="Path to .safetensors checkpoint") parser.add_argument("--output", type=str, default="output.wav", help="Path to save output .wav file") parser.add_argument("--steps", type=int, default=48, help="Number of ODE steps (16-48 recommended)") parser.add_argument("--speed", type=float, default=1.0, help="Speech rate / speed multiplier") parser.add_argument("--speed", type=float, default=0.92, help="Speech rate / speed multiplier (0.92 prevents syllable drop)") parser.add_argument("--cfg_scale", type=float, default=1.5, help="Classifier-Free Guidance scale (1.0=off, 1.5=recommended)") parser.add_argument("--temperature", type=float, default=0.667, help="Prior noise temperature (0.5-0.7 reduces background hiss)") parser.add_argument("--sway", type=float, default=-1.0, help="Sway sampling coefficient (-1.0=F5-TTS default, 0.0=uniform)")infer.py+17-17