CoolFace
Apppublic

Bitsak/AutoGPT2

sourceHugging Facemitupdated 3y agoView on Hugging Face
0likes
brian.py41 linesDownload Raw Back to speech
1""" Brian speech module for autogpt """2import os3 4import requests5from playsound import playsound6 7from autogpt.speech.base import VoiceBase8 9 10class BrianSpeech(VoiceBase):11    """Brian speech module for autogpt"""12 13    def _setup(self) -> None:14        """Setup the voices, API key, etc."""15        pass16 17    def _speech(self, text: str, _: int = 0) -> bool:18        """Speak text using Brian with the streamelements API19 20        Args:21            text (str): The text to speak22 23        Returns:24            bool: True if the request was successful, False otherwise25        """26        tts_url = (27            f"https://api.streamelements.com/kappa/v2/speech?voice=Brian&text={text}"28        )29        response = requests.get(tts_url)30 31        if response.status_code == 200:32            with open("speech.mp3", "wb") as f:33                f.write(response.content)34            playsound("speech.mp3")35            os.remove("speech.mp3")36            return True37        else:38            print("Request failed with status code:", response.status_code)39            print("Response content:", response.content)40            return False41