> ## 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.

# Cambai

> JavaScript API reference for the cambai text-to-speech plugin.

## CambAITTS

Camb.ai text-to-speech provider.

Creates a configured Camb.ai TTS provider for use in a voice agent.

### Constructor

```typescript theme={null}
new CambAITTS(opts: CambAITTSOptions)
```

<ParamField path="apiKey" type="string">
  Camb.ai API key. Falls back to the `CAMBAI_API_KEY` env var.
</ParamField>

<ParamField path="voice" type="number">
  Numeric voice ID. Default: `147320`.
</ParamField>

<ParamField path="model" type="string">
  Synthesis model. Default: `'mars-pro'`.
</ParamField>

<ParamField path="sampleRate" type="number">
  Output audio sample rate in Hz. Default: `24000`.
</ParamField>

### close

```typescript theme={null}
close(): Promise<void>
```

Release any resources held by the provider.

### closeEmitter

```typescript theme={null}
closeEmitter(): Promise<void>
```

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds
for in-flight async handlers to settle before returning.

### emit

```typescript theme={null}
emit(event: string, ...args: any[]): void
```

<ParamField path="event" type="string" required />

### getRuntimeConfig

```typescript theme={null}
getRuntimeConfig(): Record<string, any>
```

<ResponseField name="returns" type="Record<string, any>" />

### interrupt

```typescript theme={null}
interrupt(): Promise<void>
```

Stop the current synthesis.

### listenerCount

```typescript theme={null}
listenerCount(event: string): number
```

<ParamField path="event" type="string" required />

<ResponseField name="returns" type="number" />

### off

```typescript theme={null}
off(event: string, handler: EventHandler): void
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

### on

```typescript theme={null}
on(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### once

```typescript theme={null}
once(event: string, handler: EventHandler): EventHandler
```

<ParamField path="event" type="string" required />

<ParamField path="handler" type="EventHandler" required />

<ResponseField name="returns" type="EventHandler" />

### onFirstAudioByte

```typescript theme={null}
onFirstAudioByte(callback: FirstAudioByteCallback): void
```

Register a callback fired when the first synthesized audio byte is emitted.

<ParamField path="callback" type="FirstAudioByteCallback" required />

### removeAllListeners

```typescript theme={null}
removeAllListeners(event?: string): void
```

<ParamField path="event" type="string" />

### synthesize

```typescript theme={null}
synthesize(text: any, ..._extra: any[]): Promise<void>
```

Synthesize and speak `text` on the active session.

<ParamField path="text" type="any" required />
