AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Bugfix fixtts (#4902)
zachRadack053caaa22270
diff --git a/autogpt/agent/agent.py b/autogpt/agent/agent.pyindex 1005195679..fd476e56e4 100644--- a/autogpt/agent/agent.py+++ b/autogpt/agent/agent.py@@ -165,7 +165,7 @@ class Agent:assistant_reply_json, assistant_reply, self.config)if self.config.speak_mode:- say_text(f"I want to execute {command_name}")+ say_text(f"I want to execute {command_name}", self.config)arguments = self._resolve_pathlike_command_args(arguments)diff --git a/autogpt/logs.py b/autogpt/logs.pyindex 9d99f274da..535cce3223 100644--- a/autogpt/logs.py+++ b/autogpt/logs.py@@ -16,7 +16,6 @@ if TYPE_CHECKING:from autogpt.log_cycle.json_handler import JsonFileHandler, JsonFormatterfrom autogpt.singleton import Singleton-from autogpt.speech import say_textclass Logger(metaclass=Singleton):@@ -87,13 +86,16 @@ class Logger(metaclass=Singleton):self.json_logger.setLevel(logging.DEBUG)self.speak_mode = False+ self.config = Noneself.chat_plugins = []def typewriter_log(self, title="", title_color="", content="", speak_text=False, level=logging.INFO):+ from autogpt.speech import say_text+if speak_text and self.speak_mode:- say_text(f"{title}. {content}")+ say_text(f"{title}. {content}", self.config)for plugin in self.chat_plugins:plugin.report(f"{title}. {content}")@@ -265,6 +267,8 @@ def print_assistant_thoughts(assistant_reply_json_valid: object,config: Config,) -> None:+ from autogpt.speech import say_text+assistant_thoughts_reasoning = Noneassistant_thoughts_plan = Noneassistant_thoughts_speak = Nonediff --git a/autogpt/main.py b/autogpt/main.pyindex c1b79c7836..26e8e331f8 100644--- a/autogpt/main.py+++ b/autogpt/main.py@@ -58,6 +58,9 @@ def run_auto_gpt(logger.speak_mode = speakconfig = ConfigBuilder.build_config_from_env()+ # HACK: This is a hack to allow the config into the logger without having to pass it around everywhere+ # or import it directly.+ logger.config = config# TODO: fill in llm values herecheck_openai_api_key(config)diff --git a/autogpt/speech/base.py b/autogpt/speech/base.pyindex 44e90eaa7b..b3dd03bdbd 100644--- a/autogpt/speech/base.py+++ b/autogpt/speech/base.py@@ -45,7 +45,7 @@ class VoiceBase(AbstractSingleton):return self._speech(text, voice_index)@abc.abstractmethod- def _setup(self) -> None:+ def _setup(self, config: Config) -> None:"""Setup the voices, API key, etc."""diff --git a/autogpt/speech/gtts.py b/autogpt/speech/gtts.pyindex 1c3e9cae05..deef4f2702 100644--- a/autogpt/speech/gtts.py+++ b/autogpt/speech/gtts.py@@ -4,13 +4,14 @@ import osimport gttsfrom playsound import playsound+from autogpt.config import Configfrom autogpt.speech.base import VoiceBaseclass GTTSVoice(VoiceBase):"""GTTS Voice."""- def _setup(self) -> None:+ def _setup(self, config: Config) -> None:passdef _speech(self, text: str, _: int = 0) -> bool:diff --git a/autogpt/speech/macos_tts.py b/autogpt/speech/macos_tts.pyindex 4c072ce256..e48522cf98 100644--- a/autogpt/speech/macos_tts.py+++ b/autogpt/speech/macos_tts.py@@ -1,13 +1,14 @@""" MacOS TTS Voice. """import os+from autogpt.config import Configfrom autogpt.speech.base import VoiceBaseclass MacOSTTS(VoiceBase):"""MacOS TTS Voice."""- def _setup(self) -> None:+ def _setup(self, config: Config) -> None:passdef _speech(self, text: str, voice_index: int = 0) -> bool:diff --git a/autogpt/speech/say.py b/autogpt/speech/say.pyindex 3d71a392c5..5d04c76f93 100644--- a/autogpt/speech/say.py+++ b/autogpt/speech/say.py@@ -41,10 +41,10 @@ def _get_voice_engine(config: Config) -> tuple[VoiceBase, VoiceBase]:if tts_provider == "elevenlabs":voice_engine = ElevenLabsSpeech(config)elif tts_provider == "macos":- voice_engine = MacOSTTS()+ voice_engine = MacOSTTS(config)elif tts_provider == "streamelements":- voice_engine = StreamElementsSpeech()+ voice_engine = StreamElementsSpeech(config)else:- voice_engine = GTTSVoice()+ voice_engine = GTTSVoice(config)- return GTTSVoice(), voice_engine+ return GTTSVoice(config), voice_enginediff --git a/autogpt/speech/stream_elements_speech.py b/autogpt/speech/stream_elements_speech.pyindex 9019cf0954..e4e4e8bfe7 100644--- a/autogpt/speech/stream_elements_speech.py+++ b/autogpt/speech/stream_elements_speech.py@@ -4,13 +4,14 @@ import osimport requestsfrom playsound import playsound+from autogpt.config import Configfrom autogpt.speech.base import VoiceBaseclass StreamElementsSpeech(VoiceBase):"""Streamelements speech module for autogpt"""- def _setup(self) -> None:+ def _setup(self, config: Config) -> None:"""Setup the voices, API key, etc."""def _speech(self, text: str, voice: str, _: int = 0) -> bool: