# RoomDefinition: voice property

> The voice property of a room definition turns on proximity voice and decides who each connection hears.

The **`voice`** property of a [room definition](/docs/room/room-definition) turns on proximity voice: the room tells each connection who it hears and who hears it, and `@irtio/client/voice` plays what the room allows.

## Value

An object with these optional properties. `voice: {}` turns voice on with the defaults.

`maxSpeakers`
: The most speakers each listener hears, at most 256. Defaults to 8, or 256 with `audible`. The project's `voice.maxSpeakers` setting is a ceiling: the room gets the smaller of the two.

`owner(entity)`
: Returns the player ID an entity speaks for, or `undefined`. Defaults to the entity's owner, else its `owner` string field.

`audible(room, listener)`
: Returns the player IDs `listener`, a [`Connection`](/docs/room/connection), hears, replacing the default rule. The listener's own ID is dropped.

## Description

The project needs its `voice` setting turned on as well. By default a listener hears the players whose entities it can see under the room's [`interest`](/docs/room/room-definition/interest), ranked by the interest limit's `priority` and capped at `maxSpeakers`. `audible` replaces that rule, for teams, radio channels or a whole room on one call.

With each state update the room works out every connection's speakers and listeners, and sends them when they change, at most 4 times a second. Bots, and players the room muted with `room.muteVoice()`, are left out of every listener's speakers. Voice doesn't need a [`tickRate`](/docs/room/room-definition/tickrate).

## Examples

### Team radio

Each player hears only its own team, wherever they are.

```ts
// radio.ts
import { defineRoom } from "@irtio/room";

export default defineRoom({
  onJoin(_room, connection) {
    connection.data.team = (connection.meta as { team?: string } | null)?.team ?? "red";
  },
  voice: {
    audible: (room, listener) =>
      [...room.connections.values()].filter((c) => c.data.team === listener.data.team).map((c) => c.player),
  },
});
```

## See also

- [Proximity voice](/docs/room/guides/voice)
