# Speech to sign

## POST /v1/speech-to-sign/realtime

A playlist of short sign clips to play back to back. **Price:** Speech→Sign rate
(currently $0.33 per minute of sign video produced; minimum $0.01 per call).
Idempotent with `Idempotency-Key`.

Request: [shared sign request fields](#shared-sign-request-fields).

**Audio input.** Instead of `text`, send `multipart/form-data` with an `audio` file
(WAV, MP3, FLAC, OGG, M4A/AAC, WebM or MP4 audio; at most **10 minutes** and **25 MB**,
checked from the file's content). The audio is transcribed and then signed. You are
charged the Speech→Sign rate for the **measured audio length**, and the response adds
`input: "audio"` and `transcript`. Optional form field `spokenLanguage` (BCP-47, default
`en-US`); the other shared fields work as form fields too. Errors: `400 invalid_file`,
`413 file_too_large`, `413 audio_too_long`, `422 no_speech` (nothing charged),
`502 transcription_failed`.

```bash
curl https://api-staging.talksign.co/v1/speech-to-sign/realtime \
  -H "Authorization: Bearer $TALKSIGN_KEY" \
  -F audio=@question.mp3 -F avatar=arthur
```

Response `data`:

| Field | Type | Notes |
|---|---|---|
| `language` | string | Sign language used. |
| `avatar` | string | Avatar used (may be `arthur` with a `notice`, see above). |
| `text` | string | Trimmed input. |
| `glosses` | string[] | Gloss tokens in signing order. |
| `playlist` | Clip[] | One entry per clip, in order (below). |
| `idle` | object \| null | `{ url, expires_at }`: the avatar's rest-pose loop to play between sentences. `null` if the avatar has none. |
| `expires_at` | string (ISO 8601) | Every URL in this response works until at least this time: 6 to 12 hours after the call. |
| `transition` | object | Default transition `{ effect, duration_ms }`. |
| `has_missing` | boolean | `true` when a word had no clip (its `url` is `null`). |
| `notice`, `requested_avatar` | string | Only when a fallback avatar was used. |
| `model_notice` | string | Only when the engine reports a model notice. |

Clip fields:

| Field | Type | Notes |
|---|---|---|
| `gloss` | string | Sign word, e.g. `HELLO`. |
| `url` | string \| null | Main clip (signed URL). |
| `in_url` | string \| null | Neutral pose → sign start. `null` together with `out_url` when the avatar has no transition clips. |
| `out_url` | string \| null | Sign end → neutral pose. |
| `active_start_s`, `active_end_s` | number \| null | Play `url` only between these seconds when using in/out clips. |
| `in_out_speed` | number \| null | Playback rate for `in_url`/`out_url` (e.g. `1.5`); `null` = 1.0. |
| `alphaUrl` | string \| null | Optional matte of `url` (colour and mask side by side) for transparent backgrounds. |
| `in_alpha_url`, `out_alpha_url` | string \| null | Mattes of `in_url` / `out_url`. |
| `group` | integer \| string \| null | Clips of one fingerspelled word share a group. |
| `letter` | string \| null | The letter for a fingerspelled clip. |
| `tier` | string | How the gloss matched a clip (e.g. `TIER_1_EXACT`, `TIER_2_SYNONYM`, `TIER_3_FINGERSPELLING`). Informational. |
| `transition` | object | Suggested `{ effect, duration_ms }` to the next clip when not using in/out clips. |

Play order per word: `in_url` → `url[active_start_s..active_end_s]` → `out_url`; loop
`idle.url` between sentences. See "Quickstart".

Errors: `400 invalid_request` (missing `text`, unknown `model`), `402`, `403`, `404`,
`409`, `413 text_too_long`, `422`, `429`, `503 service_unavailable`.

Test mode: sample playlist built from the words of `text` (sample clip URLs, `idle: null`,
`expires_at` = when the sample links expire, 1 hour). Coming-soon avatars still return `409`.

## POST /v1/speech-to-sign/studio

Renders one downloadable MP4 (every word as in → active → out, no cuts).
**Price:** Sign Video rate (currently $1.32 per minute of rendered video; minimum $0.01).
Funds for up to twice the spoken-length estimate are reserved, the unused part is released.
Idempotent with `Idempotency-Key`.

Request: [shared sign request fields](#shared-sign-request-fields).

Response `data`:

| Field | Type | Notes |
|---|---|---|
| `videoUrl` / `video_url` | string | `https://api-staging.talksign.co/v1/speech-to-sign/video/{requestId}`. Needs your key to download. |
| `download_url` | string \| null | Signed link to the MP4, valid for **1 hour**. Works directly in `<video src>` or a browser download (no key needed). `null` if the link could not be made; use `video_url`. |
| `expires_at` | string \| null | ISO 8601 time `download_url` stops working. |
| `requestId` | string \| null | Render id. |
| `durationSeconds` | number | Billed length. |
| `avatar`, `language` | string | As used. |
| `notice`, `requested_avatar`, `model_notice` | string | As for realtime. |

Rendered videos are kept for **7 days**, then deleted. Download and host them yourself if
you need them longer.

Errors: as realtime. Test mode: a `req_test_…` id whose video redirects to a sample clip;
`download_url` is a sample clip link.

## POST /v1/speech-to-sign/gloss

Gloss tokens only (e.g. AR glasses HUDs). **Price:** Speech→Sign rate on the
spoken-length estimate of `text` (≈ 2.5 words per second; minimum $0.01).
Idempotent with `Idempotency-Key`.

Request: `text` (string, required, ≤ 5,000 chars), `language` (`asl` default | `bsl`).

Response `data`: `text`, `language`, `gloss` (space-separated string), `glosses`
(string[]), `proper_nouns` (string[]).

Errors: `400`, `402`, `413`, `429`, `503`. Test mode: deterministic sample gloss.

## POST /v1/speech-to-sign

Convenience endpoint. Same request as realtime plus `mode`: `realtime` (default),
`studio` or `render`. Behaves exactly like `/realtime` or `/studio` and is billed at
that endpoint's price. Idempotent with `Idempotency-Key`.

## GET /v1/speech-to-sign/video/{requestId}

Streams the MP4 of a studio render (`Content-Type: video/mp4`). Free. Supports HTTP Range
requests: `Range: bytes=0-1023` answers `206 Partial Content` with `Content-Range`
(an invalid range answers `416`), so video players can seek. Only the account that
rendered it can download it; anyone else gets `404 not_found`. Videos are kept for
**7 days**; download them and host them yourself if you need them longer.
Test mode: `req_test_…` ids redirect (`302`) to a sample clip.
