Ë
    Gü´jŸ  ã            	       ób  — d Z ddlZddlZddlmZmZmZ ddlZddlZddl	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZmZ  ej(                   ej*                  «       ¬	«      Zd
ej.                  dej0                  dee   dee   fd„Zdddœdeej6                     dee   dee   fd„Z G d„ d«      Zy)z|This module contains functions to list all available voices and a class to find the
correct voice based on their attributes.é    N)ÚAnyÚListÚOptional)ÚUnpacké   )ÚSEC_MS_GEC_VERSIONÚVOICE_HEADERSÚ
VOICE_LIST)ÚDRM)ÚVoiceÚVoicesManagerFindÚVoicesManagerVoice)ÚcafileÚsessionÚssl_ctxÚproxyÚreturnc              ƒ   óÈ  K  — | j                  t        › dt        j                  «       › dt        › �t        j
                  t        «      ||d¬«      4 ƒd{  –—† }t        j                  |j                  «       ƒ d{  –—† «      }ddd«      ƒd{  –—†  D ]*  }d|vri |d<   d|d   vrg |d   d<   d|d   vsŒ#g |d   d<   Œ, |S 7 Œp7 ŒK7 Œ9# 1 ƒd{  –—†7  sw Y   ŒIxY w­w)	a  
    Private function that makes the request to the voice list URL and parses the
    JSON response. This function is used by list_voices() and makes it easier to
    handle client response errors related to clock skew.

    Args:
        session (aiohttp.ClientSession): The aiohttp session to use for the request.
        ssl_ctx (ssl.SSLContext): The SSL context to use for the request.
        proxy (Optional[str]): The proxy to use for the request.

    Returns:
        List[Voice]: A list of voices and their attributes.
    z&Sec-MS-GEC=z&Sec-MS-GEC-Version=T)Úheadersr   ÚsslÚraise_for_statusNÚVoiceTagÚContentCategoriesÚVoicePersonalities)
Úgetr
   r   Úgenerate_sec_ms_gecr   Úheaders_with_muidr	   ÚjsonÚloadsÚtext)r   r   r   ÚurlÚdataÚvoices         úM/root/workspace/ytshorts/venv/lib/python3.12/site-packages/edge_tts/voices.pyÚ__list_voicesr%      s  è ø€ ð  �{‰{Üˆ,�l¤3×#:Ñ#:Ó#<Ð"=Ø
Ô1Ð2ð	4ä×%Ñ%¤mÓ4ØØØð ó ÷ 7ð 7ð 
ÜŸ*™*¨3¯8©8«:×%5Ó6ˆ÷7÷ 7ð ò 9ˆØ˜UÑ"Ø "ˆE�*Ñà e¨JÑ&7Ñ7Ø57ˆE�*ÑÐ1Ñ2à u¨ZÑ'8Ò8Ø68ˆE�*ÑÐ2Ò3ð9ð €Kð)7øð &6øð7ø÷ 7÷ 7ñ 7üs`   ‚AC"ÁCÁC"Á#CÁ=C	
Á>CÂC"ÂCÂ(C"Â;C"Ã	CÃC"ÃCÃCÃCÃC")Ú	connectorr   r&   c              ƒ   ó˜  K  — t        j                  | d¬«      4 ƒd{  –—† }	 t        |t        |«      ƒ d{  –—† }ddd«      ƒd{  –—†  |S 7 Œ07 Œ# t         j                  $ rI}|j
                  dk7  r‚ t        j                  |«       t        |t        |«      ƒ d{  –—†7  }Y d}~Œmd}~ww xY w7 Œi# 1 ƒd{  –—†7  sw Y   S xY w­w)a‘  
    List all available voices and their attributes.

    This pulls data from the URL used by Microsoft Edge to return a list of
    all available voices.

    Args:
        connector (Optional[aiohttp.BaseConnector]): The connector to use for the request.
        proxy (Optional[str]): The proxy to use for the request.

    Returns:
        List[Voice]: A list of voices and their attributes.
    T)r&   Ú	trust_envNi“  )ÚaiohttpÚClientSessionr%   Ú_SSL_CTXÚClientResponseErrorÚstatusr   Úhandle_client_response_error)r&   r   r   r"   Úes        r$   Úlist_voicesr0   :   sÂ   è ø€ ô  ×$Ñ$¨yÀDÔI÷ Að AÈWð	AÜ& w´¸%Ó@×@ˆD÷A÷ Að €KðAøà@ùÜ×*Ñ*ò 	AØ�x‰x˜3ŠØä×,Ñ,¨QÔ/Ü& w´¸%Ó@×@Ð@�Dûð	AúðAø÷ A÷ Að Að €Küs‚   ‚C
žAŸC
¢B4¤A¸A¹A½C
ÁB2Á	C
ÁAÁB/Á&9B*ÂB"Â B*Â%B4Â*B/Â/B4Â2C
Â4CÂ:B=Â;CÃC
c                   ó^   — e Zd ZdZd	d„Ze	 d
deee      dd fd„«       Z	de
e   dee   fd„Zy)ÚVoicesManagerzF
    A class to find the correct voice based on their attributes.
    r   Nc                 ó    — g | _         d| _        y )NF)ÚvoicesÚcalled_create)Úselfs    r$   Ú__init__zVoicesManager.__init__[   s   € Ø02ˆŒØ#(ˆÕó    Úcustom_voicesc              ƒ   óÊ   K  — t        «       }|€t        «       ƒ d{  –—† n|}|D �cg c]  }i |¥d|d   j                  d«      d   i¥‘Œ! c}|_        d|_        |S 7 Œ?c c}w ­w)z\
        Creates a VoicesManager object and populates it with all available voices.
        NÚLanguageÚLocaleú-r   T)r2   r0   Úsplitr4   r5   )Úclsr9   r6   r4   r#   s        r$   ÚcreatezVoicesManager.create_   st   è ø€ ô ‹ˆØ(5Ð(=”{“}×$Ð$À=ˆàNTö
ØEJÐ@ˆuÐ@�j %¨¡/×"7Ñ"7¸Ó"<¸QÑ"?Ó@ò
ˆŒð "ˆÔØˆð %úò
ùs    ‚A#œA�
A#§$AÁA#ÁA#Úkwargsc                 ó´   — | j                   st        d«      ‚| j                  D �cg c]&  }|j                  «       |j                  «       k  sŒ%|‘Œ( }}|S c c}w )zM
        Finds all matching voices based on the provided attributes.
        z9VoicesManager.find() called before VoicesManager.create())r5   ÚRuntimeErrorr4   Úitems)r6   rA   r#   Úmatching_voicess       r$   ÚfindzVoicesManager.findn   s]   € ð ×!Ò!ÜØKóð ð
  $Ÿ{™{ö
Ø¨f¯l©l«nÀÇÁÃÓ.MŠEð
ˆð 
ð Ðùò
s   ¦&AÁA)r   N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   Úclassmethodr   r   r   r@   r   r   r   rF   © r8   r$   r2   r2   V   s[   „ ñó)ð à48ñØ$ T¨%¡[Ñ1ðà	òó ðð˜VÐ$5Ñ6ð ¸4Ð@RÑ;Sô r8   r2   )rJ   r   r   Útypingr   r   r   r)   ÚcertifiÚtyping_extensionsr   Ú	constantsr   r	   r
   Údrmr   r   r   r   Úcreate_default_contextÚwherer+   r*   Ú
SSLContextÚstrr%   ÚBaseConnectorr0   r2   rL   r8   r$   ú<module>rW      sÄ   ðñ,ó Û 
ß &Ñ &ã Û Ý $ç DÑ DÝ ß @Ñ @à%ˆ3×%Ñ%¨]¨W¯]©]«_Ô=€ð$Ø×"Ñ"ð$Ø-0¯^©^ð$ØDLÈSÁMð$à	ˆ%�[ó$ðP 59ÐQUòØ˜7×0Ñ0Ñ1ðØAIÈ#Áðà	ˆ%�[ó÷8$ò $r8   