Streaming

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.

In addition to HTTP streaming endpoint, Murf TTS will soon support 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

1# pip install murf
2from murf import Murf
3
4client = Murf(
5 api_key="YOUR_API_KEY", # Not required if you have set the environment variable MURF_API_KEY
6)
7
8res = client.text_to_speech.stream(
9 text="Hi, how can I help you this fine day?",
10 voice_id="en-US-natalie"
11)
12
13for audio_chunk in res:
14 with open("stream_output.wav", "ab") as f:
15 f.write(audio_chunk)

In the response, you will receive a stream of audio data. You can save this data to a file or play it directly using an audio library.

FAQs

Yes, we support tags to control voice styles, pitch and pauses.

No, streaming TTS is priced the same as TTS. It is billed per character.

Yes. For streaming, concurrency for free and PAYG plan is limited to one. We provide custom concurrency for enterprise plans. Contact sales for scaling needs.

All the voices and languages supported in TTS are available via streaming. A full list is available in our docs.

It supports wav and mp3 formats.