Concepts

The turn contract

The shape every transcript takes in Sparkle, and the four rules that make sending it safe.

There is no standard transcript format, so Sparkle defines one. A turn is one stretch of one person speaking. The receivers turn a vendor's payload into turns for you; when you post your own, each turn looks like this:

{
  "id": "t_812",
  "final": true,
  "speaker": "spk_2",
  "name": "Dana",
  "channel": "remote",
  "start": 778.2,
  "end": 781.0,
  "text": "I'll get the SSO fix out by Friday."
}
FieldTypeMeaning
idstringYour ID for the turn, up to 255 characters. Moments name the turns they read by it, in turn_ids.
finalbooleanWhether the turn is finished. Partial turns are stored but never detected on.
speakerstringA stable key for who is speaking: the same key is the same person, for the whole conversation.
namestring, optionalThe speaker's name, when you know it.
channelmic or remotemic for whoever runs the capture, remote for everyone else.
start, endnumberSeconds from the conversation's started_at.
textstringWhat was said.

Send up to 500 turns per request to POST /conversations/{id}/turns. Sparkle answers 202 with no body once it has stored them.

The four rules

The same id replaces

Sending a turn again under the same id replaces it, so a correction or a growing partial never becomes a second turn. Each replacement adds one to the stored turn's revision.

Only final turns reach detection

Speech-to-text sends partial results while someone talks. Send them if you want them stored, with "final": false, then send the finished version under the same id with "final": true. Sparkle reads a turn the first time it arrives final, and only then. The partial:

{
  "id": "t_812",
  "final": false,
  "speaker": "spk_2",
  "channel": "remote",
  "start": 778.2,
  "end": 779.6,
  "text": "I'll get the SSO"
}

Then the final version, which replaces it:

{
  "id": "t_812",
  "final": true,
  "speaker": "spk_2",
  "channel": "remote",
  "start": 778.2,
  "end": 781.0,
  "text": "I'll get the SSO fix out by Friday."
}

This is also what makes retries safe: a batch sent twice reads each final turn once.

Order doesn't matter

Within a batch, Sparkle sorts turns by start before reading them. Batches are read in the order they arrive, so a turn that arrives late is still read, after the ones already sent.

Speaker is a key, name is a fact

speaker says which person is talking; name says who that person is, when you know. Use whatever key your speech-to-text gives you (spk_2, a participant ID, a channel number) and keep it the same for the same person. Add name when a roster or a sign-in tells you, even partway through the call. A moment carries both, as speaker.key and speaker.name.

Send turns

Send turns as they finish, every second or two, or in larger batches if you buffer. The sooner a final turn arrives, the sooner its moment can.

@sparkle/sdk is in private beta

The TypeScript tabs use @sparkle/sdk, which isn't on npm yet. To try it, ask us for access. Python and Go have no SDK yet: the cURL, Python and Go tabs call the HTTP API directly.

curl https://api.sparkle.ai/public/v1/conversations/$CONVERSATION_ID/turns \
  -H "X-API-Key: $SPARKLE_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "turns": [
      {
        "id": "t_812",
        "final": true,
        "speaker": "spk_2",
        "name": "Dana",
        "channel": "remote",
        "start": 778.2,
        "end": 781.0,
        "text": "I'\''ll get the SSO fix out by Friday."
      }
    ]
  }'

Consecutive turns from the same speaker are read together, so splitting a long stretch of speech into several turns is fine. A moment's text is the turns it read, merged, and turn_ids lists them all.

On this page