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.
add config for mac os tts
Wlad2facc3e2cb65
diff --git a/.env.template b/.env.templateindex 525cd61c5f..f9a74c9ca4 100644--- a/.env.template+++ b/.env.template@@ -11,4 +11,5 @@ OPENAI_API_BASE=your-base-url-for-azureOPENAI_API_VERSION=api-version-for-azureOPENAI_DEPLOYMENT_ID=deployment-id-for-azureIMAGE_PROVIDER=dalle-HUGGINGFACE_API_TOKEN=\ No newline at end of file+HUGGINGFACE_API_TOKEN=+USE_MAC_OS_TTS=Falsediff --git a/scripts/speak.py b/scripts/speak.pyindex eab7b6601f..1ffad84641 100644--- a/scripts/speak.py+++ b/scripts/speak.py@@ -3,12 +3,10 @@ from playsound import playsoundimport requestsfrom config import Configcfg = Config()+import gtts-# Remove the import of gtts-# import gtts--# Change voices to macOS voice identifiers-voices = ["com.apple.speech.synthesis.voice.siri_female", "com.apple.speech.synthesis.voice.siri_male"]+# TODO: Nicer names for these ids+voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"]tts_headers = {"Content-Type": "application/json",@@ -33,14 +31,21 @@ def eleven_labs_speech(text, voice_index=0):print("Response content:", response.content)return False-# Use macOS built-in TTS instead of gtts-def macos_tts_speech(text, voice_index=1):+def gtts_speech(text):+ tts = gtts.gTTS(text)+ tts.save("speech.mp3")+ playsound("speech.mp3")+ os.remove("speech.mp3")++def macos_tts_speech(text):os.system(f'say "{text}"')def say_text(text, voice_index=0):if not cfg.elevenlabs_api_key:- macos_tts_speech(text, voice_index)+ if cfg.use_mac_os_tts == 'True':+ macos_tts_speech(text)+ gtts(text)else:success = eleven_labs_speech(text, voice_index)if not success:- macos_tts_speech(text, voice_index)+ gtts_speech()(text)