Generate speech

View as Markdown
Converts text to WAV or raw PCM audio.

Authentication

AuthorizationBearer
A Nari API key created in the Dashboard.

Request

This endpoint expects an object.
modelenumRequired

Select Standard or Fast. Append :free for Free access.

inputstringRequired>=1 character

Complete text. Surrounding whitespace is removed, then the result must contain 1–2,048 Unicode code points.

Use normal capitalization and punctuation; all-lowercase or unpunctuated text can severely degrade speech quality.

voiceenumOptionalDefaults to english_female_professional

The voice used to generate speech.

languageenumOptionalDefaults to auto

Language of the selected voice. Currently supports en. auto uses the voice’s language, rather than detecting the input language.

streambooleanOptionalDefaults to false

false returns audio after generation finishes; true sends audio as it is generated. Send the complete text in one request in either mode.

response_formatenumOptionalDefaults to wav

wav includes a WAV header; pcm returns raw audio samples. Both formats support streaming.

Response headers

x-usage-input-charactersinteger
Input characters counted as Unicode code points after trimming surrounding whitespace, before text normalization.
x-request-idstringOptional
Canonical identifier for the request. Include it when contacting support.

Response

Binary audio containing 24 kHz, signed 16-bit little-endian, mono samples. The content type is `audio/wav` for WAV or `audio/pcm` for raw PCM. Example response for `input: "Hello."` and `response_format: "wav"` (schematic): ```http HTTP/1.1 200 OK Content-Type: audio/wav x-request-id: 019c2e72-149f-733a-9579-67df595ba0f0 x-usage-input-characters: 6 [binary WAV audio] ``` Streamed WAV starts with an unknown-length header. See [Streaming audio](/streaming-audio) for playback details. A failure after streaming starts interrupts the audio without a JSON error; see [Interrupted streams](/errors#interrupted-streams).

Errors

400
Bad Request Error
401
Unauthorized Error
402
Payment Required Error
403
Forbidden Error
404
Not Found Error
413
Content Too Large Error
429
Too Many Requests Error
500
Internal Server Error
503
Service Unavailable Error