§
    ²eîiŸ  ã            	       ó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j        dee         dee         fd„Zdddœdeej                 dee         dee         fd„Z G d„ d¦  «        ZdS )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  — |                       t          › dt          j        ¦   «         › dt          › �t          j        t          ¦  «        ||d¬¦  «        4 ƒd{V —†	 }t          j        | 	                    ¦   «         ƒ d{V —†¦  «        }ddd¦  «        ƒd{V —† n# 1 ƒd{V —†swxY w Y   |D ]5}d|vri |d<   d|d         vrg |d         d<   d|d         vrg |d         d<   Œ6|S )	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         úS/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/edge_tts/voices.pyÚ__list_voicesr%      s°  è è € ð  �{Š{Ýð 	4ð 	4¥3Ô#:Ñ#<Ô#<ð 	4ð 	4Ý1ð	4ð 	4åÔ%¥mÑ4Ô4ØØØð ñ ô ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 
Ýœ*¨3¯8ª8©:¬:Ð%5Ð%5Ð%5Ð%5Ð%5Ð%5Ñ6Ô6ˆð7ð 7ð 7ñ 7ô 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7ð 7øøøð 7ð 7ð 7ð 7ð ð 9ð 9ˆØ˜UÐ"Ð"Ø "ˆE�*Ñà e¨JÔ&7Ð7Ð7Ø57ˆE�*ÔÐ1Ñ2à u¨ZÔ'8Ð8Ð8Ø68ˆE�*ÔÐ2Ñ3øà€Ks   Á-BÂ
B'Â*B')Ú	connectorr   r&   c              ƒ   óv  K  — t          j        | d¬¦  «        4 ƒd{V —†}	 t          |t          |¦  «        ƒ d{V —†}nX# t           j        $ rF}|j        dk    r‚ t          j        |¦  «         t          |t          |¦  «        ƒ d{V —†}Y d}~nd}~ww xY wddd¦  «        ƒd{V —† n# 1 ƒd{V —†swxY w Y   |S )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ÑIÔIð Að Að Að Að Að Að AÈWð	AÝ& wµ¸%Ñ@Ô@Ð@Ð@Ð@Ð@Ð@Ð@ˆDˆDøÝÔ*ð 	Að 	Að 	AØŒx˜3ŠˆØåÔ,¨QÑ/Ô/Ð/Ý& wµ¸%Ñ@Ô@Ð@Ð@Ð@Ð@Ð@Ð@ˆDˆDˆDˆDˆDˆDøøøøð	AøøøðAð Að Añ Aô Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Að Aøøøð Að Að Að Að €Ks7   ŸB(¡>½B(¾BÁ<BÂ	B(ÂBÂB(Â(
B2Â5B2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dS )ÚVoicesManagerzF
    A class to find the correct voice based on their attributes.
    r   Nc                 ó"   — g | _         d| _        d S )NF)ÚvoicesÚcalled_create)Úselfs    r$   Ú__init__zVoicesManager.__init__[   s   € Ø02ˆŒØ#(ˆÔÐÐó    Úcustom_voicesc              ƒ   ó†   K  — t          ¦   «         }|€t          ¦   «         ƒ d{V —†n|}d„ |D ¦   «         |_        d|_        |S )z\
        Creates a VoicesManager object and populates it with all available voices.
        Nc                 ó\   — g | ])}i |¥d |d                               d¦  «        d         i¥‘Œ*S )ÚLanguageÚLocaleÚ-r   )Úsplit)Ú.0r#   s     r$   ú
<listcomp>z(VoicesManager.create.<locals>.<listcomp>h   sL   € ð 
ð 
ð 
ØEJÐ@ˆuÐ@�j %¨¤/×"7Ò"7¸Ñ"<Ô"<¸QÔ"?Ð@Ð@ð
ð 
ð 
r8   T)r2   r0   r4   r5   )Úclsr9   r6   r4   s       r$   ÚcreatezVoicesManager.create_   se   è è € õ ‰ŒˆØ(5Ð(=•{‘}”}Ð$Ð$Ð$Ð$Ð$Ð$Ð$À=ˆð
ð 
ØNTð
ñ 
ô 
ˆŒð "ˆÔØˆr8   Úkwargsc                 óZ   ‡— | j         st          d¦  «        ‚ˆfd„| j        D ¦   «         }|S )zM
        Finds all matching voices based on the provided attributes.
        z9VoicesManager.find() called before VoicesManager.create()c                 óh   •— g | ].}‰                      ¦   «         |                      ¦   «         k    ¯,|‘Œ/S © )Úitems)r@   r#   rD   s     €r$   rA   z&VoicesManager.find.<locals>.<listcomp>w   s:   ø€ ð 
ð 
ð 
Ø¨f¯lªl©n¬nÀÇÂÁÄÒ.MÐ.MˆEÐ.MÐ.MÐ.Mr8   )r5   ÚRuntimeErrorr4   )r6   rD   Úmatching_voicess    ` r$   ÚfindzVoicesManager.findn   sW   ø€ ð Ô!ð 	ÝØKñô ð ð
ð 
ð 
ð 
Ø#œ{ð
ñ 
ô 
ˆð Ðr8   )r   N)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r7   Úclassmethodr   r   r   rC   r   r   r   rK   rG   r8   r$   r2   r2   V   s¡   € € € € € ðð ð)ð )ð )ð )ð à48ðð Ø$ T¨%¤[Ô1ðà	ðð ð ñ „[ðð˜VÐ$5Ô6ð ¸4Ð@RÔ;Sð ð ð ð ð ð r8   r2   )rO   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   rG   r8   r$   ú<module>r[      s’  ðð,ð ,ð €€€Ø 
€
€
€
Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à €€€Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $à DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DÐ DØ Ð Ð Ð Ð Ð Ø @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @Ð @à%ˆ3Ô%¨]¨W¬]©_¬_Ð=Ñ=Ô=€ð$ØÔ"ð$Ø-0¬^ð$ØDLÈSÄMð$à	ˆ%„[ð$ð $ð $ð $ðP 59ÐQUðð ð Ø˜7Ô0Ô1ðØAIÈ#Äðà	ˆ%„[ðð ð ð ð8$ð $ð $ð $ð $ñ $ô $ð $ð $ð $r8   