.f0rge/wiki/docs/capabilities/stt.v1.md 4.3 KiB 119 lines Raw

stt.v1

Status: v1. A published shape is frozen by spec.md section 20.1. Capability key: stt Route: POST /stt

Parts in

One row for each part kind that this capability accepts. A kind that is not in this table is invalid_part.

kindrolerequiredmeaning
audioanyyes, one or morethe audio to transcribe. The mime names its format.
textpromptnoa hint for the transcription. At most one.

Parameters

The plugin validates these. A parameter that is not in this table is ignored, not an error (spec.md R26). A default of none means the plugin decides.

nametypedefaultmeaning
languagestringnonethe language to transcribe
timestampsboolfalseemit timed segments in the terminal metadata

Channels out

One row for each channel that this capability can emit.

channelmimepayload
texttext/plain; charset=utf-8one UTF-8 fragment of the transcript
tokensapplication/cborthe same fragment as token ids: {id, text, t_ms}
progressapplication/json{stage, pct} during decode

Terminal metadata

done.meta is vocabulary-defined. The core stores it and never reads it. done without meta means {}.

keytypemeaning
modelstringthe served name that ran the job
languagestringthe language that the plugin transcribed
duration_msuintthe measured length of the audio, in milliseconds
segmentsarray{start_ms, end_ms, text} for each timed segment

model, language, and duration_ms are present when outcome is completed. They are absent when the outcome is cancelled or expired. segments is absent unless timestamps is true.

Request

POST /stt
{
  "model": "<served-name>",
  "input": [
    {"kind": "audio", "mime": "audio/wav", "inline": "<audio bytes>"},
    {"kind": "text", "role": "prompt", "text": "talks about device memory"}
  ],
  "params": {"language": "en", "timestamps": true},
  "stream": true
}

Response, no stream

{"job": "019...", "outcome": "completed",
 "text": "A ledger records reserved bytes for each device.",
 "usage": {"audio_ms": 4200, "tokens_out": 9},
 "meta": {"model": "<served-name>", "language": "en", "duration_ms": 4200,
          "segments": [{"start_ms": 0, "end_ms": 4200,
                        "text": "A ledger records reserved bytes for each device."}]}}

Stream

event  ch=progress {"stage": "decode", "pct": 0.4}
event  ch=text     "A ledger records"
event  ch=text     " reserved bytes for each device."
done   outcome=completed meta={"model":"<served-name>","language":"en","duration_ms":4200}

Rules

  1. At least one audio part is required. A request with no audio part is invalid_part.
  2. A text part must carry role prompt. A text part with another role, or a second text part, is invalid_part.
  3. An image, video, tokens, or json part is invalid_part.
  4. The plugin accepts the audio formats that it declares. An undeclared mime is invalid_part.
  5. Transcript fragments follow the audio order. Earlier audio produces earlier fragments.
  6. One text event is a whole UTF-8 sequence. A plugin never splits a code point across two events.
  7. A progress event carries {stage, pct}. pct never decreases within one job.
  8. timestamps = false means meta.segments is absent.
  9. When timestamps is true, meta.segments is an array of {start_ms, end_ms, text}.
  10. In every segment, start_ms is not greater than end_ms. Segments follow the transcript order.
  11. The segment text, joined in order, equals the transcript. Nothing is dropped.
  12. language = none leaves the choice to the plugin. meta.language then names the language that the plugin used.
  13. A language value that the plugin does not declare gives a refusal that names language.
  14. meta.duration_ms is measured by the plugin. The client never sets it.
  15. No event follows a cancel. The terminal frame is done with outcome = cancelled.
  16. A tokens event repeats the same fragment that a text event carries. The tokens, joined in order, equal the joined text events. A plugin that cannot give tokens omits the channel.

view raw