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

# Speech to text

> Transcribe recordings and identify speakers.

This standalone API transcribes supplied audio. To ask a model to respond to audio instead, see [Audio inputs](/docs/audio-inputs).

## Transcribe audio

Send an audio file to the transcription endpoint when you want text output from a recorded file.
If your app acts on behalf of an end user, also send `X-On-Behalf-Of`.

Supported audio formats: `FLAC`, `MP3`, `MP4`, `MPEG`, `MPGA`, `M4A`, `OGG`, `WAV`, `WebM`.

To save the transcription (and input audio) to history, set `store=true`.

<CodeGroup>
  ```ts TypeScript SDK theme={null}
  import { SDK } from '@meetkai/mka1';
  import { openAsBlob } from 'node:fs';

  const sdk = new SDK({ bearerAuth: 'Bearer <mka1-api-key>' });

  const result = await sdk.llm.speech.transcribe({
    xOnBehalfOf: '<end-user-id>', // optional — attribute the request to one of your end users
    language: 'en',
    prompt: 'This is a technical podcast about machine learning.',
    temperature: 0.2,
    store: true,
    requestBody: {
      file: await openAsBlob('episode.wav'),
    },
  });

  console.log(result.text);
  console.log(result.language);
  console.log(result.confidence);
  ```

  ```python Python SDK theme={null}
  from meetkai_mka1 import SDK

  sdk = SDK(bearer_auth="Bearer <mka1-api-key>")

  result = sdk.llm.speech.transcribe(
      file={"file_name": "episode.wav", "content": open("episode.wav", "rb")},
      language="en",
      prompt="This is a technical podcast about machine learning.",
      temperature=0.2,
      store=True,
  )

  print(result.text)
  print(result.language)
  print(result.confidence)
  ```

  ```csharp C# SDK theme={null}
  using MeetKai.MKA1;
  using MeetKai.MKA1.Types.Components;
  using MeetKai.MKA1.Types.Requests;

  var sdk = new SDK(bearerAuth: "Bearer <mka1-api-key>");

  var result = await sdk.Llm.Speech.TranscribeAsync(new TranscribeRequest()
  {
      Language = "en",
      Prompt = "This is a technical podcast about machine learning.",
      Temperature = 0.2,
      Store = true,
      Body = new TranscribeRequestBody()
      {
          File = new TranscribeFile()
          {
              FileName = "episode.wav",
              Content = System.IO.File.ReadAllBytes("episode.wav"),
          },
      },
  });

  Console.WriteLine(result.TranscriptionResponse!.Text);
  Console.WriteLine(result.TranscriptionResponse!.Language);
  Console.WriteLine(result.TranscriptionResponse!.Confidence);
  ```

  ```bash CLI theme={null}
  mka1 llm speech transcribe \
    --file ./episode.wav \
    --language en \
    --prompt 'This is a technical podcast about machine learning.' \
    --temperature 0.2 \
    --store \
    -H 'X-On-Behalf-Of: <end-user-id>'
  ```

  ```bash Bash theme={null}
  curl 'https://apigw.mka1.com/api/v1/llm/speech/transcriptions?language=en&prompt=This%20is%20a%20technical%20podcast%20about%20machine%20learning.&temperature=0.2&store=true' \
    --request POST \
    --header 'Authorization: Bearer <mka1-api-key>' \
    --header 'X-On-Behalf-Of: <end-user-id>' \
    --form 'file=@episode.wav'
  ```
</CodeGroup>

The response includes the transcript text plus detected language and confidence:

```json theme={null}
{
  "text": "Hello! We're excited to show you our native speech capabilities.",
  "language": "en",
  "confidence": 0.8429018476208717
}
```

## Separate speakers in one transcript

If you need diarization, enable speaker data in the transcription request.
When enabled, the response can include a `speakers` array with speaker-labeled segments and timing metadata.

<Warning>
  For `include_speaker_data`, upload WAV or PCM audio for non-streaming transcription. Other audio formats return `400 BAD_REQUEST` with the message `Speaker diarization currently requires WAV/PCM audio for non-streaming transcription`.
</Warning>

```ts TypeScript SDK theme={null}
const result = await sdk.llm.speech.transcribe({
  xOnBehalfOf: '<end-user-id>',
  language: 'en',
  includeSpeakerData: true,
  prompt: 'This is a short podcast clip about AI product updates.',
  temperature: 0.2,
  requestBody: {
    file: await openAsBlob('panel.wav'),
  },
});

console.log(result.speakers);
```

Example response with speaker separation:

```json theme={null}
{
  "text": "Welcome back to the show. Today we're looking at how speech APIs fit into production apps. We'll keep it practical and focus on latency, accuracy, and speaker turns.",
  "language": "en",
  "confidence": 0.91177404,
  "speakers": [
    {
      "speaker": "Speaker-1",
      "text": "Welcome back to the show.",
      "confidence": 0.91177404,
      "offset_ms": 80,
      "duration_ms": 1280
    },
    {
      "speaker": "Speaker-2",
      "text": "Today we're looking at how speech APIs fit into production apps.",
      "confidence": 0.91177404,
      "offset_ms": 1540,
      "duration_ms": 3380
    },
    {
      "speaker": "Speaker-1",
      "text": "We'll keep it practical and focus on latency, accuracy, and speaker turns.",
      "confidence": 0.91177404,
      "offset_ms": 5220,
      "duration_ms": 3660
    }
  ]
}
```

Use the top-level `text` field when you need a single merged transcript.
Use `speakers` when you need captions, turn-taking, or downstream speaker analytics.
