mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 22:44:21 +01:00
replace gtts with macos tts
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user