Skip to main content

TTS — Make the Speaker Talk

WhatWhere
Route moduleos/hal/routes/voice.py
POST /voice/speak — one-shot say (interrupts current speech)def speak_text(req: SpeakRequest)
POST /voice/speak-queue — say after current speech finishesdef speak_queue_text(req: SpeakRequest)
POST /tts/stop — cut off the currently-playing sentencedef stop_tts()
SpeakRequest schema (text, voice, provider, interruptible, cached…)os/hal/models.py
# Fire-and-forget say
curl -X POST http://127.0.0.1:5001/voice/speak \
-H 'Content-Type: application/json' \
-d '{"text": "Hello from the device"}'

# Queue behind any in-flight speech (e.g. multi-turn narration)
curl -X POST http://127.0.0.1:5001/voice/speak-queue \
-H 'Content-Type: application/json' \
-d '{"text": "…and that concludes the update."}'

# Interrupt whatever is playing right now
curl -X POST http://127.0.0.1:5001/tts/stop

Call it from inside HAL Python:

from hal.models import SpeakRequest
from hal.routes.voice import speak_text

speak_text(SpeakRequest(text="Hello", voice="Rachel", interruptible=False))