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.
replace gtts with macos tts
Wlad34560901175d
diff --git a/scripts/speak.py b/scripts/speak.pyindex 13517d366f..eab7b6601f 100644--- a/scripts/speak.py+++ b/scripts/speak.py@@ -3,11 +3,12 @@ from playsound import playsoundimport requestsfrom config import Configcfg = Config()-import gtts+# Remove the import of gtts+# import gtts-# TODO: Nicer names for these ids-voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"]+# Change voices to macOS voice identifiers+voices = ["com.apple.speech.synthesis.voice.siri_female", "com.apple.speech.synthesis.voice.siri_male"]tts_headers = {"Content-Type": "application/json",@@ -32,17 +33,14 @@ def eleven_labs_speech(text, voice_index=0):print("Response content:", response.content)return False-def gtts_speech(text):- tts = gtts.gTTS(text)- tts.save("speech.mp3")- playsound("speech.mp3")- os.remove("speech.mp3")+# Use macOS built-in TTS instead of gtts+def macos_tts_speech(text, voice_index=1):+ os.system(f'say "{text}"')def say_text(text, voice_index=0):if not cfg.elevenlabs_api_key:- gtts_speech(text)+ macos_tts_speech(text, voice_index)else:success = eleven_labs_speech(text, voice_index)if not success:- gtts_speech(text)-+ macos_tts_speech(text, voice_index)