# Speech-to-Text

> The Speech-to-Text (STT), also called ASR, is a technology that converts spoken audio into written text.

## What is speech-to-text (STT)?

The technology, also called automatic speech recognition, that turns spoken audio into text. Streaming models return partial results while the person is still speaking, which is essential for voice agents and live captions.

- Topic: Voice AI
- Type: technology

## Example

Wrong:

```js
recorder.onstop = async () => {
  const blob = new Blob(chunks, { type: 'audio/webm' });
  const text = await transcribe(blob);
  showText(text);
};
```

Right:

```js
recorder.ondataavailable = (e) => socket.send(e.data);
recorder.start(250);
socket.onmessage = (e) => {
  const msg = JSON.parse(e.data);
  msg.final ? commitText(msg.text) : showPartial(msg.text);
};
```

Sending small chunks over a socket gives partial results while the user speaks, instead of waiting for the whole recording.

## Common mistakes

- Uploading the whole recording after the user stops, making the agent feel slow.

## Key points

- Audio is sent in the sample rate and format the model expects.
- Partial results are shown as temporary and replaced by final ones.
- The language is set explicitly when it is known.

## Interview questions

### What is the difference between STT and ASR?

They mean the same thing. ASR, automatic speech recognition, is the more technical name for converting speech to text.

### Why does speech-to-text get names and technical terms wrong?

Rare words are underrepresented in training data. Many STT APIs accept a list of key terms or a prompt with domain vocabulary to improve recognition.

### What is the difference between partial and final transcripts?

Partial results are early guesses that can still change as more audio arrives. Final results are stable and should be used for logic and storage.

## Related cards

- [Text-to-Speech](https://wonderium.dev/ai/text-to-speech.md)
- [Voice Agent](https://wonderium.dev/ai/voice-agent.md)
- [Word Error Rate](https://wonderium.dev/ai/word-error-rate.md)
- [MediaRecorder](https://wonderium.dev/js/media-recorder.md)

---

- Level: [Artificial Intelligence](https://wonderium.dev/ai.md)
- HTML version: https://wonderium.dev/ai/speech-to-text
- Last updated: 2026-11-25
