mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-31 12:54:29 +01:00
Bugfix fixtts (#4902)
* changing configs names to tts_provider * accidently triggered circular importing. * added config to places it needs other than the logger * got it to work on windows * did all the formatting stuff --------- Co-authored-by: James Collins <collijk@uw.edu>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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.
|
||||
"""
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user