diff --git a/scripts/speak.py b/scripts/speak.py index 13517d36..eab7b660 100644 --- a/scripts/speak.py +++ b/scripts/speak.py @@ -3,11 +3,12 @@ from playsound import playsound import requests from config import Config cfg = 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)