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

All requests require authentication with a bearer token in the `Authorization` header: `Authorization: Bearer YOUR_API_KEY`. See [API authentication](/docs/api-authentication) for how to create a key.

## Overview

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

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](/docs/custom-pronunciation).

<Note>
  Custom pronunciation strings are supported by **Mist v1 and v2** only. For an overview of all the ways to control pronunciation, see [Pronunciation control](/platform/pronunciation-control).
</Note>

## 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](/cli-reference/overview):

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

Then post it to the endpoint:

```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](/platform/rime-phonetic-alphabet). The string may end with a punctuation token (e.g. `!` or `?`); strip it before using the string inside `{}`.
* `authed` — always `1`.

<RequestExample>
  ```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));
  ```
</RequestExample>

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