> 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.

# Audio Formats

> Declare your input audio format with AudioConfig. Murf Speech to Text accepts PCM, µ-law, A-law and Opus at 8 kHz to 48 kHz.

By default, the server expects **16-bit signed little-endian PCM, 16 kHz, mono**. If your audio is in that format, just send it.

For any other format, send one `AudioConfig` message as the first text message on the connection, before any audio:

```json
{ "type": "AudioConfig", "codec": "mulaw", "sample_rate": 8000, "channels": 1 }
```

Then send the audio as binary frames. The server converts every supported format before transcription, so you don't need to convert audio yourself.

> **Note**
>
> Send exactly one `AudioConfig` per connection, and send it before any audio. To use a different format, open a new connection.

## Supported formats

| `codec`     | Alias  | Contents of each binary frame                                    |
| ----------- | ------ | ---------------------------------------------------------------- |
| `pcm_s16le` | —      | Raw 16-bit signed little-endian PCM samples                      |
| `mulaw`     | `pcmu` | G.711 µ-law, 1 byte per sample                                   |
| `alaw`      | `pcma` | G.711 A-law, 1 byte per sample                                   |
| `opus`      | —      | Exactly one Opus packet per frame, with no Ogg or WebM container |

| Field         | Required | Allowed values                                                             |
| ------------- | -------- | -------------------------------------------------------------------------- |
| `codec`       | Yes      | `pcm_s16le`, `mulaw`, `pcmu`, `alaw`, `pcma`, `opus`                       |
| `sample_rate` | Yes      | `8000`, `12000`, `16000`, `24000`, `32000`, `44100`, `48000` (every codec) |
| `channels`    | No       | `1` (default) or `2`. Stereo is mixed down to mono before transcription.   |
| `type`        | No       | `AudioConfig`. Can be omitted when `codec` and `sample_rate` are present.  |

## Telephony

Most telephony platforms stream call audio as 8 kHz G.711. Declare it as-is:

#### 8 kHz µ-law

Common in North America and Japan, and the default on many cloud telephony platforms.

```json
{ "type": "AudioConfig", "codec": "mulaw", "sample_rate": 8000, "channels": 1 }
```

#### 8 kHz A-law

Common on European and Indian carrier networks.

```json
{ "type": "AudioConfig", "codec": "alaw", "sample_rate": 8000, "channels": 1 }
```

Many telephony media streams deliver audio as base64 text inside JSON events. Decode the base64 and send the raw bytes as a **binary** frame. Do not forward the provider's JSON event.

```python
import base64

# media_payload: the base64 audio string from your telephony provider's event
await ws.send(base64.b64decode(media_payload))
```

### Full telephony session

```text
wss://in.api.murf.ai/v1/transcription/stream-input?api_key=YOUR_API_KEY&language=hi
```

```json
{ "type": "AudioConfig", "codec": "mulaw", "sample_rate": 8000, "channels": 1 }
```

```
<binary frame: 8 kHz µ-law bytes>
<binary frame: 8 kHz µ-law bytes>
...
```

```json
{ "type": "Finalize" }
```

The server sends the turn's `final` transcript. The connection stays open for the next turn.

```json
{ "type": "CloseStream" }
```

## Web and mobile audio

#### Opus (WebRTC)

```json
{ "type": "AudioConfig", "codec": "opus", "sample_rate": 48000, "channels": 2 }
```

Send each Opus packet as its own binary frame. Do not combine several packets into one frame, and do not send Ogg or WebM container data, such as the output of the browser's `MediaRecorder`.

#### PCM at 44.1 kHz

A common microphone default.

```json
{ "type": "AudioConfig", "codec": "pcm_s16le", "sample_rate": 44100, "channels": 1 }
```

#### PCM at 16 kHz (default)

No `AudioConfig` needed. Send the samples directly.

## Format errors

If `codec`, `sample_rate` or `channels` is invalid, a binary frame cannot be decoded, or a text frame is not a JSON object, the server sends an `Error` message and closes the connection with code `4002`.

```json
{ "type": "Error", "message": "Invalid sample_rate 22050. Allowed: [8000, 12000, 16000, 24000, 32000, 44100, 48000]" }
```

```json
{ "type": "Error", "message": "Invalid audio config: missing sample_rate" }
```

```json
{ "type": "Error", "message": "Opus decode failed" }
```

If your source audio uses a sample rate that isn't listed, such as 22.05 kHz, resample it to a supported rate before sending.

See [Errors](/api/docs/speech-to-text/errors) for every close code.