
    ri                     z    S r SSKrSSKrSSKJr  SSKr\R                  " \5      rS\	4S jr
\S:X  a  \
" 5         gg)z~Patches a voice ONNX model with phoneme width alignment output.

Requires the onnx package to be installed (not onnxruntime).
    N)Setreturnc                    ^ [         R                  " 5       n U R                  SSS9  U R                  SSS9  U R                  SSS9  U R                  5       n[        R
                  " [        R                  S9  UR                  (       d  UR                  Ul        [        R                  " UR                  5      nUR                  (       a  UR                  mO[        5       nUR                  R                   H0  nUR                  S	:w  a  M  UR!                  UR                  5        M2     U(       d  ["        R%                  S
5        g['        U5      S:  a  ["        R%                  SU5        g[)        [+        U5      5      m["        R-                  ST5        [/        U4S jUR                  R                   5       5      (       a  ["        R%                  ST5        g[        R0                  R3                  5       nTUl        UR                  R                  R7                  U5        [        R8                  " X!R                  5        ["        R-                  SUR                  5        g)zMain entry point.modelzPath to ONNX voice model)helpz--outputz/Path to write output model (default: overwrite)z--tensor-namez6Name of tensor to mark as output (default: autodetect))levelCeilz5No ceil tensors detected. Use --tensor-name manually.   z>Multiple ceil tensors detected. Use --tensor-name manually: %szDetected tensor name: %sc              3   @   >#    U  H  oR                   T:H  v   M     g 7f)N)name).0outputceil_tensor_names     f/home/kim/smarthome/piper_models/venv/lib/python3.13/site-packages/piper/patch_voice_with_alignment.py	<genexpr>main.<locals>.<genexpr>:   s     
L9Kv;;**9Ks   z0Tensor is already marked as output. Aborting: %szSuccessfully wrote %sr   )argparseArgumentParseradd_argument
parse_argsloggingbasicConfigINFOr   r   onnxloadtensor_namesetgraphnodeop_typeupdate_LOGGERfatallennextiterinfoanyhelperValueInfoProtor   appendsave)parserargsr   ceil_tensor_namesr   ceil_value_infor   s         @r   mainr1      s   $$&F
&@A
J   V   Dgll+;;jjIIdjj!E++&)eKK$$D||v%$$T[[1	 % !MMQR !A%MMP! %6 78/1AB

L9K9K
LLL>@P	
 kk002O+O	KKo.IIe[[!LL($++6    __main__)__doc__r   r   typingr   r   	getLogger__name__r"   intr1    r2   r   <module>r:      sI   
    


H
%8c 8v zF r2   