> ## Documentation Index
> Fetch the complete documentation index at: https://60db.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Speech-to-Text

> Transcribe audio to text with high accuracy

## Overview

60db's Speech-to-Text (STT) API converts spoken audio into written text with high accuracy across 50+ languages. Our STT engine uses state-of-the-art AI models optimized for various use cases.

## Features

<CardGroup cols={2}>
  <Card title="Multi-Language" icon="globe">
    Support for 50+ languages with auto-detection
  </Card>

  <Card title="Speaker Diarization" icon="users">
    Identify and separate different speakers
  </Card>

  <Card title="Timestamps" icon="clock">
    Word-level timestamps for precise alignment
  </Card>

  <Card title="Specialized Models" icon="brain">
    Models optimized for calls, meetings, and more
  </Card>
</CardGroup>

## Basic Usage

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    import { SixtyDBClient } from '60db';

    const client = new SixtyDBClient('your-api-key');

    const file = document.querySelector('input[type="file"]').files[0];

    const result = await client.speechToText(file, {
      language: 'en'
    });

    console.log('Transcription:', result.text);
    console.log('Confidence:', result.confidence);
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from sixtydb import SixtyDBClient

    client = SixtyDBClient('your-api-key')

    with open('recording.mp3', 'rb') as audio_file:
        result = client.speech_to_text(audio_file, language='en')
        print(f"Transcription: {result['text']}")
        print(f"Confidence: {result['confidence']}")
    ```
  </Tab>
</Tabs>

## Supported Formats

| Format | Max Size | Max Duration | Quality   |
| ------ | -------- | ------------ | --------- |
| MP3    | 25MB     | 10 min       | Good      |
| WAV    | 25MB     | 10 min       | Excellent |
| FLAC   | 25MB     | 10 min       | Lossless  |
| OGG    | 25MB     | 10 min       | Good      |
| M4A    | 25MB     | 10 min       | Good      |

## Language Support

### Auto-Detection

Let the API automatically detect the language:

```javascript theme={null}
const result = await client.speechToText(file);
// Language will be auto-detected
console.log('Detected language:', result.language);
```

### Specify Language

For better accuracy, specify the language:

```javascript theme={null}
const result = await client.speechToText(file, {
  language: 'en'  // ISO 639-1 code
});
```

### Get Supported Languages

```javascript theme={null}
const languages = await client.getLanguages();
languages.forEach(lang => {
  console.log(`${lang.name} (${lang.code})`);
});
```

## Transcription Models

Choose the model optimized for your use case:

### General (Default)

Best for general-purpose transcription:

```javascript theme={null}
const result = await client.speechToText(file, {
  model: 'general'
});
```

### Phone Call

Optimized for phone conversations:

```javascript theme={null}
const result = await client.speechToText(file, {
  model: 'phone_call'
});
```

### Meeting

Best for multi-speaker meetings:

```javascript theme={null}
const result = await client.speechToText(file, {
  model: 'meeting',
  speaker_labels: true
});
```

### Medical

Specialized for medical terminology:

```javascript theme={null}
const result = await client.speechToText(file, {
  model: 'medical'
});
```

## Advanced Features

### Word-Level Timestamps

Get precise timing for each word:

```javascript theme={null}
const result = await client.speechToText(file, {
  timestamps: true
});

result.words.forEach(word => {
  console.log(`${word.word}: ${word.start}s - ${word.end}s`);
});
```

### Speaker Diarization

Identify different speakers:

```javascript theme={null}
const result = await client.speechToText(file, {
  speaker_labels: true
});

// Result includes speaker information
result.segments.forEach(segment => {
  console.log(`Speaker ${segment.speaker}: ${segment.text}`);
});
```

## Best Practices

<AccordionGroup>
  <Accordion title="Audio Quality">
    * Use high-quality recordings (16kHz+ sample rate)
    * Minimize background noise
    * Ensure clear speech
    * Avoid audio compression when possible
  </Accordion>

  <Accordion title="Accuracy Tips">
    * Specify the language when known
    * Use appropriate model for your use case
    * Provide clean audio without music
    * Split very long recordings
  </Accordion>

  <Accordion title="Performance">
    * Keep files under 25MB
    * Use appropriate format (WAV for quality, MP3 for size)
    * Process in batches for multiple files
  </Accordion>
</AccordionGroup>

## Use Cases

### Meeting Transcription

```python theme={null}
with open('meeting.mp3', 'rb') as audio:
    result = client.speech_to_text(
        audio,
        model='meeting',
        speaker_labels=True,
        timestamps=True
    )
    
    # Generate meeting notes
    for segment in result['segments']:
        print(f"[{segment['start']:.1f}s] Speaker {segment['speaker']}: {segment['text']}")
```

### Voice Commands

```javascript theme={null}
async function processVoiceCommand(audioBlob) {
  const result = await client.speechToText(audioBlob, {
    language: 'en',
    model: 'general'
  });
  
  const command = parseCommand(result.text);
  executeCommand(command);
}
```

### Subtitle Generation

```javascript theme={null}
const result = await client.speechToText(videoAudio, {
  timestamps: true
});

const subtitles = generateSRT(result.words);
saveFile('subtitles.srt', subtitles);
```

## API Reference

<Card title="Speech to Text API" icon="microphone" href="/api-reference/stt/speech-to-text">
  View complete API documentation
</Card>
