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

# AssemblyAI

> Use the AssemblyAI speech-to-text plugin in a Zero Runtime pipeline. Setup and usage in Python and JavaScript.

AssemblyAI is a **speech-to-text** plugin. It transcribes the caller's audio into text for
the LLM, using AssemblyAI's universal streaming model with built-in end-of-turn detection.

## Setup

Set your AssemblyAI API key in the worker environment. Generate a key from the [AssemblyAI dashboard](https://www.assemblyai.com/dashboard/docs/your-api-key):

```bash theme={null}
export ASSEMBLYAI_API_KEY=<key>
```

<Note>
  The Python SDK requires `scipy` for audio resampling. Install it with `pip install scipy`
  if it isn't already present.
</Note>

## Usage

Import the plugin and pass it to the pipeline's `stt` slot.

<CodeGroup>
  ```python Python theme={null}
  from zeroruntime.plugins import AssemblyAISTT

  stt = AssemblyAISTT()

  # Pipeline(stt=stt, ...)
  ```

  ```typescript Node JS theme={null}
  import { AssemblyAISTT } from '@zeroruntime/js-sdk/plugins';

  const stt = AssemblyAISTT();

  // Pipeline({ stt, ... })
  ```
</CodeGroup>

## Parameters

*Constructor parameters for `AssemblyAISTT`. The Python and Node JS SDKs share these field names.*

| Parameter | Type | Default | Description |
| - | - | - | - |
| `api_key` | `str` | `None` | AssemblyAI API key. Falls back to the `ASSEMBLYAI_API_KEY` environment variable when unset. |
| `input_sample_rate` | `int` | `48000` | Sample rate (Hz) of the incoming audio. |
| `output_sample_rate` | `int` | `16000` | Sample rate (Hz) the audio is resampled to before it is sent to AssemblyAI. |
| `format_turns` | `bool` | `True` | Apply capitalization and punctuation to completed turns. |
| `keyterms_prompt` | `list[str]` | `None` | Words or phrases to bias recognition toward. |
| `end_of_turn_confidence_threshold` | `float` | `0.4` | Confidence above which a turn is considered finished. |
| `min_end_of_turn_silence_when_confident` | `int` | `560` | Milliseconds of silence required to end a turn when end-of-turn confidence is high. |
| `max_turn_silence` | `int` | `2400` | Maximum silence (ms) allowed within a turn before it ends. |
| `speech_model` | `str` | `"universal-streaming-english"` | Recognition model: `"universal-streaming-english"` or `"universal-streaming-multilingual"`. |
| `language_detection` | `bool` | `False` | Automatically detect the spoken language. |

## Import paths

| SDK | Import | Constructor |
| - | - | - |
| Python | `from zeroruntime.plugins import AssemblyAISTT` | `AssemblyAISTT()` |
| Node JS | `import { AssemblyAISTT } from '@zeroruntime/js-sdk/plugins'` | `AssemblyAISTT()` |

Transcribed text passes to the [LLM](/runtime-sdk/plugins/llm/google) once
[turn detection](/runtime-sdk/plugins/turn-detection/namo) decides the caller has finished speaking.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.