+
    &j'                         ^ RI t ^ RIt^ RIt^ RIHtHtHtHt RR R lltR R lt	 ! R R4      t
 ! R	 R
]
4      t ! R R]
4      t ! R R]4      t ! R R]4      t ! R R]
4      t ! R R]
4      tR R ltR# )    N)CallableListOptionalTextIOc                <    V ^8  d   QhR\         R\        R\        /# )   secondsalways_include_hoursdecimal_marker)floatboolstr)formats   "k/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/mlx_whisper/writers.py__annotate__r   	   s$      *.HK    c                     V ^ 8  g   Q R4       h\        V R,          4      pVR,          pW4R,          ,          pVR,          pW5R,          ,          pVR,          p W0R,          ,          pV'       g   V^ 8  d   VR R2MRpV VR RV R V VR	 2# )
r   znon-negative timestamp expectedg     @@i6 i`    02d: 03d)round)r	   r
   r   millisecondshoursminuteshours_markers   &&&    r   format_timestampr   	   s     a<:::<6)*LI%EI%%Lf$Gf$$Le#GeO#L&:eaieC[?RL.QwsmN3CLQTCUVr   c                \    V ^8  d   QhR\         \        ,          R\        \        ,          /# )r   segmentsreturn)r   dictr   r   )r   s   "r   r   r      s"      T
 x r   c                 `    \        R  V  4       V '       d   V ^ ,          R,          4      # R4      # )c              3   P   "   T F  qR ,           F  q"R,          x  K  	  K  	  R# 5i)wordsstartN ).0sws   &  r   	<genexpr>get_start.<locals>.<genexpr>    s      :Xzz!7zXs   $&r&   N)next)r    s   &r   	get_startr.      s2    :X: (G .2 r   c                   j   a  ] tR t^%t o V 3R lR ltR
V 3R lR lltR
V 3R lR lltV 3R ltR	tV t	R# )ResultWriterc                    < V ^8  d   QhRS[ /# )r   
output_dirr   )r   __classdict__s   "r   r   ResultWriter.__annotate__(   s     % %3 %r   c                    Wn         R # Nr2   )selfr2   s   &&r   __init__ResultWriter.__init__(   s    $r   Nc                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# )r   resultoutput_nameoptions)r"   r   r   )r   r4   s   "r   r   r5   +   s.     I II),I7?~Ir   c           	     *   \         P                  ! V P                  4      V,          P                  R V P                   24      pVP                  RRR7      ;_uu_ 4       pV P                  ! V3RVRV/VB  RRR4       R#   + '       g   i     R# ; i).wtzutf-8)encodingfiler?   N)pathlibPathr2   with_suffix	extensionopenwrite_result)r9   r=   r>   r?   kwargsoutput_pathfs   &&&&,  r   __call__ResultWriter.__call__+   s{     ||DOO4{BOO 
 dW55fH1HgHH 6555s   BB	c                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# r   r=   rD   r?   r"   r   r   )r   r4   s   "r   r   r5   5   s)     " """("3;D>"r   c                    \         hr7   )NotImplementedErrorr9   r=   rD   r?   rK   s   &&&&,r   rJ   ResultWriter.write_result5   s
     "!r   c                &   < V ^8  d   Qh/ S[ ;R&   # r   rH   r3   )r   r4   s   "r   r   r5   %   s     N r   r8   r7   )
__name__
__module____qualname____firstlineno__r:   rN   rJ   __annotate_func____static_attributes____classdictcell__r4   s   @r   r0   r0   %   s,     % %I I" "!  r   r0   c                   F   a  ] tR t^;t o RtRV 3R lR lltV 3R ltRtV tR# )WriteTXTtxtNc                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# rQ   rR   )r   r4   s   "r   r   WriteTXT.__annotate__>   s.     B BB"(B3;D>Br   c                l    VR ,           F&  p\        VR,          P                  4       VRR7       K(  	  R# )r    textTrD   flushN)printstripr9   r=   rD   r?   rK   segments   &&&&, r   rJ   WriteTXT.write_result>   s/     j))G'&/'')DA *r   c                &   < V ^8  d   Qh/ S[ ;R&   # rX   r3   )r   r4   s   "r   r   re   ;   s      r   r'   r7   	rY   rZ   r[   r\   rH   rJ   r]   r^   r_   r`   s   @r   rb   rb   ;   s     IB B  r   rb   c            	       h   a  ] tR t^Et o RRRRRRRRR/V 3R lR llltV 3R	 lR
 ltV 3R ltRtV tR# )SubtitlesWriterNmax_line_widthmax_line_counthighlight_wordsFmax_words_per_linec                ~   < V ^8  d   QhRS[ RS[S[ ,          RS[S[,          RS[S[,          RS[RS[S[,          /# )r   r=   r?   rs   rt   ru   rv   )r"   r   intr   )r   r4   s   "r   r   SubtitlesWriter.__annotate__I   s_     i? i?i? $i?
 !i? !i? i? %SMi?r   c             #  X  aaaaa"   T;'       g    / pS;'       g    VP                  R 4      oS;'       g    VP                  R4      oT;'       g    VP                  RR4      pS;'       g    VP                  R4      oSRJ ;'       g    SRJ oS;'       g    RoS;'       g    RoVVVVV3R lp\        SR,          4      ^ 8  Ed`   R	SR,          ^ ,          9   EdJ   V! 4        EF;  pV P                  V^ ,          R
,          4      p	V P                  VR,          R,          4      p
RP                  V Uu. uF  qR,          NK  	  up4      pV'       d   T	pV Uu. uF  qR,          NK  	  pp\	        V4       F  w  ppV P                  VR
,          4      pV P                  VR,          4      pVV8w  d   VVV3x  TTRP                  \	        V4       UUu. uF'  w  ppVV8X  d   \
        P                  ! RRV4      MTNK)  	  upp4      3x  TpK  	  EK5  WV3x  EK>  	  R# SR,           Fa  pV P                  VR
,          4      pV P                  VR,          4      pVR,          P                  4       P                  RR4      pVVV3x  Kc  	  R# u upi u upi u uppi 5i)rs   rt   ru   Frv   Nr   c               3   \  <"   ^ p ^p. p\        SR,          4      ;'       g    RpSR,           EF  p^ pSpV\        VR,          4      8  g   K!  \        VR,          4      V,
          pS\        VR,          4      V,
          8  d   Tp\        VR,          WUV,            4       EF]  w  rV	P                  4       p
S'       * ;'       d    V
R,          V,
          R8  pV \        V
R,          4      ,           S8*  pV^ 8H  ;'       d    \        V4      ^ 8  ;'       d    SpV ^ 8  d3   V'       d+   V'       g#   V'       g   V \        V
R,          4      ,          p MV
R,          P	                  4       V
R&   \        V4      ^ 8  d   Se   V'       g   VS8  g	   V'       d
   Vx  . p^pM#V ^ 8  d   V^,          pRV
R,          ,           V
R&   \        V
R,          P	                  4       4      p VP                  V
4       V
R,          pEK`  	  VS,          pEK  	  \        V4      ^ 8  d   Vx  R# R# 5i)	r   r    g        r%   r&   g      @wordN
)r.   len	enumeratecopyrk   append)line_len
line_countsubtitlelastrm   chunk_indexwords_countremaining_wordsioriginal_timingtiming
long_pausehas_room	seg_breakrt   rs   rv   preserve_segmentsr=   s                 r   iterate_subtitles9SubtitlesWriter.iterate_result.<locals>.iterate_subtitles\   s     HJ#%H#F:$67>>3D!*--0!C(8$99&)''*:&;k&IO)C0@,AK,OO&5.7([7PQ/* "1!5!5!7 11RRfWo6Ls6R # $,c&..A#A^#S$%F$V$Vs8}q/@$V$VEV	$qL ($.$- %F6N(;;H .4F^-A-A-CF6N #H 1$2$>%/:3O#, '/+--.
!)A *a
15v1Fv'*6&>+?+?+A'BH /%gI/J  #55KY .Z 8}q  !s?   AH,A7H,;H,H,H,,H,4H,<AH,H,BH,r    r%   r&   endr   r|   z^(\s*)(.*)$z\1<u>\2</u>rg   z-->z->)	getr~   r   joinr   resubrk   replace)r9   r=   r?   rs   rt   ru   rv   r   r   subtitle_startsubtitle_endr|   subtitle_textr   r   	all_wordsr   	this_wordr&   r   jrm   segment_startsegment_endsegment_textr   s   &f&dd$d                  @r   iterate_resultSubtitlesWriter.iterate_resultI   s     --R'HH7;;7G+H'HH7;;7G+H)RRW[[9JE-R/TT7;;?S3T*d2LLn6L'//4/7744	 4	l vj!"Q&7fZ6H6K+K-/!%!6!6x{77K!L#44Xb\%5HI "((K($f((K L")D>F GhFhI G(1((;9 $ 5 5i6H I"33Ie4DE5="&}"<<#S"'' 09/C 0DGAt ()Av %'FF>>4$P)-%. 0D	+ 	 	  #! )<$ )EE3 06 "*-- $ 5 5gg6F G"33GENC&v446>>udK#[,>>	 .1 )L !HsZ   J*J*J*J*/J*J*J*&BJ*9J

J*J*J0A,J*-J$	B!J*c                    < V ^8  d   QhRS[ /# )r   r	   )r   )r   r4   s   "r   r   ry      s     
 
 
r   c                F    \        VV P                  V P                  R 7      # ))r	   r
   r   )r   r
   r   )r9   r	   s   &&r   r    SubtitlesWriter.format_timestamp   s$    !%!:!:..
 	
r   c                2   < V ^8  d   Qh/ S[ ;R&   S[;R&   # )r   r
   r   )r   r   )r   r4   s   "r   r   ry   E   s       r   r'   r7   )	rY   rZ   r[   r\   r   r   r]   r^   r_   r`   s   @r   rr   rr   E   sP     i?
 )-i? )-i? !&i? -1i? i?V
 
_  r   rr   c                   N   a  ] tR t^t o RtRtRtR	V 3R lR lltV 3R ltRt	V t
R# )
WriteVTTvttFrA   Nc                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# rQ   rR   )r   r4   s   "r   r   WriteVTT.__annotate__   s.     I II"(I3;D>Ir   c           	         \        R VR7       V P                  ! W3/ VB  F  w  rVp\        V RV RV R2VRR7       K  	  R# )zWEBVTT
)rD    --> r}   Trh   N)rj   r   )r9   r=   rD   r?   rK   r&   r   rg   s   &&&&,   r   rJ   WriteVTT.write_result   sM     	jt$ $ 3 3F Nv NEUG5RvR0t4H !Or   c                >   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[ ;R&   # r   rH   r
   r   r   r   )r   r4   s   "r   r   r      s(      &   r   r'   r7   rY   rZ   r[   r\   rH   r
   r   rJ   r]   r^   r_   r`   s   @r   r   r      s(     I!&NI I  r   r   c                   N   a  ] tR t^t o RtRtRtR	V 3R lR lltV 3R ltRt	V t
R# )
WriteSRTsrtT,Nc                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# rQ   rR   )r   r4   s   "r   r   WriteSRT.__annotate__   s.     N NN"(N3;D>Nr   c                    \        V P                  ! W3/ VB ^R7       F#  w  pw  rgp\        V RV RV RV R2VRR7       K%  	  R# )   )r&   r}   r   Trh   N)r   r   rj   )	r9   r=   rD   r?   rK   r   r&   r   rg   s	   &&&&,    r   rJ   WriteSRT.write_result   sY     &/:6:!&
!A!D QCr%cU"TF"5DM&
r   c                >   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[ ;R&   # r   r   )r   r4   s   "r   r   r      s(      %   r   r'   r7   r   r`   s   @r   r   r      s(     I!%NN N  r   r   c                   J   a  ] tR t^t o RtRtRV 3R lR lltV 3R ltRtV t	R# )	WriteTSVa  
Write a transcript to a file in TSV (tab-separated values) format containing lines like:
<start time in integer milliseconds>        <end time in integer milliseconds>      <transcript text>

Using integer milliseconds as start and end times means there's no chance of interference from
an environment setting a language encoding that causes the decimal in a floating point number
to appear as a comma; also is faster and more efficient to parse & store, e.g., in C++.
tsvNc                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# rQ   rR   )r   r4   s   "r   r   WriteTSV.__annotate__   s.     U UU"(U3;D>Ur   c                @   \        R RRRVR7       VR,           F  p\        \        RVR ,          ,          4      VRR7       \        \        RVR,          ,          4      VRR7       \        VR,          P                  4       P                  RR4      VR	R
7       K  	  R# )r&   r   rg   	)seprD   r    r   )rD   r    Trh   N)rj   r   rk   r   rl   s   &&&&, r   rJ   WriteTSV.write_result   s     	guf$T:j))G%ww//0tF%wu~-.TtD'&/'')11$<4tT *r   c                &   < V ^8  d   Qh/ S[ ;R&   # rX   r3   )r   r4   s   "r   r   r      s       r   r'   r7   )
rY   rZ   r[   r\   __doc__rH   rJ   r]   r^   r_   r`   s   @r   r   r      s$      IU U  r   r   c                   F   a  ] tR t^t o RtRV 3R lR lltV 3R ltRtV tR# )	WriteJSONjsonNc                <   < V ^8  d   QhRS[ RS[RS[S[ ,          /# rQ   rR   )r   r4   s   "r   r   WriteJSON.__annotate__   s)     4 44"(43;D>4r   c                6    \         P                  ! WR R7       R# )F)ensure_asciiN)r   dumprU   s   &&&&,r   rJ   WriteJSON.write_result   s     			&U3r   c                &   < V ^8  d   Qh/ S[ ;R&   # rX   r3   )r   r4   s   "r   r   r      s      r   r'   r7   rp   r`   s   @r   r   r      s     I4 4  r   r   c          	      l    V ^8  d   QhR\         R\         R\        \        \        \        .R3,          /# )r   output_formatr2   r!   N)r   r   r"   r   )r   s   "r   r   r      s5     . ..$'.tVT"D().r   c           
         a R \         R\        R\        R\        R\        /pV R8X  d3   VP                  4        Uu. uF
  q3! V4      NK  	  upoRR V3R lllpV# W ,          ! V4      # u upi )	rc   r   r   r   r   allc                R    V ^8  d   QhR\         R\        R\        \         ,          /# rQ   rR   )r   s   "r   r    get_writer.<locals>.__annotate__  s(     	8 	8	8 &	819$	8r   c                 .   < S F  pV! WV3/ VB  K  	  R # r7   r'   )r=   rD   r?   rK   writerall_writerss   &&&, r   	write_allget_writer.<locals>.write_all  s     &vW77 &r   r7   )rb   r   r   r   r   values)r   r2   writersr   r   r   s   &&   @r   
get_writerr      sw     	xxxx	G 8?8HI8Hfvj)8HI	8 	8 !*-- Js   A))FrA   )r   rE   r   typingr   r   r   r   r   r.   r0   rb   rr   r   r   r   r   r   r'   r   r   <module>r      s      	 3 3*" ",B| Bt
l t
n
I 
IN NU| U,4 4.r   