Skip to navigation

The Gen2 model has been decommissioned for streaming. Use our latest Falcon 2.1 model instead.

Murf TTS API supports real-time streaming capabilities, allowing developers to generate and play text-to-speech (TTS) audio dynamically as it is being generated in real-time, reducing the time-to-first-byte. This ensures minimal latency, making it ideal for conversational AI, real-time applications, and voice-enabled assistants.

New: Pass model = falcon-2.1 to use our Falcon 2.1 model in text-to-speech streaming endpoints, designed for ultra-low latency (~100 ms).

In addition to HTTP streaming endpoint, Murf TTS supports Websocket streaming which enables bidirectional streaming for real-time audio generation.

Quickstart

Streaming enables returning raw audio bytes (e.g., MP3 data) directly over HTTP using chunked transfer encoding. This allows clients to process or play audio incrementally as it is generated. This section focuses on how streaming works for requests made to the Text to Speech API.

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.

2

Initiating a Streaming Request

Install the Python SDK and PyAudio

pyaudio depends on PortAudio, you may need to install it first.

PyAudio depends on PortAudio, a cross-platform audio I/O library. You may need to install PortAudio separately if it’s not already on your system.

brew install portaudio

Once you have installed PortAudio, you can install the required Python packages using the following command:

pip install murf pyaudio

Make the API Call with Real-Time Playback

Once you have the SDK and PyAudio installed, and the API key set as an environment variable, you are ready to make your first streaming API call with real-time audio playback.

import pyaudio
from murf import Murf, MurfRegion
client = Murf(
api_key="YOUR_API_KEY", # Not required if you have set the MURF_API_KEY environment variable
region=MurfRegion.GLOBAL
)
# For lower latency, specify a region closer to your users
# client = Murf(region=MurfRegion.IN) # Example: India region
# Audio format settings (must match your API output)
SAMPLE_RATE = 24000
CHANNELS = 1
FORMAT = pyaudio.paInt16
def play_streaming_audio():
# Get the streaming audio generator
audio_stream = client.text_to_speech.stream(
text="Hi, How are you doing today?",
voice_id="Gordon",
model="falcon-2.1",
locale="en-US",
sample_rate=SAMPLE_RATE,
format="PCM"
)
# Setup audio stream for playback
pa = pyaudio.PyAudio()
stream = pa.open(format=FORMAT, channels=CHANNELS, rate=SAMPLE_RATE, output=True)
try:
print("Starting audio playback...")
for chunk in audio_stream:
if chunk: # Check if chunk has data
stream.write(chunk)
except Exception as e:
print(f"Error during streaming: {e}")
finally:
stream.stop_stream()
stream.close()
pa.terminate()
print("Audio streaming and playback complete!")
if __name__ == "__main__":
play_streaming_audio()

Voices

Pick a voice from the Falcon 2.1 list in the Voice Library. Falcon 2.1 voices are for realtime agents.

Endpoint & Concurrency Overview

Endpoint baseConcurrency cap
https://global.api.murf.ai/v1/speech/stream5 (if nearest server is US-East) / 2 (all other regions)
https://<region>.api.murf.ai/v1/speech/stream (see regions below)5 for US-East / 2 for all other regions

The Global Router picks the nearest region for each request. The concurrency limit is 5 for US-East and 2 for all other regions. Every response names the region that served it and your current usage in X-Murf-* headers; see Check your usage. For a higher limit, use the US-East endpoint directly or contact us to raise limits for regional endpoints.

Available Regions

Use the region closest to your users for the lowest latency.

Region (City/Area)Endpoint
Global (Routes to the nearest server)https://global.api.murf.ai/v1/speech/stream
US-Easthttps://us-east.api.murf.ai/v1/speech/stream
US-Westhttps://us-west.api.murf.ai/v1/speech/stream
Indiahttps://in.api.murf.ai/v1/speech/stream
Canadahttps://ca.api.murf.ai/v1/speech/stream
South Koreahttps://kr.api.murf.ai/v1/speech/stream
UAEhttps://me.api.murf.ai/v1/speech/stream
Japanhttps://jp.api.murf.ai/v1/speech/stream
Australiahttps://au.api.murf.ai/v1/speech/stream
EU (Central)https://eu-central.api.murf.ai/v1/speech/stream
UKhttps://uk.api.murf.ai/v1/speech/stream
South America (São Paulo)https://sa-east.api.murf.ai/v1/speech/stream

FAQs

Falcon 2.1 is our fastest streaming model (~100 ms latency) optimized for real-time interactions.

Use Falcon 2.1 when your top priority is ultra-low latency. Typical fits include: - Conversational agents & live support where snappy turn-taking matters. - Real-time apps (IVR, gaming, tutoring, assistive tech) that stream audio as users speak. - Interruptible/barge-in experiences and interactive demos or prototyping.

Pass model: falcon-2.1 in your request (HTTP or WebSocket). If omitted, the API defaults to falcon-2.1.

You can control voice, locale, speed, and pitch. Falcon 2.1 style is Conversational only; style control is on Styles. You can also set how words are pronounced, with IPA in your text ("/mɜːrf/") or with pronunciationDictionary.

HTTP streaming returns MP3, FLAC, WAV, ALAW, ULAW, OGG, or PCM. Inline Base64 audio is available on Synthesize, not on HTTP streaming.