{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://jambonz.org/schema/callbacks/tts-streaming-event",
  "title": "TTS Streaming Event",
  "description": "Events sent to the '/streaming-event' WebSocket endpoint during TTS streaming. These are sent as 'tts:streaming-event' messages. The tts_spoken event is only sent when trackTtsPlayout is enabled via the config verb.",
  "type": "object",
  "oneOf": [
    {
      "properties": {
        "event_type": {
          "const": "stream_open",
          "description": "The TTS streaming connection has been established."
        }
      },
      "required": ["event_type"],
      "additionalProperties": false
    },
    {
      "properties": {
        "event_type": {
          "const": "stream_closed",
          "description": "The TTS streaming connection has been closed."
        }
      },
      "required": ["event_type"],
      "additionalProperties": false
    },
    {
      "properties": {
        "event_type": {
          "const": "stream_paused",
          "description": "TTS streaming has been paused."
        }
      },
      "required": ["event_type"],
      "additionalProperties": false
    },
    {
      "properties": {
        "event_type": {
          "const": "stream_resumed",
          "description": "TTS streaming has been resumed."
        }
      },
      "required": ["event_type"],
      "additionalProperties": false
    },
    {
      "properties": {
        "event_type": {
          "const": "user_interruption",
          "description": "The user interrupted (barged in) during TTS playout, causing the stream to be cleared."
        }
      },
      "required": ["event_type"],
      "additionalProperties": false
    },
    {
      "properties": {
        "event_type": {
          "const": "tts_spoken",
          "description": "Reports the actual text that was spoken via TTS. Sent on utterance completion or when the user barges in. Only sent when trackTtsPlayout is enabled via the config verb. Requires a TTS vendor that supports alignment data (e.g. ElevenLabs)."
        },
        "text": {
          "type": "string",
          "description": "The text that was actually spoken before completion or interruption."
        },
        "bargein": {
          "type": "boolean",
          "description": "True if the user barged in (interrupted) before the TTS finished speaking. False if the utterance completed normally."
        }
      },
      "required": ["event_type", "text", "bargein"],
      "additionalProperties": false
    }
  ]
}
