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.

<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xmlns:mstts="http://www.w3.org/2001/mstts" xml:lang="th">
  <voice name="khanomkrok">
    <mstts:express-as style="customerservice">สวัสดีครับ ขอบคุณที่โทรหา Paxa Labs</mstts:express-as>
    <break time="300ms"/>
    <prosody rate="-10%">กรุณาถือสายรอสักครู่ เจ้าหน้าที่จะรับสายโดยเร็วที่สุดครับ</prosody>
    <mark name="hold"/>
    <break time="2s"/>
    หากต้องการฟังเมนูอีกครั้ง กด <emphasis>9</emphasis> ครับ
  </voice>
</speak>
x-ssml-report: {"notes":[{"path":"/speak/voice[1]/say-as[1]","code":"ignored"},{"path":"/speak/voice[1]/audio[1]","code":"fallback","reason":"fetch_failed"}]}
x-ssml-marks: {"marks":[{"name":"hold","time":6.412}]}

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 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 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 lists every other change.

Can a voice agent speak SSML mid-call?

Yes. Send {"type":"ssml","ssml":"<speak>...</speak>"} on the live socket or the multiplexed socket. 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.