VoiceReceiver
Defined in: packages/voice/src/receiver.ts:48
Receives other users’ audio (low level): decrypted Opus packets per user.
SSRCs are mapped to users from op 5; decoding is up to you (createOpusCodec).
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new VoiceReceiver():
VoiceReceiver
Returns
Section titled “Returns”VoiceReceiver
Accessors
Section titled “Accessors”speaking
Section titled “speaking”Get Signature
Section titled “Get Signature”get speaking():
ReadonlySet<string>
Defined in: packages/voice/src/receiver.ts:63
Users who sent audio in the last 100 ms.
Returns
Section titled “Returns”ReadonlySet<string>
Methods
Section titled “Methods”off(
event,listener):this
Defined in: packages/voice/src/receiver.ts:78
Parameters
Section titled “Parameters”"end" | "start"
listener
Section titled “listener”(userId) => void
Returns
Section titled “Returns”this
on(
event,listener):this
Defined in: packages/voice/src/receiver.ts:68
Listens for a user starting or stopping to send audio.
Parameters
Section titled “Parameters”"end" | "start"
listener
Section titled “listener”(userId) => void
Returns
Section titled “Returns”this
record()
Section titled “record()”record(
userId,options?):ReadableStream<Uint8Array<ArrayBufferLike>>
Defined in: packages/voice/src/receiver.ts:134
Records userId as an Ogg/Opus stream (48 kHz stereo) that players and
FFmpeg read: write it to a file with Bun.write(path, new Response(stream)).
The audio is not re-encoded. Time the user is silent is kept as silence,
counted from the start of the recording, so recordings of several users
started together line up.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
options?
Section titled “options?”RecordOptions = {}
Returns
Section titled “Returns”ReadableStream<Uint8Array<ArrayBufferLike>>
ssrcOf()
Section titled “ssrcOf()”ssrcOf(
userId):number|undefined
Defined in: packages/voice/src/receiver.ts:58
The SSRC Discord assigned to a user, once they spoke.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”number | undefined
subscribe()
Section titled “subscribe()”subscribe(
userId,options?):ReadableStream<Uint8Array<ArrayBufferLike>>
Defined in: packages/voice/src/receiver.ts:99
A stream of userId’s Opus packets. It ends after a second without
audio unless end.behavior is "manual"; cancelling it unsubscribes.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
options?
Section titled “options?”ReceiveOptions = {}
Returns
Section titled “Returns”ReadableStream<Uint8Array<ArrayBufferLike>>
unsubscribe()
Section titled “unsubscribe()”unsubscribe(
userId):boolean
Defined in: packages/voice/src/receiver.ts:199
Ends every stream of userId.
Parameters
Section titled “Parameters”userId
Section titled “userId”string
Returns
Section titled “Returns”boolean
Whether there was one.