mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-20 15:34:23 +01:00
replace gtts with macos tts
This commit is contained in:
@@ -3,11 +3,12 @@ from playsound import playsound
|
|||||||
import requests
|
import requests
|
||||||
from config import Config
|
from config import Config
|
||||||
cfg = Config()
|
cfg = Config()
|
||||||
import gtts
|
|
||||||
|
|
||||||
|
# Remove the import of gtts
|
||||||
|
# import gtts
|
||||||
|
|
||||||
# TODO: Nicer names for these ids
|
# Change voices to macOS voice identifiers
|
||||||
voices = ["ErXwobaYiN019PkySvjV", "EXAVITQu4vr4xnSDxMaL"]
|
voices = ["com.apple.speech.synthesis.voice.siri_female", "com.apple.speech.synthesis.voice.siri_male"]
|
||||||
|
|
||||||
tts_headers = {
|
tts_headers = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
@@ -32,17 +33,14 @@ def eleven_labs_speech(text, voice_index=0):
|
|||||||
print("Response content:", response.content)
|
print("Response content:", response.content)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def gtts_speech(text):
|
# Use macOS built-in TTS instead of gtts
|
||||||
tts = gtts.gTTS(text)
|
def macos_tts_speech(text, voice_index=1):
|
||||||
tts.save("speech.mp3")
|
os.system(f'say "{text}"')
|
||||||
playsound("speech.mp3")
|
|
||||||
os.remove("speech.mp3")
|
|
||||||
|
|
||||||
def say_text(text, voice_index=0):
|
def say_text(text, voice_index=0):
|
||||||
if not cfg.elevenlabs_api_key:
|
if not cfg.elevenlabs_api_key:
|
||||||
gtts_speech(text)
|
macos_tts_speech(text, voice_index)
|
||||||
else:
|
else:
|
||||||
success = eleven_labs_speech(text, voice_index)
|
success = eleven_labs_speech(text, voice_index)
|
||||||
if not success:
|
if not success:
|
||||||
gtts_speech(text)
|
macos_tts_speech(text, voice_index)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user