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.
Gives Auto-GPT a voice! The AI now spesks it's thoughts every turn.
Torantulino2cf3c8d7bd58
diff --git a/AutonomousAI/data/prompt.txt b/AutonomousAI/data/prompt.txtindex cf82f615ca..932256532c 100644--- a/AutonomousAI/data/prompt.txt+++ b/AutonomousAI/data/prompt.txt@@ -56,6 +56,7 @@ RESPONSE FORMAT:"reasoning": "reasoning","plan": "short bulleted long-term plan","criticism": "constructive self-criticism"+"speak": "thoughts summary to say to user"}}diff --git a/AutonomousAI/main.py b/AutonomousAI/main.pyindex 1f4b3f69de..969d4ebc10 100644--- a/AutonomousAI/main.py+++ b/AutonomousAI/main.py@@ -7,6 +7,7 @@ import chatfrom colorama import Fore, Stylefrom spinner import Spinnerimport time+import speakdef print_to_console(title, title_color, content, min_typing_speed=0.05, max_typing_speed=0.01):print(title_color + title + " " + Style.RESET_ALL, end="")@@ -35,11 +36,13 @@ def print_assistant_thoughts(assistant_reply):assistant_thoughts_reasoning = assistant_thoughts.get("reasoning")assistant_thoughts_plan = assistant_thoughts.get("plan")assistant_thoughts_criticism = assistant_thoughts.get("criticism")+ assistant_thoughts_speak = assistant_thoughts.get("speak")else:assistant_thoughts_text = Noneassistant_thoughts_reasoning = Noneassistant_thoughts_plan = Noneassistant_thoughts_criticism = None+ assistant_thoughts_speak = Noneprint_to_console(f"{ai_name.upper()} THOUGHTS:", Fore.YELLOW, assistant_thoughts_text)print_to_console("REASONING:", Fore.YELLOW, assistant_thoughts_reasoning)@@ -57,6 +60,10 @@ def print_assistant_thoughts(assistant_reply):print_to_console("- ", Fore.GREEN, line.strip())print_to_console("CRITICISM:", Fore.YELLOW, assistant_thoughts_criticism)+ # Speak the assistant's thoughts+ if assistant_thoughts_speak:+ speak.say_text(assistant_thoughts_speak)+except json.decoder.JSONDecodeError:print_to_console("Error: Invalid JSON\n", Fore.RED, assistant_reply)# All other errors, return "Error: + error message"diff --git a/AutonomousAI/speak.py b/AutonomousAI/speak.pynew file mode 100644index 0000000000..3673d420f3--- /dev/null+++ b/AutonomousAI/speak.py@@ -0,0 +1,29 @@+import os+from playsound import playsound+import requests+import keys++voice_id = "ErXwobaYiN019PkySvjV"+tts_url = "https://api.elevenlabs.io/v1/text-to-speech/{voice_id}".format(voice_id=voice_id)++tts_headers = {+ "Content-Type": "application/json",+ "xi-api-key": keys.ELEVENLABS_API_KEY+}+++def say_text(text):+ formatted_message = {"text": text}+ response = requests.post(+ tts_url, headers=tts_headers, json=formatted_message)++ if response.status_code == 200:+ with open("speech.mpeg", "wb") as f:+ f.write(response.content)+ playsound("speech.mpeg")+ # Delete audio file+ os.remove("speech.mpeg")+ else:+ print("Request failed with status code:", response.status_code)+ print("Response content:", response.content)+