
    Fd                     R    d dl Z d dlZd dlZd dlmZ d dlmZ  G d de          ZdS )    N)	playsound)	VoiceBasec            	       4    e Zd ZdZd
dZddedededefd	ZdS )StreamElementsSpeechz(Streamelements speech module for autogptreturnNc                     dS )zSetup the voices, API key, etc.N )selfs    YC:\Users\Administrator\Downloads\Auto-GPT-master\autogpt\speech\stream_elements_speech.py_setupzStreamElementsSpeech._setup   s          r   textvoice_c                 b   d| d| }t          j        |          }|j        dk    rgt          dd          5 }|                    |j                   ddd           n# 1 swxY w Y   t          d           t          j        d           dS t          j
        d|j        |j                   d	S )
zSpeak text using the streamelements API

        Args:
            text (str): The text to speak
            voice (str): The voice to use

        Returns:
            bool: True if the request was successful, False otherwise
        z5https://api.streamelements.com/kappa/v2/speech?voice=z&text=   z
speech.mp3wbNTz9Request failed with status code: %s, response content: %sF)requestsgetstatus_codeopenwritecontentr   osremoveloggingerror)r
   r   r   r   tts_urlresponsefs          r   _speechzStreamElementsSpeech._speech   s    XEWWQUWW 	 <((3&&lD)) *Q()))* * * * * * * * * * * * * * *l###Il###4MK$   
 5s   AA#&A#)r   N)r   )	__name__
__module____qualname____doc__r   strintboolr!   r	   r   r   r   r   
   sc        22. . . . C   D      r   r   )r   r   r   r   autogpt.speech.baser   r   r	   r   r   <module>r*      sx     				        ) ) ) ) ) )! ! ! ! !9 ! ! ! ! !r   