#!/usr/bin/env python3 # Prueba de clonacion con XTTS-v2. Clona la voz de ref/jarvis_ref.wav y sintetiza # unas frases de prueba en espanol. Mide el tiempo por frase (GPU vs CPU). import os, sys, time os.environ.setdefault("COQUI_TOS_AGREED", "1") # aceptar licencia CPML no interactivo DISPOSITIVO = sys.argv[1] if len(sys.argv) > 1 else "cuda" REF = os.path.join(os.path.dirname(__file__), "ref", "jarvis_ref.wav") SALIDA = os.path.join(os.path.dirname(__file__), "ref", "muestras") os.makedirs(SALIDA, exist_ok=True) FRASES = [ "Buenas noches, señor. Todo está listo.", "He encontrado tres ficheros que coinciden. ¿Cuál abro?", "El procesador está a sesenta y un grados y quedan cuarenta gigabytes de memoria.", ] print(f"cargando XTTS-v2 en {DISPOSITIVO}...", flush=True) t0 = time.time() import torch from TTS.api import TTS tts = TTS("tts_models/multilingual/multi-dataset/xtts_v2").to(DISPOSITIVO) print(f" modelo cargado en {time.time()-t0:.1f} s", flush=True) for i, frase in enumerate(FRASES, 1): t0 = time.time() dst = os.path.join(SALIDA, f"prueba_{DISPOSITIVO}_{i}.wav") tts.tts_to_file(text=frase, speaker_wav=REF, language="es", file_path=dst) dur = time.time() - t0 print(f" [{i}] {dur:5.1f} s -> {dst}", flush=True) print(f" «{frase}»", flush=True) print("listo.", flush=True)