02-ago: [proyecto] vigilancia - apagado de la tele via Alexa (VoiceMonkey monkey) tras el anuncio + audio local confirmado funcionando
This commit is contained in:
@@ -46,6 +46,27 @@ def enviar_texto_telegram(texto: str, chat_id=None):
|
||||
print(f"[Telegram] Excepción al enviar: {e}")
|
||||
|
||||
|
||||
def disparar_monkey_alexa(monkey: str, speech: str = ""):
|
||||
if not config.ALEXA_NOTIFY_SCRIPT or not monkey:
|
||||
return
|
||||
env = os.environ.copy()
|
||||
if config.VOICEMONKEY_TOKEN:
|
||||
env["VOICEMONKEY_TOKEN"] = config.VOICEMONKEY_TOKEN
|
||||
if config.VOICEMONKEY_DEVICE:
|
||||
env["VOICEMONKEY_DEVICE"] = config.VOICEMONKEY_DEVICE
|
||||
cmd = [config.ALEXA_NODE, config.ALEXA_NOTIFY_SCRIPT, "--monkey", monkey]
|
||||
if speech:
|
||||
cmd.append(speech)
|
||||
try:
|
||||
r = subprocess.run(
|
||||
cmd, env=env, timeout=15, capture_output=True, text=True,
|
||||
)
|
||||
if r.returncode != 0:
|
||||
print(f"[Alexa] Error monkey: {r.stderr[:200]}")
|
||||
except Exception as e:
|
||||
print(f"[Alexa] Excepción lanzando monkey: {e}")
|
||||
|
||||
|
||||
def disparar_webhook_alexa(texto: str):
|
||||
if config.ALEXA_NOTIFY_SCRIPT:
|
||||
env = os.environ.copy()
|
||||
|
||||
Reference in New Issue
Block a user