# SSML text to speech API

A prompt library written in SSML sets its pauses, speaking styles, and timing marks by hand, and a speech API that reads only plain text loses all of it.

Paxa TTS Flash v2 reads a subset of SSML 1.1 with Azure's mstts extensions. Send the document in the ssml field of POST /v1/tts or as a frame on the live socket, and every voice speaks it in English, Thai, and Mandarin.

## One greeting, two ways to send it

The SSML guide's Thai support-line greeting carries a style, breaks, and a mark. Over HTTP it goes in the ssml field of POST /v1/tts, and on the live socket in an ssml frame. The response reports any markup it did not read as written and gives the time of each mark.

## Send SSML in three steps

Prompts written as SSML for Azure AI Speech send as they are once each voice name is a Paxa voice id. The request is the one you send for plain text, with the document in place of the text.

1. **Name a Paxa voice**: Set each voice element's name to a voice id from GET /v1/voices. The request's voice field speaks any text outside every voice element.
2. **Send it over HTTP**: Post the document as ssml to POST /v1/tts in place of text, with model set to paxa-tts-flash-v2. Streaming and word timestamps work as they do on text.
3. **Or drop it into a live call**: On WS /v1/tts/live or WS /v1/tts/multi, send a frame of type ssml. The document speaks after any text already buffered and bills into the connection's total, and the socket sends report and mark events.

Paxa TTS Flash v2 lists at $10 per 1M characters. A document bills for the text it compiles to at that rate, a short break between words included, since it compiles to a pause tag. Silence between speech items, clips, and background audio bill nothing, and marks never change the charge. Word timestamps bill the request at 1.25 times. [The SSML guide](https://paxalabs.com/docs/ssml#billing) prices a sample document.

## Questions

### Which SSML elements does Paxa read?

Paxa TTS Flash v2 reads a subset of SSML 1.1 with Azure's `mstts` extensions. `voice` takes a Paxa voice id. `break`, `mstts:silence`, `prosody` with rate, pitch, range, and volume, and `emphasis` shape the delivery. `mstts:express-as` reads 34 styles. `mark` and `mstts:bookmark` place timed marks. `audio` plays a clip by URL and reads its fallback content when the clip does not play, and `mstts:backgroundaudio` lays a recording under the speech. `p`, `s`, and `sub` read too. [The SSML guide](https://paxalabs.com/docs/ssml#elements) states what each one does.

### Which elements are dropped?

`say-as`, `phoneme`, `lexicon`, `lang`, `w`, `token`, and `lookup` are dropped. Their text reads as written, and the report lists each one. Write a date, an amount, or a code as it should be spoken, or give it a `sub` alias. Every voice speaks English, Thai, and Mandarin. A change of language needs no `lang` element.

### Does SSML written for Azure AI Speech work?

It does once each voice name is a Paxa voice id. Azure voice names do not map to Paxa voices, and a name the API does not serve answers 400 `unknown_voice`. [Migrate from Azure](https://paxalabs.com/docs/ssml#azure) lists every other change.

### Can a voice agent speak SSML mid-call?

Yes. Send `{"type":"ssml","ssml":"<speak>...</speak>"}` on [the live socket](https://paxalabs.com/docs/live-streaming) or [the multiplexed socket](https://paxalabs.com/docs/multiplexing). The document speaks as one leg after any buffered text and bills into the connection's total, and the socket sends `report` and `mark` events. An agent streams model text and drops a scripted prompt, such as a required disclosure, into the same call.

### What are the limits?

The text a document compiles to holds up to 5,000 characters buffered and 20,000 streamed, as plain text does. A document holds up to 200 marks, and one break plays up to 20 seconds. A document the API cannot read answers 400 `ssml_invalid` before any charge, with the element's path, line, and column.

## Start with free credits

Sign in with Google, GitHub, or Hugging Face and spend 100 one-time free credits on your own text.
