Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Global objectClient APIGenerated

Voice

const Voice: object

Defined in: client/api.d.ts:5236

Local player’s proximity voice chat settings: on/off, playback volume, hearing range and the push-to-talk binding.

getActivationThreshold(): number

Reads the voice-activation threshold.

number

Level from 0 to 1.

getHearingRange(): number

Reads the local hearing-range limit.

number

Radius in world units, or 0 when the server’s range applies unreduced.

getInputDevice(): string

Reads the chosen microphone.

string

Its name, or an empty string for the system default.

getInputDevices(): string[]

Lists the microphones voice can record from.

string[]

Device names as the player would recognise them; empty when the game chooses the device itself.

getInputLevel(): number

Reads how loud the microphone is right now, whether or not anything is being sent – the value to draw a level meter from and to tune the activation threshold against.

number

Smoothed level from 0 to 1; 0 while no microphone is open.

getPushToTalkKey(): string

Reads the push-to-talk binding.

string

Canonical key name, e.g. “v”.

getPushToTalkReleaseDelay(): number

Reads the push-to-talk release delay.

number

Delay in milliseconds; 0 when transmission stops the moment the key is released.

getRange(): number

Reads the server’s proximity range for talkers with no override of their own.

number

Radius in world units.

getTier(): number

Reads the voice tier this player is on.

number

0 whisper, 1 normal, 2 shout.

getTransmitMode(): "pushToTalk" | "voiceActivity"

Reads what opens the microphone.

"pushToTalk" | "voiceActivity"

The current transmit mode.

getVolume(): number

Reads the voice playback volume.

number

Current gain, where 1 is unattenuated.

hasMicrophone(): boolean

Checks whether a capture device opened for this session.

boolean

False when the player has no working microphone, i.e. they are listen-only.

isEnabled(): boolean

Checks whether voice chat is enabled for this player.

boolean

True unless the player turned voice chat off.

isNoiseSuppressionEnabled(): boolean

Checks whether noise suppression is on.

boolean

True while background noise is being filtered.

isTalking(): boolean

Checks whether the local player is speaking right now. The same state raises the voiceStart and voiceStop events.

boolean

True while push-to-talk is open – held, or still inside the release delay – and the microphone is producing audio.

setActivationThreshold(level): void

Sets the voice-activation sensitivity: lower sends quieter speech, higher ignores more background noise. Clamped to 0..1.

number

Microphone level, 0 to 1 on the scale getInputLevel reports, above which voice activation sends.

void

setEnabled(enabled): void

Turns voice chat on or off. Off closes the microphone and playback devices and tells the server to stop relaying voice to this client.

boolean

Whether voice chat runs at all for this player.

void

setHearingRange(range): void

Narrows how far this player hears others. Can only reduce the server’s range, since a talker beyond it is never relayed.

number

Audibility radius in world units; 0 removes the local limit.

void

setInputDevice(name): void

Chooses the microphone. A running microphone is reopened on the new device; a device that is no longer connected falls back to the default.

string

A name from getInputDevices, or an empty string for the system default.

void

setNoiseSuppression(enabled): void

Turns noise suppression on or off. It runs before the level is measured, so it also keeps steady noise from tripping voice activation.

boolean

Whether to filter background noise out of the microphone.

void

setPushToTalkKey(key): void

Rebinds push-to-talk. Unknown key names throw.

string

Case-insensitive key name, using the same names as Key.bind.

void

setPushToTalkReleaseDelay(milliseconds): void

Sets how long transmission continues after push-to-talk is released, so letting go slightly early does not clip the end of a word. Muting, turning voice off and losing input focus still stop it at once.

number

How long to keep transmitting after the key goes up. Clamped to 0..2000.

void

setTier(tier): void

Switches how far this player’s voice carries. A request: the server paces it, decides the radius, and may move the player itself.

number

Voice tier: 0 whisper, 1 normal, 2 shout.

void

setTransmitMode(mode): void

Chooses what opens the microphone. Switching closes whatever the previous mode had open. Unknown modes throw.

"pushToTalk" | "voiceActivity"

pushToTalk sends while the key is held; voiceActivity sends whenever the microphone is louder than the activation threshold.

void

setVolume(volume): void

Sets the playback volume of incoming voice. A game that plays voice through its own audio engine applies the same gain there.

number

Playback gain, where 1 is unattenuated. Clamped to 0..4.

void