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

# Speech-to-Text

> Transcribe audio files to text using OpenAI Whisper API

<Endpoint method="post" url="/tts/stt" />

Transcribe audio files to text using OpenAI's Whisper API. Supports multiple audio formats and automatically detects language.

## Request

<ParamField body="audio" type="file" required>
  Audio file to transcribe (MP3, WAV, FLAC, etc.)
</ParamField>

<ParamField body="api_key" type="string" required>
  Your GistMag API key
</ParamField>

## Response

<ResponseField name="text" type="string">
  The transcribed text from the audio file
</ResponseField>

<ResponseField name="language" type="string">
  The detected or specified language code (e.g., "en", "es", "fr") or "auto" if auto-detected
</ResponseField>

## Credit Cost

**5 credits per minute** of audio (rounded up to the nearest minute).

For example:

* 30 seconds of audio = 5 credits (1 minute)
* 2.5 minutes of audio = 15 credits (3 minutes)

## Example Request

<CodeGroup>
  ```bash theme={null}
  curl -X POST https://api.gistmag.co.uk/tts/stt \
    -F "audio=@recording.wav" \
    -F "api_key=your_api_key_here"
  ```

  ```javascript theme={null}
  const formData = new FormData();
  formData.append('audio', audioFile);
  formData.append('api_key', 'your_api_key_here');

  const response = await fetch('https://api.gistmag.co.uk/tts/stt', {
    method: 'POST',
    body: formData
  });

  const result = await response.json();
  console.log(result.text); // Transcribed text
  ```

  ```python theme={null}
  import requests

  with open('recording.wav', 'rb') as audio_file:
      files = {'audio': audio_file}
      data = {'api_key': 'your_api_key_here'}
      
      response = requests.post(
          'https://api.gistmag.co.uk/tts/stt',
          files=files,
          data=data
      )
      
      result = response.json()
      print(result['text'])  # Transcribed text
  ```
</CodeGroup>

## Supported Audio Formats

OpenAI Whisper supports a wide range of audio formats:

* MP3
* WAV
* M4A
* FLAC
* OGG
* WebM
* And many other common audio formats

## Notes

* The API automatically detects the language in the audio (or you can specify it)
* Audio is processed securely and not stored
* Maximum file size: 25MB (OpenAI Whisper limit)
* Uses OpenAI's Whisper-1 model for high-quality transcription
