> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Phonemize

> Phonemize endpoint: convert a recording of a word into a phonetic string in the Rime phonetic alphabet.

The Rime API authenticates every request with a bearer token in the `Authorization` header: `Authorization: Bearer YOUR_API_KEY`. See [API authentication](https://docs.rime.ai/docs/api-authentication.md) for how to create a key.

## Overview

This endpoint converts a short audio recording of a word into a phonetic string in the [Rime phonetic alphabet](https://docs.rime.ai/platform/rime-phonetic-alphabet.md).

Use it when you know how a word should sound but don't want to write the phonetic string by hand: record the word (or synthesize it), post the audio, and paste the returned string into a TTS request inside curly brackets with `phonemizeBetweenBrackets: true`. See [Custom pronunciation](https://docs.rime.ai/docs/custom-pronunciation).

> [!NOTE]
>
> Custom pronunciation strings are supported on **English Mist v3**. Coda and non-English Mist v3 accept `phonemizeBetweenBrackets` and ignore it. For an overview of all the ways to control pronunciation, see [Pronunciation control](https://docs.rime.ai/platform/pronunciation-control.md).

## Request

Unlike Rime's other endpoints, the request body is the **raw audio bytes**, not JSON or multipart form data. Set the `Content-Type` header to match the audio format. WAV (`audio/wav`) and MP3 (`audio/mpeg`) are supported.

## Example

Generate or record audio of the word, for example with the [Rime CLI](https://docs.rime.ai/cli-reference/overview.md):

```bash theme={null}
rime tts -m coda -l en -s astra "hello" -o speech.wav
```

Post the file as the raw request body. `--data-binary` sends the bytes unchanged, while `-d` would strip newlines and corrupt the audio:

```bash theme={null}
curl -X POST https://optimize.rime.ai/phonemize \
     -H "Authorization: Bearer $(rime key)" \
     -H "Content-Type: audio/wav" \
     --data-binary @speech.wav
```

The response includes the phonetic string:

```json theme={null}
{
  "audioId": "9b2d8ad2-0618-4e96-b255-98b2f7488061",
  "phonemeString": "h0El1o !",
  "authed": 1
}
```

## Response fields

* `audioId`: identifier of the uploaded audio clip.
* `phonemeString`: the phonetic transcription in the [Rime phonetic alphabet](https://docs.rime.ai/platform/rime-phonetic-alphabet.md). The string may end with a punctuation token (for example, `!` or `?`). Strip that token before you use the string inside `{}`.
* `authed`: always `1`.

```bash cURL theme={null}
curl --request POST \
  --url https://optimize.rime.ai/phonemize \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: audio/wav' \
  --fail \
  --data-binary @speech.wav
```

```python Python theme={null}
import requests

url = "https://optimize.rime.ai/phonemize"

headers = {
    "Authorization": "Bearer <authorization>",
    "Content-Type": "audio/wav"
}

with open("speech.wav", "rb") as f:
    response = requests.request("POST", url, data=f, headers=headers)

print(response.text)
```

```javascript JavaScript theme={null}
import { readFile } from 'node:fs/promises';

const audio = await readFile('speech.wav');

const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <authorization>',
    'Content-Type': 'audio/wav'
  },
  body: audio
};

fetch('https://optimize.rime.ai/phonemize', options)
  .then(response => response.json())
  .then(response => console.log(response))
  .catch(err => console.error(err));
```

```json 200 theme={null}
{
  "audioId": "9b2d8ad2-0618-4e96-b255-98b2f7488061",
  "phonemeString": "h0El1o !",
  "authed": 1
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.