POST
/
v1
/
ai
/
speech
curl --request POST \
  --url https://api.lmnt.com/v1/ai/speech \
  --header 'Content-Type: multipart/form-data' \
  --header 'X-API-Key: <x-api-key>' \
  --form voice=daniel \
  --form 'text=This is a test of LMNT, hello world!' \
  --form format=mp3 \
  --form speed=1.3 \
  --form length=123 \
  --form return_durations=true \
  --form seed=123
{
  "audio": "<string>",
  "durations": [
    {
      "text": "<string>",
      "duration": 123,
      "start": 123
    }
  ],
  "seed": 123
}

Specify either speed or length, not both; otherwise a request with both will result in an 500 server error as the desired speed might not match the desired length.

The output of this POST request is a JSON object from which you must extract and decode the base64-encoded audio data. Here is an example of how to do so in your terminal:

jq -r '.audio' lmnt-output.json | base64 --decode > lmnt-audio-output.mp3

The file format of your audio output depends on the format specified in the inital request (this example assumes format=mp3).

Headers

X-API-Key
string
required

Your API key; get it from your LMNT account page.

Body

multipart/form-data
voice
string
required

The voice id of the voice to use for synthesis; voice ids can be retrieved by calls to List voices or Voice info

text
string
required

The text to synthesize; max 5000 characters per request (including spaces).

format
string

The file format of the synthesized audio output, either acc, mp3, mulaw, raw, wav; defaults to mp3.

speed
number

The talking speed of the generated speech, a floating point value between 0.25 (slow) and 2.0 (fast); defaults to 1.0.

length
number

Produce speech of this length in seconds; maximum 300.0 (5 minutes).

return_durations
string

If set as true, response will contain a durations object; see definition in the response section below.

seed
integer

Seed used to specify a different take; defaults to random (see here for more details).

Response

200 - application/json
audio
string
required

The base64-encoded audio file; the format is determined by the format parameter.

durations
object[]

A JSON object outlining the spoken duration of each synthesized input element (words and non-words like spaces, punctuation, etc.). See an example of this object for the input string "Hello world!"

seed
integer
required

The seed used to generate this speech; can be used to replicate this output take (assuming the same text is resynthsized with this seed number, see here for more details).