import os import json import time import secrets import logging import warnings from pathlib import Path from typing import Tuple, Any from functools import partial logging.getLogger("huggingface_hub").setLevel(logging.ERROR) import gradio as gr import torch import torchaudio from inference import ( load_model_from_hf, load_fish_ae_from_hf, load_pca_state_from_hf, load_audio, ae_encode, ae_decode, ae_reconstruct, get_speaker_latent_and_mask, sample_pipeline, compile_model, compile_fish_ae, sample_euler_cfg_independent_guidances, sample_euler_cfg_vc, load_vc_model_from_hf ) # -------------------------------------------------------------------- # Configuration (CPU mode) MODEL_DTYPE = torch.float32 FISH_AE_DTYPE = torch.float32 DEFAULT_SAMPLE_LATENT_LENGTH = 640 # -------------------------------------------------------------------- # Audio Prompt Library for Custom Audio Panel (included in repo) AUDIO_PROMPT_FOLDER = Path("./audio_prompts") # -------------------------------------------------------------------- TEXT_PRESETS_PATH = Path("./text_presets.txt") SAMPLER_PRESETS_PATH = Path("./sampler_presets.json") TEMP_AUDIO_DIR = Path("./temp_gradio_audio") TEMP_AUDIO_DIR.mkdir(parents=True, exist_ok=True) # -------------------------------------------------------------------- # Model loading (eager for local use) model = load_model_from_hf(dtype=MODEL_DTYPE, delete_blockwise_modules=True, device="cpu") fish_ae = load_fish_ae_from_hf(dtype=FISH_AE_DTYPE, device="cpu") pca_state = load_pca_state_from_hf(device="cpu") model_compiled = None fish_ae_compiled = None # Full model with latent encoder for VC (loaded lazily on first VC use) _vc_model = None def _get_vc_model(): global _vc_model if _vc_model is None: print("Loading full VC model (with latent encoder)...") _vc_model = load_vc_model_from_hf(dtype=MODEL_DTYPE, device="cpu") return _vc_model # -------------------------------------------------------------------- # Helper functions def make_stem(prefix: str, user_id: str | None = None) -> str: """Create unique filename stem: prefix__user__timestamp_random or prefix__timestamp_random if no user_id.""" ts = int(time.time() * 1000) rand = secrets.token_hex(4) if user_id: return f"{prefix}__{user_id}__{ts}_{rand}" return f"{prefix}__{ts}_{rand}" def cleanup_temp_audio(dir_: Path, user_id: str | None, max_age_sec: int = 60 * 5): """Remove old files globally and all previous files for this user.""" now = time.time() for p in dir_.glob("*"): try: if p.is_file() and (now - p.stat().st_mtime) > max_age_sec: p.unlink(missing_ok=True) except Exception: pass if user_id: for p in dir_.glob(f"*__{user_id}__*"): try: if p.is_file(): p.unlink(missing_ok=True) except Exception: pass def save_audio_with_format(audio_tensor: torch.Tensor, base_path: Path, filename: str, sample_rate: int, audio_format: str) -> Path: """Save audio in specified format, fallback to WAV if MP3 encoding fails.""" if audio_format == "mp3": try: output_path = base_path / f"{filename}.mp3" torchaudio.save( str(output_path), audio_tensor, sample_rate, format="mp3", encoding="mp3", bits_per_sample=None, ) return output_path except Exception as e: print(f"MP3 encoding failed: {e}, falling back to WAV") output_path = base_path / f"{filename}.wav" torchaudio.save(str(output_path), audio_tensor, sample_rate) return output_path output_path = base_path / f"{filename}.wav" torchaudio.save(str(output_path), audio_tensor, sample_rate) return output_path def to_bool(val: Any) -> bool: """Parse truthy values from common string/bool inputs.""" return str(val).strip().lower() not in {"", "0", "false", "off", "none", "no"} def find_min_bucket_gte(values_str: str, actual_length: int) -> int | None: """Parse comma-separated values and find minimum value >= actual_length. If a single value is provided (no comma), returns that value directly. If comma-separated, finds the smallest bucket that can fit the content. Returns None if empty string. """ if not values_str or not values_str.strip(): return None values_str = values_str.strip() # Single value case - return as-is if "," not in values_str: return int(values_str) # Multiple values - find minimum >= actual_length values = [int(v.strip()) for v in values_str.split(",") if v.strip()] if not values: return None # Find minimum value >= actual_length candidates = [v for v in values if v >= actual_length] if candidates: return min(candidates) # If no value is >=, return the maximum (best effort) return max(values) def generate_audio( text_prompt: str, speaker_audio_path: str, num_steps: int, rng_seed: int, cfg_scale_text: float, cfg_scale_speaker: float, cfg_min_t: float, cfg_max_t: float, truncation_factor: float, rescale_k: float, rescale_sigma: float, force_speaker: bool, speaker_kv_scale: float, speaker_kv_min_t: float, speaker_kv_max_layers: int, reconstruct_first_30_seconds: bool, use_custom_shapes: bool, max_text_byte_length: str, max_speaker_latent_length: str, sample_latent_length: str, audio_format: str, use_compile: bool, show_original_audio: bool, session_id: str, ) -> Tuple[Any, Any, Any, Any, Any, Any, Any, Any, Any]: """Generate audio using the model.""" global model_compiled, fish_ae_compiled if use_compile: if model_compiled is None: try: model_compiled = compile_model(model) fish_ae_compiled = compile_fish_ae(fish_ae) except Exception as e: print(f"Compilation wrapping failed: {str(e)}") model_compiled = None fish_ae_compiled = None use_compile = False active_model = model_compiled if use_compile else model active_fish_ae = fish_ae_compiled if use_compile else fish_ae cleanup_temp_audio(TEMP_AUDIO_DIR, session_id) start_time = time.time() num_steps_int = min(max(int(num_steps), 1), 80) rng_seed_int = int(rng_seed) if rng_seed is not None else 0 cfg_scale_text_val = float(cfg_scale_text) cfg_scale_speaker_val = float(cfg_scale_speaker) if cfg_scale_speaker is not None else None cfg_min_t_val = float(cfg_min_t) cfg_max_t_val = float(cfg_max_t) truncation_factor_val = float(truncation_factor) rescale_k_val = float(rescale_k) if rescale_k != 1.0 else None rescale_sigma_val = float(rescale_sigma) speaker_kv_enabled = bool(force_speaker) if speaker_kv_enabled: speaker_kv_scale_val = float(speaker_kv_scale) if speaker_kv_scale is not None else None speaker_kv_min_t_val = float(speaker_kv_min_t) if speaker_kv_min_t is not None else None speaker_kv_max_layers_val = int(speaker_kv_max_layers) if speaker_kv_max_layers is not None else None else: speaker_kv_scale_val = None speaker_kv_min_t_val = None speaker_kv_max_layers_val = None # Load speaker audio early so we can compute actual lengths for bucket selection use_zero_speaker = not speaker_audio_path or speaker_audio_path == "" speaker_audio = load_audio(speaker_audio_path).cpu() if not use_zero_speaker else None if use_custom_shapes: # Compute actual text byte length actual_text_byte_length = len(text_prompt.encode("utf-8")) + 1 # +1 for BOS token # Compute actual speaker latent length (audio_samples // 2048) AE_DOWNSAMPLE_FACTOR = 2048 if speaker_audio is not None: actual_speaker_latent_length = (speaker_audio.shape[-1] // AE_DOWNSAMPLE_FACTOR) // 4 * 4 else: actual_speaker_latent_length = 0 # Find appropriate bucket sizes from comma-separated values pad_to_max_text_length = find_min_bucket_gte(max_text_byte_length, actual_text_byte_length) pad_to_max_speaker_latent_length = find_min_bucket_gte(max_speaker_latent_length, actual_speaker_latent_length) sample_latent_length_val = int(sample_latent_length) if sample_latent_length.strip() else (DEFAULT_SAMPLE_LATENT_LENGTH or 640) else: pad_to_max_text_length = None pad_to_max_speaker_latent_length = None sample_latent_length_val = DEFAULT_SAMPLE_LATENT_LENGTH or 640 sample_fn = partial( sample_euler_cfg_independent_guidances, num_steps=num_steps_int, cfg_scale_text=cfg_scale_text_val, cfg_scale_speaker=cfg_scale_speaker_val, cfg_min_t=cfg_min_t_val, cfg_max_t=cfg_max_t_val, truncation_factor=truncation_factor_val, rescale_k=rescale_k_val, rescale_sigma=rescale_sigma_val, speaker_kv_scale=speaker_kv_scale_val, speaker_kv_min_t=speaker_kv_min_t_val, speaker_kv_max_layers=speaker_kv_max_layers_val, sequence_length=sample_latent_length_val, ) audio_out, normalized_text = sample_pipeline( model=active_model, fish_ae=active_fish_ae, pca_state=pca_state, sample_fn=sample_fn, text_prompt=text_prompt, speaker_audio=speaker_audio, rng_seed=rng_seed_int, pad_to_max_text_length=pad_to_max_text_length, pad_to_max_speaker_latent_length=pad_to_max_speaker_latent_length, normalize_text=True, ) audio_to_save = audio_out[0].cpu() stem = make_stem("generated", session_id) output_path = save_audio_with_format(audio_to_save, TEMP_AUDIO_DIR, stem, 44100, audio_format) generation_time = time.time() - start_time time_str = f"⏱️ Total generation time: {generation_time:.2f}s" text_display = f"**Text Prompt (normalized):**\n\n{normalized_text}" recon_output_path = None original_output_path = None if reconstruct_first_30_seconds and speaker_audio is not None: audio_recon = ae_reconstruct( fish_ae=fish_ae, pca_state=pca_state, audio=torch.nn.functional.pad( speaker_audio[..., :2048 * 640], (0, max(0, 2048 * 640 - speaker_audio.shape[-1])), )[None], )[..., : speaker_audio.shape[-1]] recon_stem = make_stem("speaker_recon", session_id) recon_output_path = save_audio_with_format(audio_recon.cpu()[0], TEMP_AUDIO_DIR, recon_stem, 44100, audio_format) if show_original_audio and speaker_audio is not None: original_stem = make_stem("original_audio", session_id) original_output_path = save_audio_with_format(speaker_audio.cpu(), TEMP_AUDIO_DIR, original_stem, 44100, audio_format) show_reference_section = (show_original_audio or reconstruct_first_30_seconds) and speaker_audio is not None return ( gr.update(), gr.update(value=str(output_path), visible=True), gr.update(value=text_display, visible=True), gr.update(value=str(original_output_path) if original_output_path else None, visible=True), gr.update(value=time_str, visible=True), gr.update(value=str(recon_output_path) if recon_output_path else None, visible=True), gr.update(visible=(show_original_audio and speaker_audio is not None)), gr.update(visible=(reconstruct_first_30_seconds and speaker_audio is not None)), gr.update(visible=show_reference_section), ) # UI Helper Functions def load_text_presets(): """Load text presets from file with category and word count.""" if TEXT_PRESETS_PATH.exists(): with open(TEXT_PRESETS_PATH, "r", encoding="utf-8") as f: lines = [line.strip() for line in f if line.strip()] result = [] for line in lines: if " | " in line: parts = line.split(" | ", 1) category = parts[0] text = parts[1] else: category = "Uncategorized" text = line word_count = len(text.split()) result.append([category, str(word_count), text]) return result return [] def select_text_preset(evt: gr.SelectData): """Handle text preset selection - extract text from the row.""" if evt.value: if isinstance(evt.index, (tuple, list)) and len(evt.index) >= 2: row_index = evt.index[0] else: row_index = evt.index presets_data = load_text_presets() if isinstance(row_index, int) and row_index < len(presets_data): text = presets_data[row_index][2] return gr.update(value=text) return gr.update() def toggle_mode(mode): """Toggle advanced settings section visibility.""" show_advanced = mode == "Advanced Mode" return gr.update(visible=show_advanced) def update_force_row(force_speaker): """Show KV scaling controls when Force Speaker is enabled.""" return gr.update(visible=bool(force_speaker)) def apply_cfg_preset(preset_name): """Apply CFG guidance preset.""" presets = { "higher speaker": (3.0, 8.0, 0.5, 1.0), "large guidances": (8.0, 8.0, 0.5, 1.0), } if preset_name not in presets: return [gr.update()] * 5 text_scale, speaker_scale, min_t, max_t = presets[preset_name] return [ gr.update(value=text_scale), gr.update(value=speaker_scale), gr.update(value=min_t), gr.update(value=max_t), gr.update(value="Custom"), ] def apply_speaker_kv_preset(preset_name): """Apply speaker KV attention control preset.""" if preset_name == "enable": return [ gr.update(value=True), gr.update(visible=True), gr.update(value="Custom"), ] if preset_name == "off": return [ gr.update(value=False), gr.update(visible=False), gr.update(value="Custom"), ] return [gr.update()] * 3 def apply_truncation_preset(preset_name): """Apply truncation & temporal rescaling preset.""" presets = { "flat": (0.8, 1.2, 3.0), "sharp": (0.9, 0.96, 3.0), "baseline(sharp)": (1.0, 1.0, 3.0), } if preset_name == "custom" or preset_name not in presets: return [gr.update()] * 4 truncation, rescale_k, rescale_sigma = presets[preset_name] return [ gr.update(value=truncation), gr.update(value=rescale_k), gr.update(value=rescale_sigma), gr.update(value="Custom"), ] def load_sampler_presets(): """Load sampler presets from JSON file.""" if SAMPLER_PRESETS_PATH.exists(): with open(SAMPLER_PRESETS_PATH, "r") as f: return json.load(f) default_presets = { "Independent-High-Speaker-CFG": { "num_steps": "40", "cfg_scale_text": "3.0", "cfg_scale_speaker": "8.0", "cfg_min_t": "0.5", "cfg_max_t": "1.0", "truncation_factor": "1.", "rescale_k": "1.", "rescale_sigma": "3.0" } } with open(SAMPLER_PRESETS_PATH, "w") as f: json.dump(default_presets, f, indent=2) return default_presets def apply_sampler_preset(preset_name): """Apply a sampler preset to all fields.""" presets = load_sampler_presets() if preset_name == "Custom" or preset_name not in presets: return [gr.update()] * 13 preset = presets[preset_name] speaker_kv_enabled = to_bool(preset.get("speaker_kv_enable", False)) def to_num(val, default): try: return float(val) if isinstance(val, str) else val except (ValueError, TypeError): return default return [ gr.update(value=int(to_num(preset.get("num_steps", "40"), 40))), gr.update(value=to_num(preset.get("cfg_scale_text", "3.0"), 3.0)), gr.update(value=to_num(preset.get("cfg_scale_speaker", "5.0"), 5.0)), gr.update(value=to_num(preset.get("cfg_min_t", "0.5"), 0.5)), gr.update(value=to_num(preset.get("cfg_max_t", "1.0"), 1.0)), gr.update(value=to_num(preset.get("truncation_factor", "0.8"), 0.8)), gr.update(value=to_num(preset.get("rescale_k", "1.2"), 1.2)), gr.update(value=to_num(preset.get("rescale_sigma", "3.0"), 3.0)), gr.update(value=speaker_kv_enabled), gr.update(visible=speaker_kv_enabled), gr.update(value=to_num(preset.get("speaker_kv_scale", "1.5"), 1.5)), gr.update(value=to_num(preset.get("speaker_kv_min_t", "0.9"), 0.9)), gr.update(value=int(to_num(preset.get("speaker_kv_max_layers", "24"), 24))), ] AUDIO_EXTS = {".wav", ".mp3", ".m4a", ".ogg", ".flac", ".webm", ".aac", ".opus"} def get_audio_prompt_files(search_query: str = ""): """Get list of audio files from the audio prompt folder, optionally filtered by search query.""" if AUDIO_PROMPT_FOLDER is None or not AUDIO_PROMPT_FOLDER.exists(): return [] files = sorted([f.name for f in AUDIO_PROMPT_FOLDER.iterdir() if f.is_file() and f.suffix.lower() in AUDIO_EXTS], key=str.lower) # Filter by search query if provided if search_query.strip(): query_lower = search_query.lower() files = [f for f in files if query_lower in f.lower()] return [[file] for file in files] def filter_audio_prompts(search_query: str): """Filter audio prompts based on search query.""" return gr.update(value=get_audio_prompt_files(search_query)) def select_audio_prompt_file(evt: gr.SelectData): """Handle audio prompt file selection from table.""" if evt.value and AUDIO_PROMPT_FOLDER is not None: file_path = AUDIO_PROMPT_FOLDER / evt.value if file_path.exists(): return gr.update(value=str(file_path)) return gr.update() # UI styling and helpers LINK_CSS = """ .preset-inline { display:flex; align-items:baseline; gap:6px; margin-top:-4px; margin-bottom:-12px; } .preset-inline .title { font-weight:600; font-size:.95rem; } .preset-inline .dim { color:#666; margin:0 4px; } a.preset-link { color: #0a5bd8; text-decoration: underline; cursor: pointer; font-weight: 400; } a.preset-link:hover { text-decoration: none; opacity: 0.8; } .dark a.preset-link, [data-theme="dark"] a.preset-link { color: #60a5fa !important; } .dark a.preset-link:hover, [data-theme="dark"] a.preset-link:hover { color: #93c5fd !important; } .dark .preset-inline .dim, [data-theme="dark"] .preset-inline .dim { color: #9ca3af !important; } .proxy-btn { position:absolute; width:0; height:0; overflow:hidden; padding:0 !important; margin:0 !important; border:0 !important; opacity:0; pointer-events:none; } .gr-group { border: 1px solid #d1d5db !important; background: #f3f4f6 !important; } .dark .gr-group, [data-theme="dark"] .gr-group { border: 1px solid #4b5563 !important; background: #1f2937 !important; } .generated-audio-player { border: 3px solid #667eea !important; border-radius: 12px !important; padding: 20px !important; background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.05) 100%) !important; box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2) !important; margin: 1rem 0 !important; } .generated-audio-player > div { background: transparent !important; } #component-mode-selector { text-align: center; padding: 1rem 0; } #component-mode-selector label { font-size: 1.1rem !important; font-weight: 600 !important; margin-bottom: 0.5rem !important; } #component-mode-selector .wrap { justify-content: center !important; } #component-mode-selector fieldset { border: 2px solid #e5e7eb !important; border-radius: 8px !important; padding: 1rem !important; background: #f9fafb !important; } .dark #component-mode-selector fieldset, [data-theme="dark"] #component-mode-selector fieldset { border: 2px solid #4b5563 !important; background: #1f2937 !important; } .section-separator { height: 3px !important; background: linear-gradient(90deg, transparent 0%, #667eea 20%, #764ba2 80%, transparent 100%) !important; border: none !important; margin: 2rem 0 !important; } .dark .section-separator, [data-theme="dark"] .section-separator { background: linear-gradient(90deg, transparent 0%, #667eea 20%, #764ba2 80%, transparent 100%) !important; } .gradio-container h1, .gradio-container h2 { font-weight: 700 !important; margin-top: 1.5rem !important; margin-bottom: 1rem !important; } .tip-box { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important; border-left: 4px solid #f59e0b !important; border-radius: 8px !important; padding: 1rem 1.5rem !important; margin: 1rem 0 !important; box-shadow: 0 2px 4px rgba(245, 158, 11, 0.1) !important; } .tip-box strong { color: #92400e !important; } .dark .tip-box, [data-theme="dark"] .tip-box { background: linear-gradient(135deg, #451a03 0%, #78350f 100%) !important; border-left: 4px solid #f59e0b !important; } .dark .tip-box strong, [data-theme="dark"] .tip-box strong { color: #fbbf24 !important; } """ JS_CODE = r""" function () { const appEl = document.querySelector("gradio-app"); const root = appEl && appEl.shadowRoot ? appEl.shadowRoot : document; function clickHiddenButtonById(id) { if (!id) return; const host = root.getElementById(id); if (!host) return; const realBtn = host.querySelector("button, [role='button']") || host; realBtn.click(); } root.addEventListener("click", (ev) => { const a = ev.target.closest("a.preset-link"); if (!a) return; ev.preventDefault(); ev.stopPropagation(); ev.stopImmediatePropagation(); clickHiddenButtonById(a.getAttribute("data-fire")); return false; }, true); } """ def init_session(): """Initialize session ID for this browser tab/session.""" return secrets.token_hex(8) # Whisper model (loaded lazily on first VC use) _whisper_model = None def _get_whisper(): global _whisper_model if _whisper_model is None: try: import whisper _whisper_model = whisper.load_model("base", device="cpu") except Exception as e: raise gr.Error(f"Could not load Whisper: {e}. Install it with: pip install openai-whisper") return _whisper_model def transcribe_source_audio(source_audio_path: str) -> str: """Auto-transcribe source audio using Whisper.""" if not source_audio_path: return "" try: whisper_model = _get_whisper() result = whisper_model.transcribe(source_audio_path, fp16=False) return result["text"].strip() except Exception as e: raise gr.Error(f"Transcription failed: {e}") def _source_duration_to_latent_length(source_audio_path: str) -> int: """Compute sequence_length from source audio duration to match rhythm.""" AE_DOWNSAMPLE_FACTOR = 2048 SAMPLE_RATE = 44_100 try: from torchcodec.decoders import AudioDecoder decoder = AudioDecoder(source_audio_path) sr = decoder.metadata.sample_rate num_frames = decoder.metadata.num_frames duration_samples_at_44k = int(num_frames / sr * SAMPLE_RATE) except Exception: return DEFAULT_SAMPLE_LATENT_LENGTH latent_len = duration_samples_at_44k // AE_DOWNSAMPLE_FACTOR # Round to multiple of 4 (patch size), clamp to [64, 640] latent_len = max(64, min(640, (latent_len // 4) * 4)) return latent_len def generate_voice_conversion( source_audio_path: str, target_speaker_path: str, transcript: str, num_steps: int, rng_seed: int, cfg_scale_text: float, cfg_scale_speaker: float, cfg_min_t: float, cfg_max_t: float, truncation_factor: float, audio_format: str, session_id: str, ) -> Tuple[Any, Any, Any]: """Voice conversion: encode source audio latent, condition diffusion on it alongside target speaker to re-speak content in the target voice.""" cleanup_temp_audio(TEMP_AUDIO_DIR, session_id) start_time = time.time() if not source_audio_path: raise gr.Error("Please provide source audio to convert.") if not transcript or not transcript.strip(): raise gr.Error("Please provide a transcript (or use Auto-Transcribe).") sequence_length = _source_duration_to_latent_length(source_audio_path) # Encode source audio into AE latent space source_audio_raw = load_audio(source_audio_path).cpu() n_samples = sequence_length * 2048 src_padded = torch.nn.functional.pad( source_audio_raw, (0, max(0, n_samples - source_audio_raw.shape[-1])) )[:, :n_samples] source_latent = ae_encode( fish_ae, pca_state, src_padded.unsqueeze(0).to(fish_ae.dtype) ) # (1, sequence_length, 80) target_audio = load_audio(target_speaker_path).cpu() if target_speaker_path else None # Use the full model (with latent encoder) for VC vc_model = _get_vc_model() num_steps_int = min(max(int(num_steps), 1), 80) sample_fn = partial( sample_euler_cfg_vc, num_steps=num_steps_int, cfg_scale_text=float(cfg_scale_text), cfg_scale_speaker=float(cfg_scale_speaker) if cfg_scale_speaker is not None else None, cfg_min_t=float(cfg_min_t), cfg_max_t=float(cfg_max_t), truncation_factor=float(truncation_factor), rescale_k=None, rescale_sigma=3.0, speaker_kv_scale=None, speaker_kv_min_t=None, speaker_kv_max_layers=None, sequence_length=sequence_length, source_latent=source_latent, ) audio_out, normalized_text = sample_pipeline( model=vc_model, fish_ae=fish_ae, pca_state=pca_state, sample_fn=sample_fn, text_prompt=transcript, speaker_audio=target_audio, rng_seed=int(rng_seed) if rng_seed is not None else 0, normalize_text=True, ) audio_to_save = audio_out[0].cpu() stem = make_stem("vc_output", session_id) output_path = save_audio_with_format(audio_to_save, TEMP_AUDIO_DIR, stem, 44100, audio_format) generation_time = time.time() - start_time time_str = f"\u23f1\ufe0f {generation_time:.2f}s | latent={sequence_length} (~{sequence_length * 2048 / 44100:.1f}s)" text_display = f"**Transcript (normalized):**\n\n{normalized_text}" return ( gr.update(value=str(output_path), visible=True), gr.update(value=time_str, visible=True), gr.update(value=text_display, visible=True), ) with gr.Blocks(title="Echo-TTS", css=LINK_CSS, js=JS_CODE) as demo: gr.Markdown("# Echo-TTS") gr.Markdown("*Jordan Darefsky, 2025. See technical details [here](https://jordandarefsky.com/blog/2025/echo/)*") gr.Markdown("**License Notice:** All audio outputs are subject to non-commercial use [CC-BY-NC-SA-4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/).") gr.Markdown("**Responsible Use:** Do not use this model to impersonate real people without their explicit consent or to generate deceptive audio.") with gr.Accordion("📖 Quick Start Instructions", open=True): gr.Markdown( """ 1. Upload or record a short reference clip (or leave blank for no speaker reference). 2. Pick a text preset or type your own prompt. 3. Click **Generate Audio**.