# VoiceSession

Source: https://docs.voice.kheelona.com/reference/sdk/interfaces/voicesession/

A live voice session.

## Properties

### sessionId

> `readonly` **sessionId**: `string`

The session id.

***

### state

> `readonly` **state**: [`SessionState`](https://docs.voice.kheelona.com/reference/sdk/type-aliases/sessionstate.md)

The current state. `listening` once `connect()` has resolved.

***

### transport

> `readonly` **transport**: `"webrtc"` \| `"websocket"`

The transport in use: `webrtc`, or `websocket` after the fallback.

## Methods

### end()

> **end**(): `Promise`\<`void`\>

Ends the session and releases the microphone.

#### Returns

`Promise`\<`void`\>

***

### interrupt()

> **interrupt**(): `void`

Stops the reply now, as if the person had started speaking.

#### Returns

`void`

***

### levels()

> **levels**(): `object`

Loudness, 0..1, for meters.

#### Returns

`object`

##### input

> **input**: `number`

##### output

> **output**: `number`

***

### mute()

> **mute**(`muted`): `void`

Mutes or unmutes the microphone.

#### Parameters

##### muted

`boolean`

#### Returns

`void`

***

### on()

> **on**\<`K`\>(`name`, `fn`): () => `void`

Subscribes; the returned function unsubscribes. A new `state` listener first gets the current state, once, in a
microtask after `on()` returns; then every change. Events that arrived while `connect()` was running are
delivered in a task after it resolves, so listeners attached right after `await connect()` miss none of them.

#### Type Parameters

##### K

`K` *extends* keyof [`SessionEvents`](https://docs.voice.kheelona.com/reference/sdk/interfaces/sessionevents.md)

#### Parameters

##### name

`K`

##### fn

(`e`) => `void`

#### Returns

() => `void`

***

### resumeAudio()

> **resumeAudio**(): `void`

After a non-fatal `audio_unavailable` (the browser refused to play the voice): call it
synchronously in a click or tap handler. It resumes the audio and retries playing the voice inside that gesture;
the conversation goes on. If the browser still refuses, `audio_unavailable` is reported again. Does nothing after
`ended`.

#### Returns

`void`

***

### sendText()

> **sendText**(`text`): `void`

Sends a typed turn (at most 2,000 characters; longer throws `RangeError`).

#### Parameters

##### text

`string`

#### Returns

`void`
