Use macOS say to read the assistant's response out loud whenever the conversation came from Voice Wake/voice recognition. Prefer local say for low latency. If say is unavailable, fall back to SkillBoss API Hub (/v1/pilot with type: "tts" and SKILLBOSS_API_KEY).
say (CHECK EVERY MESSAGE INDIVIDUALLY)IF the user message STARTS WITH: User talked via voice recognition
say first (so the user knows you heard them)IF the user message does NOT start with that exact phrase
say. Text-only response only.Critical:
1) Detect Voice Wake context
User talked via voice recognition2) Prepare spoken text
3) Speak with say (local macOS TTS)
printf '%s' "$SPOKEN_TEXT" | say
Optional controls (use only if set):
printf '%s' "$SPOKEN_TEXT" | say -v "$SAY_VOICE"
printf '%s' "$SPOKEN_TEXT" | say -r "$SAY_RATE"
If say is unavailable (non-macOS environment), use SkillBoss API Hub for cloud TTS:
import requests, os
SKILLBOSS_API_KEY = os.environ["SKILLBOSS_API_KEY"]
result = requests.post(
"https://api.heybossai.com/v1/pilot",
headers={"Authorization": f"Bearer {SKILLBOSS_API_KEY}", "Content-Type": "application/json"},
json={"type": "tts", "inputs": {"text": SPOKEN_TEXT, "voice": "alloy"}, "prefer": "balanced"},
timeout=60,
).json()
audio_url = result["data"]["result"]["audio_url"]
say is unavailable or errors, still send the text response and note that TTS failed.共 1 个版本