Skip to navigation

Synthesize or non-streaming (Gen2)

Synthesize (Gen 2) sends the full text in one request and returns a file URL when generation finishes. Use it for studio voiceover: ads, narration, e-learning, and other offline playback where you need styles, pause tags, audio duration, or variations.

Pass modelVersion: "GEN2" in the request. Host is https://api.murf.ai. Do not send Synthesize calls to the streaming host.

Use HTTP streaming when you need audio chunks in real time, or WebSocket when text arrives in pieces.

Quickstart

Generate an audio file from text with POST /v1/speech/generate. The response includes a link to the file. The file remains available for 72 hours.

1

Getting Started

Generate an API key here. Store the key in a secure location, as you’ll need it to authenticate your requests. You can optionally save the key as an environment variable in your terminal.

# Export an environment variable on macOS or Linux systems
export MURF_API_KEY="your_api_key_here"
2

Initiating a Synthesize Request

Install the Python SDK

pip install murf

Make the API call

Python SDK
from murf import Murf
client = Murf()
res = client.text_to_speech.generate(
text="There is much to be said",
voice_id="Terrell",
locale="en-US",
model_version="GEN2",
)
print(res.audio_file)

A link to the audio file is returned in the response. Download it and use it wherever you need it. The file is available for 72 hours after generation.

Voices

Pick a voice from the Gen 2 list in the Voice Library. Gen 2 has 150+ voices and 20+ speaking styles. Gen 2 voices are for studio voiceover.

Endpoint

https://api.murf.ai/v1/speech/generate

Each in-flight generate request counts toward Synthesize (Gen 2) concurrency. A request can include up to 3,000 characters. Split longer scripts across multiple calls.

The machine-readable request and response are in the Synthesize Speech API reference.

Speech customization

Voice, locale, speed, and pitch are available. Style control, custom pause tags, audio duration, and variations are Synthesize (Gen 2) only. Set pronunciations with pronunciationDictionary.

See Speech Customization for ranges and samples.

Supported output formats

The default output format is WAV. Set format, channelType, and sampleRate in the request. The API supports stereo and mono, and sample rates of 8000, 24000, 44100, and 48000 Hz.

FormatDescription
WAVUncompressed audio, useful when you want to skip decoding.
MP3Compressed audio, widely supported when file size matters.
FLACLossless compressed audio.
ALAWTelephony format.
ULAWTelephony format.
OGGCompressed format for web playback.
PCMRaw, uncompressed samples.
from murf import Murf
client = Murf()
res = client.text_to_speech.generate(
text="Hi, How are you doing today?",
voice_id="Julia",
locale="en-US",
model_version="GEN2",
format="MP3",
channel_type="STEREO",
sample_rate=44100,
)
print(res.audio_file)

ULAW and ALAW formats only support mono channel type and a sample rate of 8000 Hz. If you specify a different channel type or sample rate, the API will default to the supported values.

Base64 encoding

Base64 encoding is Synthesize (Gen 2) only. Set encodeAsBase64 to true to receive the audio inline instead of a file URL. That also enables zero retention of audio data on Murf’s servers.

from murf import Murf
client = Murf()
res = client.text_to_speech.generate(
text="Hi, How are you doing today?",
voice_id="Julia",
model_version="GEN2",
encode_as_base_64=True,
)
print(res.encoded_audio)

The response includes the audio encoded in Base64:

Response
{
...,
"encodedAudio": "U29tZSB0ZXh0IHNob3cgd2l0aCB0aGF0Lg==...",
...
}

gzip

gzip is Synthesize (Gen 2) only. Include gzip in the accept-encoding header. This is especially useful with Base64 audio.

from murf import Murf
client = Murf()
client.text_to_speech.generate(
text="Hi, How are you doing today?",
voice_id="Natalie",
model_version="GEN2",
encode_as_base_64=True,
request_options={
"additional_headers": {
"accept-encoding": "gzip"
}
},
)

Next Steps

FAQs

Gen 2 is Murf’s studio text-to-speech model. It returns a file URL from Synthesize Speech and supports 150+ voices and 20+ speaking styles. See the Gen 2 model page.

Use Synthesize when you want a finished file for ads, narration, e-learning, or other offline playback, and when you need styles, pause tags, audio duration, or variations. Use HTTP streaming or WebSocket for realtime agents.

Pass modelVersion: "GEN2" (Python SDK: model_version="GEN2") on POST /v1/speech/generate.

Voice, locale, speed, and pitch are available, plus styles, custom pause tags, audio duration, variations, and pronunciationDictionary. See Speech Customization.

Synthesize returns MP3, FLAC, WAV, ALAW, ULAW, OGG, or PCM. Inline Base64 audio and gzip are Synthesize only.

The returned URL stays available for 72 hours after generation. Use Base64 encoding if you need the audio inline with no object-storage retention.