
    Fd                     `    d Z ddlZddlZddlmZ ddlmZ ddlmZ dhZ G d de          Z	dS )	zElevenLabs speech module    N)	playsound)Config)	VoiceBasezyour-voice-idc                   @    e Zd ZdZdeddfdZddZdded	ede	fd
Z
dS )ElevenLabsSpeechzElevenLabs speech classconfigreturnNc           
      N   ddg}ddddddddd	d
	}d|j         d| _        |                                | _        |j        |v r||j                 |_        |j        |v r||j                 |_        |                     |j        d           |                     |j        d           dS )zRSet up the voices, API key, etc.

        Returns:
            None: None
        ErXwobaYiN019PkySvjVEXAVITQu4vr4xnSDxMaL21m00Tcm4TlvDq8ikWAMAZnzlk1XvdvUeBnXmlldMF3mGyEYCl7XYWbV9V6OTxGEqnHWrfWFTfGW9XjXVR6AewLTigWG4xSOukaGpNInz6obpgDQGcFmaJgByoZ06aMxZJJ28mfd3POQ)	RachelDomiBellaAntoniElliJoshArnoldAdamSamzapplication/json)zContent-Typez
xi-api-keyr      N)elevenlabs_api_key_headerscopy_voiceselevenlabs_voice_idelevenlabs_voice_2_id_use_custom_voice)selfr   default_voicesvoice_optionss       NC:\Users\Administrator\Downloads\Auto-GPT-master\autogpt\speech\eleven_labs.py_setupzElevenLabsSpeech._setup   s     12HI,*+,**,*)

 

 / 3
 
 &**,,%66)6v7Q)RF&'=88+89U+VF(v91===v;Q?????    c                 8    |r|t           vr|| j        |<   dS dS dS )zUse a custom voice if provided and not a placeholder

        Args:
            voice (str): The voice ID
            voice_index (int): The voice index

        Returns:
            None: None
        N)PLACEHOLDERSr!   )r%   voicevoice_indexs      r(   r$   z"ElevenLabsSpeech._use_custom_voice/   s8      	.U,..(-DL%%%	. 	...r*   r   textr.   c                    ddl m} d| j        |          }t          j        || j        d|i          }|j        dk    rht          dd          5 }|                    |j	                   d	d	d	           n# 1 swxY w Y   t          dd
           t          j        d           d
S |                    d|j                   |                    d|j	                   dS )a  Speak text using elevenlabs.io's API

        Args:
            text (str): The text to speak
            voice_index (int, optional): The voice to use. Defaults to 0.

        Returns:
            bool: True if the request was successful, False otherwise
        r   )loggerz,https://api.elevenlabs.io/v1/text-to-speech/r/   )headersjson   zspeech.mpegwbNTz Request failed with status code:zResponse content:F)autogpt.logsr1   r!   requestspostr   status_codeopenwritecontentr   osremovewarninfo)r%   r/   r.   r1   tts_urlresponsefs          r(   _speechzElevenLabsSpeech._speech=   s-    	(''''' W4<;TVV 	 =$-vtnUUU3&&mT** *a()))* * * * * * * * * * * * * * *mT***Im$$$4KK:H<PQQQKK+X-=>>>5s   A77A;>A;)r	   N)r   )__name__
__module____qualname____doc__r   r)   r$   strintboolrD    r*   r(   r   r      s        !!@V @ @ @ @ @>. . . . C c $      r*   r   )
rH   r=   r7   r   autogpt.config.configr   autogpt.speech.baser   r,   r   rL   r*   r(   <module>rO      s      				        ( ( ( ( ( ( ) ) ) ) ) ) J J J J Jy J J J J Jr*   