> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://murf.ai/api/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://murf.ai/api/docs/_mcp/server.

# Synthesize Speech

POST https://api.murf.ai/v1/speech/generate
Content-Type: application/json

Returns a url to the generated audio file along with other associated properties.

Reference: https://murf.ai/api/docs/api-reference/text-to-speech/generate

## Request

### Headers

- `token` (string, optional)
- `api-key` (string, optional)

### Body (application/json)

This endpoint expects a GenerateSpeechRequest.

- `text` (string, required) — The text that is to be synthesised. e.g. 'Hello there [pause 1s] friend'
- `voiceId` (string, required) — Use the GET /v1/speech/voices API to find supported voiceIds. You can use either the voiceId (e.g. en-US-natalie) or just the voice actor's name (e.g. natalie).
- `audioDuration` (double, optional) — This parameter allows specifying the duration (in seconds) for the generated audio. If the value is 0, this parameter will be ignored. Only available for Gen2 model.
- `channelType` (string, optional, default: MONO) — Valid values: STEREO, MONO
- `encodeAsBase64` (boolean, optional) — Set to true to receive audio in response as a Base64 encoded string instead of a url. This enables zero retention of audio data on Murf's servers.
- `format` (string, optional, default: WAV) — Format of the generated audio file. Valid values: MP3, WAV, FLAC, ALAW, ULAW, PCM, OGG
- `modelVersion` (enum, optional, default: GEN2) — Valid values: GEN2. Audio will be generated using the new and advanced GEN2 model. Outputs from GEN2 sound more natural and high-quality compared to earlier models.
  - Allowed values: `GEN2`
- `locale` (string, optional) — Specifies the language for the generated audio, enabling a voice to speak in multiple languages natively. Only available in the Gen2 model. Valid values: "en-US", "en-UK", "es-ES", etc. Use the GET /v1/speech/voices endpoint to retrieve the list of available voices and languages.
- `pitch` (integer, optional) — Pitch of the voiceover
- `pronunciationDictionary` (map from string to PronunciationDetail, optional) — An object used to define custom pronunciations. Example: pronunciation\_dictionary=\{ "live": \{ "type": "IPA", "pronunciation": "laɪv" }, "2010": \{ "type": "SAY\_AS", "pronunciation": "two thousand and ten" } }
- `rate` (integer, optional) — Speed of the voiceover
- `sampleRate` (double, optional, default: 44100) — Valid values are 8000, 24000, 44100, 48000
- `style` (string, optional) — The voice style to be used for voiceover generation.
- `variation` (integer, optional, default: 1) — Higher values will add more variation in terms of Pause, Pitch, and Speed to the voice. Only available for Gen2 model.
- `wordDurationsAsOriginalText` (boolean, optional, default: false) — If set to true, the word durations in response will return words as the original input text. (English only)
- `multiNativeLocale` (string, optional, deprecated) — This field is superseded by `locale` field. Please migrate to `locale` field to ensure compatibility with future API versions. Specifies the language for the generated audio, enabling a voice to speak in multiple languages natively. Only available in the Gen2 model. Valid values: "en-US", "en-UK", "es-ES", etc. Use the GET /v1/speech/voices endpoint to retrieve the list of available voices and languages.

## Response

### 200

Ok

- `audioFile` (string, required)
- `audioLengthInSeconds` (double, required)
- `remainingCharacterCount` (long, required) — Remaining number of characters available for synthesis in the current billing cycle.
- `wordDurations` (list of WordDurationResponse, required)
- `encodedAudio` (string, optional)
- `warning` (string, optional)
- `consumedCharacterCount` (long, optional, deprecated) — Number of characters consumed so far in the current billing cycle.

## Errors

### 400 Bad Request Error

Bad Request

- `any`

### 402 Payment Required Error

Expired subscription or character limit exhausted

- `any`

### 403 Forbidden Error

Invalid or expired token/api-key provided

- `any`

### 500 Internal Server Error

Internal Server Error

- `any`

### 503 Service Unavailable Error

Service Unavailable

- `any`

## Types

### PronunciationDetail

Defines a custom pronunciation with `type` (IPA or SAY_AS) and `pronunciation`.

- `pronunciation` (string, optional)
- `type` (enum, optional)
  - Allowed values: `IPA`, `SAY_AS`

### WordDurationResponse

- `endMs` (integer, optional)
- `startMs` (integer, optional)
- `word` (string, optional)
- `pitchScaleMaximum` (double, optional, deprecated) — This field has been deprecated.
- `pitchScaleMinimum` (double, optional, deprecated) — This field has been deprecated.
- `sourceWordIndex` (integer, optional, deprecated) — This field has been deprecated.

## Examples

### Basic

**Request**

```json
{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "locale": "en-US"
}
```

**Response**

```json
{
  "audioFile": "string",
  "audioLengthInSeconds": 1.1,
  "remainingCharacterCount": 1,
  "wordDurations": [
    {
      "endMs": 1,
      "startMs": 1,
      "word": "string",
      "pitchScaleMaximum": 1.1,
      "pitchScaleMinimum": 1.1,
      "sourceWordIndex": 1
    }
  ],
  "encodedAudio": "string",
  "warning": "string",
  "consumedCharacterCount": 1
}
```

**SDK Code**

```python Basic
import requests

url = "https://api.murf.ai/v1/speech/generate"

payload = {
    "text": "Hi, How are you doing today?",
    "voiceId": "Natalie",
    "locale": "en-US"
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Basic
const url = 'https://api.murf.ai/v1/speech/generate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"text":"Hi, How are you doing today?","voiceId":"Natalie","locale":"en-US"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Basic
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.murf.ai/v1/speech/generate"

	payload := strings.NewReader("{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Basic
require 'uri'
require 'net/http'

url = URI("https://api.murf.ai/v1/speech/generate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\"\n}"

response = http.request(request)
puts response.read_body
```

```java Basic
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.murf.ai/v1/speech/generate")
  .header("Content-Type", "application/json")
  .body("{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\"\n}")
  .asString();
```

```php Basic
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.murf.ai/v1/speech/generate', [
  'body' => '{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "locale": "en-US"
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Basic
using RestSharp;

var client = new RestClient("https://api.murf.ai/v1/speech/generate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Basic
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "locale": "en-US"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.murf.ai/v1/speech/generate")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Pronunciation

**Request**

```json
{
  "text": "The 2010 world cup was held in South Africa",
  "voiceId": "Natalie",
  "locale": "en-US",
  "pronunciationDictionary": {
    "2010": {
      "pronunciation": "two thousand and ten",
      "type": "SAY_AS"
    },
    "live": {
      "pronunciation": "laɪv",
      "type": "IPA"
    }
  }
}
```

**Response**

```json
{
  "audioFile": "string",
  "audioLengthInSeconds": 1.1,
  "remainingCharacterCount": 1,
  "wordDurations": [
    {
      "endMs": 1,
      "startMs": 1,
      "word": "string",
      "pitchScaleMaximum": 1.1,
      "pitchScaleMinimum": 1.1,
      "sourceWordIndex": 1
    }
  ],
  "encodedAudio": "string",
  "warning": "string",
  "consumedCharacterCount": 1
}
```

**SDK Code**

```python Pronunciation
import requests

url = "https://api.murf.ai/v1/speech/generate"

payload = {
    "text": "The 2010 world cup was held in South Africa",
    "voiceId": "Natalie",
    "locale": "en-US",
    "pronunciationDictionary": {
        "2010": {
            "pronunciation": "two thousand and ten",
            "type": "SAY_AS"
        },
        "live": {
            "pronunciation": "laɪv",
            "type": "IPA"
        }
    }
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Pronunciation
const url = 'https://api.murf.ai/v1/speech/generate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"text":"The 2010 world cup was held in South Africa","voiceId":"Natalie","locale":"en-US","pronunciationDictionary":{"2010":{"pronunciation":"two thousand and ten","type":"SAY_AS"},"live":{"pronunciation":"laɪv","type":"IPA"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Pronunciation
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.murf.ai/v1/speech/generate"

	payload := strings.NewReader("{\n  \"text\": \"The 2010 world cup was held in South Africa\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\",\n  \"pronunciationDictionary\": {\n    \"2010\": {\n      \"pronunciation\": \"two thousand and ten\",\n      \"type\": \"SAY_AS\"\n    },\n    \"live\": {\n      \"pronunciation\": \"laɪv\",\n      \"type\": \"IPA\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Pronunciation
require 'uri'
require 'net/http'

url = URI("https://api.murf.ai/v1/speech/generate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"text\": \"The 2010 world cup was held in South Africa\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\",\n  \"pronunciationDictionary\": {\n    \"2010\": {\n      \"pronunciation\": \"two thousand and ten\",\n      \"type\": \"SAY_AS\"\n    },\n    \"live\": {\n      \"pronunciation\": \"laɪv\",\n      \"type\": \"IPA\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Pronunciation
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.murf.ai/v1/speech/generate")
  .header("Content-Type", "application/json")
  .body("{\n  \"text\": \"The 2010 world cup was held in South Africa\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\",\n  \"pronunciationDictionary\": {\n    \"2010\": {\n      \"pronunciation\": \"two thousand and ten\",\n      \"type\": \"SAY_AS\"\n    },\n    \"live\": {\n      \"pronunciation\": \"laɪv\",\n      \"type\": \"IPA\"\n    }\n  }\n}")
  .asString();
```

```php Pronunciation
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.murf.ai/v1/speech/generate', [
  'body' => '{
  "text": "The 2010 world cup was held in South Africa",
  "voiceId": "Natalie",
  "locale": "en-US",
  "pronunciationDictionary": {
    "2010": {
      "pronunciation": "two thousand and ten",
      "type": "SAY_AS"
    },
    "live": {
      "pronunciation": "laɪv",
      "type": "IPA"
    }
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Pronunciation
using RestSharp;

var client = new RestClient("https://api.murf.ai/v1/speech/generate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"text\": \"The 2010 world cup was held in South Africa\",\n  \"voiceId\": \"Natalie\",\n  \"locale\": \"en-US\",\n  \"pronunciationDictionary\": {\n    \"2010\": {\n      \"pronunciation\": \"two thousand and ten\",\n      \"type\": \"SAY_AS\"\n    },\n    \"live\": {\n      \"pronunciation\": \"laɪv\",\n      \"type\": \"IPA\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Pronunciation
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "text": "The 2010 world cup was held in South Africa",
  "voiceId": "Natalie",
  "locale": "en-US",
  "pronunciationDictionary": [
    "2010": [
      "pronunciation": "two thousand and ten",
      "type": "SAY_AS"
    ],
    "live": [
      "pronunciation": "laɪv",
      "type": "IPA"
    ]
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.murf.ai/v1/speech/generate")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Different output formats

**Request**

```json
{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "format": "MP3",
  "locale": "en-US",
  "sampleRate": 44100
}
```

**Response**

```json
{
  "audioFile": "string",
  "audioLengthInSeconds": 1.1,
  "remainingCharacterCount": 1,
  "wordDurations": [
    {
      "endMs": 1,
      "startMs": 1,
      "word": "string",
      "pitchScaleMaximum": 1.1,
      "pitchScaleMinimum": 1.1,
      "sourceWordIndex": 1
    }
  ],
  "encodedAudio": "string",
  "warning": "string",
  "consumedCharacterCount": 1
}
```

**SDK Code**

```python Different output formats
import requests

url = "https://api.murf.ai/v1/speech/generate"

payload = {
    "text": "Hi, How are you doing today?",
    "voiceId": "Natalie",
    "format": "MP3",
    "locale": "en-US",
    "sampleRate": 44100
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Different output formats
const url = 'https://api.murf.ai/v1/speech/generate';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: '{"text":"Hi, How are you doing today?","voiceId":"Natalie","format":"MP3","locale":"en-US","sampleRate":44100}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Different output formats
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.murf.ai/v1/speech/generate"

	payload := strings.NewReader("{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"format\": \"MP3\",\n  \"locale\": \"en-US\",\n  \"sampleRate\": 44100\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Different output formats
require 'uri'
require 'net/http'

url = URI("https://api.murf.ai/v1/speech/generate")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"format\": \"MP3\",\n  \"locale\": \"en-US\",\n  \"sampleRate\": 44100\n}"

response = http.request(request)
puts response.read_body
```

```java Different output formats
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.murf.ai/v1/speech/generate")
  .header("Content-Type", "application/json")
  .body("{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"format\": \"MP3\",\n  \"locale\": \"en-US\",\n  \"sampleRate\": 44100\n}")
  .asString();
```

```php Different output formats
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.murf.ai/v1/speech/generate', [
  'body' => '{
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "format": "MP3",
  "locale": "en-US",
  "sampleRate": 44100
}',
  'headers' => [
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Different output formats
using RestSharp;

var client = new RestClient("https://api.murf.ai/v1/speech/generate");
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"text\": \"Hi, How are you doing today?\",\n  \"voiceId\": \"Natalie\",\n  \"format\": \"MP3\",\n  \"locale\": \"en-US\",\n  \"sampleRate\": 44100\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Different output formats
import Foundation

let headers = ["Content-Type": "application/json"]
let parameters = [
  "text": "Hi, How are you doing today?",
  "voiceId": "Natalie",
  "format": "MP3",
  "locale": "en-US",
  "sampleRate": 44100
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.murf.ai/v1/speech/generate")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```