
    Nj                        d Z ddlmZ ddlZddlmZ ddlZdZ ee	      j                         j                  j                  dz  Z G d d      Zy)	u  Local text-to-speech: Kokoro-82M via ONNX (24 kHz, fully on-device).

kokoro-onnx was chosen over the MLX build after the MLX Kokoro hit a
shape bug (mlx-audio istftnet broadcast error, July 2026); same model,
same voices, ~300ms per sentence warm on an M4.

Voice via VOICE=<name>; default bm_george (British male — the Jarvis
voice). Others: bm_lewis (British male), af_heart/af_sarah (US female),
am_adam/am_michael (US male), bf_emma (British female). See
hexgrad/Kokoro-82M VOICES.md. Speed via VOICE_SPEED (default 1.0).
    )annotationsN)Pathi]  modelsc                      e Zd ZddZddZy)	KokoroTTSc                4   ddl m}  |t        t        dz        t        t        dz              | _        t
        j                  j                  dd      | _        t        t
        j                  j                  dd            | _
        | j                  d	       y )
Nr   )Kokorozkokoro-v1.0.onnxzvoices-v1.0.binVOICE	bm_georgeVOICE_SPEEDz1.0zWarm up.)kokoro_onnxr	   str_MODELS_DIR_kokoroosenvironget_voicefloat_speedsynth)selfr	   s     7/Users/ahmed/devFolder/Ultron/claude-voice/voice/tts.py__init__zKokoroTTS.__init__   sl    &001//0
 jjnnWk:BJJNN=%@A

:    c                    | j                   j                  || j                  | j                  d      \  }}|t        k(  s
J d|        t        j                  |t
        j                        S )z"text -> float32 mono PCM @ 24 kHz.zen-us)voicespeedlangzunexpected kokoro sample rate )dtype)r   creater   r   SAMPLE_RATEnpasarrayfloat32)r   textsamplessrs       r   r   zKokoroTTS.synth%   sb    ll))4;;W * 
 [ G$B2$"GG zz'44r   N)returnNone)r&   r   r)   z
np.ndarray)__name__
__module____qualname__r   r    r   r   r   r      s    	5r   r   )__doc__
__future__r   r   pathlibr   numpyr#   r"   __file__resolveparentr   r   r.   r   r   <module>r6      sJ   
 # 	  8n$$&--44x?5 5r   