Skip to content

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.py
index 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.py
index 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, JsonFormatter
from autogpt.singleton import Singleton
-from autogpt.speech import say_text
class Logger(metaclass=Singleton):
@@ -87,13 +86,16 @@ class Logger(metaclass=Singleton):
self.json_logger.setLevel(logging.DEBUG)
self.speak_mode = False
+ self.config = None
self.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 = None
assistant_thoughts_plan = None
assistant_thoughts_speak = None
diff --git a/autogpt/main.py b/autogpt/main.py
index c1b79c7836..26e8e331f8 100644
--- a/autogpt/main.py
+++ b/autogpt/main.py
@@ -58,6 +58,9 @@ def run_auto_gpt(
logger.speak_mode = speak
config = 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 here
check_openai_api_key(config)
diff --git a/autogpt/speech/base.py b/autogpt/speech/base.py
index 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.py
index 1c3e9cae05..deef4f2702 100644
--- a/autogpt/speech/gtts.py
+++ b/autogpt/speech/gtts.py
@@ -4,13 +4,14 @@ import os
import gtts
from playsound import playsound
+from autogpt.config import Config
from autogpt.speech.base import VoiceBase
class GTTSVoice(VoiceBase):
"""GTTS Voice."""
- def _setup(self) -> None:
+ def _setup(self, config: Config) -> None:
pass
def _speech(self, text: str, _: int = 0) -> bool:
diff --git a/autogpt/speech/macos_tts.py b/autogpt/speech/macos_tts.py
index 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 Config
from autogpt.speech.base import VoiceBase
class MacOSTTS(VoiceBase):
"""MacOS TTS Voice."""
- def _setup(self) -> None:
+ def _setup(self, config: Config) -> None:
pass
def _speech(self, text: str, voice_index: int = 0) -> bool:
diff --git a/autogpt/speech/say.py b/autogpt/speech/say.py
index 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_engine
diff --git a/autogpt/speech/stream_elements_speech.py b/autogpt/speech/stream_elements_speech.py
index 9019cf0954..e4e4e8bfe7 100644
--- a/autogpt/speech/stream_elements_speech.py
+++ b/autogpt/speech/stream_elements_speech.py
@@ -4,13 +4,14 @@ import os
import requests
from playsound import playsound
+from autogpt.config import Config
from autogpt.speech.base import VoiceBase
class 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: