
    3h                         S r SSKrSSKrSSKrSSKJrJr  SSKJr  SSKJ	r	J
r
Jr  SSKJr  SSKJr  S	\\   S
S4S jrS\S
S4S jrSS jrSS jr\S:X  a  \" 5         gg)zJUtility functions for the command line interface. Used by the main module.    N)OptionalTextIO)tabulate   )CommunicateSubMakerlist_voices)DEFAULT_VOICE)UtilArgsproxyreturnc           
        #    [        U S9I Sh  vN n[        US S9n/ SQnU Vs/ s H9  nUS   US   SR                  US	   S
   5      SR                  US	   S   5      /PM;     nn[        [	        XB5      5        g Nns  snf 7f)zPrint all available voices.r   Nc                     U S   $ )N	ShortName )voices    E/var/www/auris/envauris/lib/python3.13/site-packages/edge_tts/util.py<lambda>_print_voices.<locals>.<lambda>   s	    eK.@    )key)NameGenderContentCategoriesVoicePersonalitiesr   r   z, VoiceTagr   r   )r	   sortedjoinprintr   )r   voicesheadersr   tables        r   _print_voicesr$      s     U++FF @AFKG  E +(OIIeJ'(;<=IIeJ'(<=>		
  
  
(5
"# ,s!   BA>BA B 'B Bargsc           	        #     [         R                  R                  5       (       aV  [         R                  R                  5       (       a3  U R                  (       d"  [        S[         R                  S9  [        5         [        U R                  U R                  U R                  U R                  U R                  U R                  S9n[!        5       n U R                  b&  U R                  S:w  a  [#        U R                  S5      O[         R                  R$                  nU R&                  b%  U R&                  S:w  a  [#        U R&                  SS	S
9OSnUc   U R&                  S:X  a  [         R                  nUR)                  5         Sh  vN nUS   S:X  a  UR+                  US   5        M(  US   S:X  d  M3  UR-                  U5        MF  ! [         a    [        S[         R                  S9   gf = f Ni
 U R.                  S:  a  UR1                  U R.                  5        Ub  UR+                  UR3                  5       5        U[         R                  R$                  La  UR5                  5         Ub%  U[         R                  La  UR5                  5         ggg! W[         R                  R$                  La  UR5                  5         Wb%  U[         R                  La  UR5                  5         f f f = f7f)z2Run TTS after parsing arguments from command line.zWarning: TTS output will be written to the terminal. Use --write-media to write to a file.
Press Ctrl+C to cancel the operation. Press Enter to continue.)filez
Operation canceled.N)ratevolumepitchr   -wbwutf-8encodingtypeaudiodataWordBoundaryr   )sysstdinisattystdoutwrite_mediar    stderrinputKeyboardInterruptr   textr   r(   r)   r*   r   r   openbufferwrite_subtitlesstreamwritefeedwords_in_cue
merge_cuesget_srtclose)r%   communicatesubmaker
audio_filesub_filechunks         r   _run_ttsrM       sd    99#**"3"3"5"5d>N>N+ ZZ G
 		

YY{{jjjjK zH +0@0@C0G !!4("" 	 ##/D4H4HC4O %%sW= 	
  4 4 ;zzH&--/ 	%%V}'  v/v.0e$?  %CJJ76	%/ q  1 12NN8++-.SZZ...HCJJ$>NN %? SZZ...HCJJ$>NN %?sp   K4A9G =AK4B4J G6
G4G6'J 9J "G1.K40G11K44G66AJ AK4AK11K4c                    #    [         R                  " SS9n U R                  SS9nUR                  SSSS9  UR                  S	S
SS9  U R                  SSS[         3[        S9  UR                  SSSSS9  U R                  SSSS9  U R                  SSSS9  U R                  SSSS9  U R                  SSS[
        S 9  U R                  S!S"S9  U R                  S#S$S9  U R                  S%S&S9  U R                  [        5       S'9nUR                  (       a1  [        UR                  S(9I S)h  vN   [        R                  " S*5        UR                  bg  UR                  S+;   a$  [        R                  R                  5       Ul        O3[#        UR                  S,S-S.9 nUR                  5       Ul        S)S)S)5        UR                   b  [%        U5      I S)h  vN   g)g) N! , (       d  f       N2= f N7f)/zAsync main functionz9Text-to-speech using Microsoft Edge's online TTS service.)descriptionT)requiredz-tz--textzwhat TTS will say)helpz-fz--filez!same as --text but read from filez-vz--voicezvoice for TTS. Default: )rQ   defaultz-lz--list-voicesz lists available voices and exits
store_true)rQ   actionz--ratezset TTS rate. Default +0%%.z+0%z--volumezset TTS volume. Default +0%%.z--pitchzset TTS pitch. Default +0Hz.z+0Hzz--words-in-cuez/number of words in a subtitle cue. Default: 10.
   )rQ   rR   r1   z--write-mediaz+send media output to file instead of stdoutz--write-subtitlesz7send subtitle output to provided file instead of stderrz--proxyz#use a proxy for TTS and voice list.)	namespacer   Nr   )r+   z
/dev/stdinrr.   r/   )argparseArgumentParseradd_mutually_exclusive_groupadd_argumentr
   int
parse_argsr   r	   r$   r   r5   exitr'   r6   readr=   r>   rM   )parsergroupr%   r'   s       r   amainrb   Z   s
    $$OF ///>E	tX,?@	tX,OP
'7	   
/	   'DeT

)HRWX
	(FPVW
>	   K   F   	(MNxz2D$**---yy99++		(DIdiiw74 IIK	 8 yytn  	. 87 	s7   D,G4.G/A0G4G!5#G4G2G4!
G/+G4c                  @    [         R                  " [        5       5        g)z$Run the main function using asyncio.N)asynciorunrb   r   r   r   mainrf      s    KKr   __main__)r   N)__doc__rX   rd   r5   typingr   r   r    r   r   r	   	constantsr
   data_classesr   strr$   rM   rb   rf   __name__r   r   r   <module>ro      sm    P   
 #  0 0 $ "$(3- $D $"7 7d 7t3l
 zF r   