@fluxerjs/voice 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -1
- package/dist/index.d.mts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +205 -2580
- package/dist/index.mjs +188 -2590
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -11,12 +11,30 @@ pnpm add @fluxerjs/voice @fluxerjs/core
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
13
|
```javascript
|
|
14
|
-
import { getVoiceManager } from '@fluxerjs/voice';
|
|
14
|
+
import { getVoiceManager, LiveKitRtcConnection } from '@fluxerjs/voice';
|
|
15
15
|
|
|
16
16
|
const voiceManager = getVoiceManager(client);
|
|
17
17
|
const connection = await voiceManager.join(channel);
|
|
18
18
|
await connection.play(streamUrl);
|
|
19
19
|
|
|
20
|
+
// Inbound transcription / speech-to-text pipeline
|
|
21
|
+
if (connection instanceof LiveKitRtcConnection) {
|
|
22
|
+
const subs = voiceManager.subscribeChannelParticipants(channel.id);
|
|
23
|
+
connection.on('speakerStart', ({ participantId }) => {
|
|
24
|
+
console.log('speaker start', participantId);
|
|
25
|
+
});
|
|
26
|
+
connection.on('speakerStop', ({ participantId }) => {
|
|
27
|
+
console.log('speaker stop', participantId);
|
|
28
|
+
});
|
|
29
|
+
connection.on('audioFrame', (frame) => {
|
|
30
|
+
// frame.samples is Int16 PCM suitable for WAV/STT pipelines
|
|
31
|
+
console.log(frame.participantId, frame.sampleRate, frame.channels, frame.samples.length);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// cleanup subscriptions when done
|
|
35
|
+
for (const sub of subs) sub.stop();
|
|
36
|
+
}
|
|
37
|
+
|
|
20
38
|
connection.stop();
|
|
21
39
|
voiceManager.leave(guildId);
|
|
22
40
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -67,6 +67,27 @@ type LiveKitRtcConnectionEvents = VoiceConnectionEvents & {
|
|
|
67
67
|
self_stream?: boolean;
|
|
68
68
|
self_video?: boolean;
|
|
69
69
|
}];
|
|
70
|
+
/** Emitted when a remote participant starts speaking. */
|
|
71
|
+
speakerStart: [payload: {
|
|
72
|
+
participantId: string;
|
|
73
|
+
}];
|
|
74
|
+
/** Emitted when a remote participant stops speaking. */
|
|
75
|
+
speakerStop: [payload: {
|
|
76
|
+
participantId: string;
|
|
77
|
+
}];
|
|
78
|
+
/** Emitted for each decoded inbound audio frame. */
|
|
79
|
+
audioFrame: [frame: LiveKitAudioFrame];
|
|
80
|
+
};
|
|
81
|
+
type LiveKitAudioFrame = {
|
|
82
|
+
participantId: string;
|
|
83
|
+
trackSid?: string;
|
|
84
|
+
sampleRate: number;
|
|
85
|
+
channels: number;
|
|
86
|
+
samples: Int16Array;
|
|
87
|
+
};
|
|
88
|
+
type LiveKitReceiveSubscription = {
|
|
89
|
+
participantId: string;
|
|
90
|
+
stop: () => void;
|
|
70
91
|
};
|
|
71
92
|
/**
|
|
72
93
|
* Options for video playback via {@link LiveKitRtcConnection.playVideo}.
|
|
@@ -133,6 +154,10 @@ declare class LiveKitRtcConnection extends EventEmitter {
|
|
|
133
154
|
private lastServerEndpoint;
|
|
134
155
|
private lastServerToken;
|
|
135
156
|
private _disconnectEmitted;
|
|
157
|
+
private readonly receiveSubscriptions;
|
|
158
|
+
private readonly requestedSubscriptions;
|
|
159
|
+
private readonly participantTrackSids;
|
|
160
|
+
private readonly activeSpeakers;
|
|
136
161
|
/**
|
|
137
162
|
* @param client - The Fluxer client instance
|
|
138
163
|
* @param channel - The voice channel to connect to
|
|
@@ -156,6 +181,13 @@ declare class LiveKitRtcConnection extends EventEmitter {
|
|
|
156
181
|
setVolume(volumePercent: number): void;
|
|
157
182
|
/** Get current volume (0-200). */
|
|
158
183
|
getVolume(): number;
|
|
184
|
+
private isAudioTrack;
|
|
185
|
+
private getParticipantId;
|
|
186
|
+
private subscribeParticipantTrack;
|
|
187
|
+
subscribeParticipantAudio(participantId: string, options?: {
|
|
188
|
+
autoResubscribe?: boolean;
|
|
189
|
+
}): LiveKitReceiveSubscription;
|
|
190
|
+
private clearReceiveSubscriptions;
|
|
159
191
|
playOpus(_stream: NodeJS.ReadableStream): void;
|
|
160
192
|
/**
|
|
161
193
|
* Connect to the LiveKit room using voice server and state from the gateway.
|
|
@@ -248,6 +280,17 @@ declare class VoiceManager extends EventEmitter {
|
|
|
248
280
|
* @param userId - User ID to look up
|
|
249
281
|
*/
|
|
250
282
|
getVoiceChannelId(guildId: string, userId: string): string | null;
|
|
283
|
+
/**
|
|
284
|
+
* List participant user IDs currently in a specific voice channel.
|
|
285
|
+
*/
|
|
286
|
+
listParticipantsInChannel(guildId: string, channelId: string): string[];
|
|
287
|
+
/**
|
|
288
|
+
* Subscribe to inbound audio for all known participants currently in a voice channel.
|
|
289
|
+
* Only supported for LiveKit connections.
|
|
290
|
+
*/
|
|
291
|
+
subscribeChannelParticipants(channelId: string, opts?: {
|
|
292
|
+
autoResubscribe?: boolean;
|
|
293
|
+
}): LiveKitReceiveSubscription[];
|
|
251
294
|
private handleVoiceStateUpdate;
|
|
252
295
|
private handleVoiceServerUpdate;
|
|
253
296
|
private storeConnectionId;
|
|
@@ -317,4 +360,4 @@ declare function getVoiceManager(client: Client, options?: {
|
|
|
317
360
|
shardId?: number;
|
|
318
361
|
}): VoiceManager;
|
|
319
362
|
|
|
320
|
-
export { LiveKitRtcConnection, type LiveKitRtcConnectionEvents, type VideoPlayOptions, VoiceConnection, type VoiceConnectionEvents, type VoiceConnectionLike, VoiceManager, type VoiceManagerOptions, type VoiceStateMap, getVoiceManager, joinVoiceChannel };
|
|
363
|
+
export { type LiveKitAudioFrame, type LiveKitReceiveSubscription, LiveKitRtcConnection, type LiveKitRtcConnectionEvents, type VideoPlayOptions, VoiceConnection, type VoiceConnectionEvents, type VoiceConnectionLike, VoiceManager, type VoiceManagerOptions, type VoiceStateMap, getVoiceManager, joinVoiceChannel };
|
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,27 @@ type LiveKitRtcConnectionEvents = VoiceConnectionEvents & {
|
|
|
67
67
|
self_stream?: boolean;
|
|
68
68
|
self_video?: boolean;
|
|
69
69
|
}];
|
|
70
|
+
/** Emitted when a remote participant starts speaking. */
|
|
71
|
+
speakerStart: [payload: {
|
|
72
|
+
participantId: string;
|
|
73
|
+
}];
|
|
74
|
+
/** Emitted when a remote participant stops speaking. */
|
|
75
|
+
speakerStop: [payload: {
|
|
76
|
+
participantId: string;
|
|
77
|
+
}];
|
|
78
|
+
/** Emitted for each decoded inbound audio frame. */
|
|
79
|
+
audioFrame: [frame: LiveKitAudioFrame];
|
|
80
|
+
};
|
|
81
|
+
type LiveKitAudioFrame = {
|
|
82
|
+
participantId: string;
|
|
83
|
+
trackSid?: string;
|
|
84
|
+
sampleRate: number;
|
|
85
|
+
channels: number;
|
|
86
|
+
samples: Int16Array;
|
|
87
|
+
};
|
|
88
|
+
type LiveKitReceiveSubscription = {
|
|
89
|
+
participantId: string;
|
|
90
|
+
stop: () => void;
|
|
70
91
|
};
|
|
71
92
|
/**
|
|
72
93
|
* Options for video playback via {@link LiveKitRtcConnection.playVideo}.
|
|
@@ -133,6 +154,10 @@ declare class LiveKitRtcConnection extends EventEmitter {
|
|
|
133
154
|
private lastServerEndpoint;
|
|
134
155
|
private lastServerToken;
|
|
135
156
|
private _disconnectEmitted;
|
|
157
|
+
private readonly receiveSubscriptions;
|
|
158
|
+
private readonly requestedSubscriptions;
|
|
159
|
+
private readonly participantTrackSids;
|
|
160
|
+
private readonly activeSpeakers;
|
|
136
161
|
/**
|
|
137
162
|
* @param client - The Fluxer client instance
|
|
138
163
|
* @param channel - The voice channel to connect to
|
|
@@ -156,6 +181,13 @@ declare class LiveKitRtcConnection extends EventEmitter {
|
|
|
156
181
|
setVolume(volumePercent: number): void;
|
|
157
182
|
/** Get current volume (0-200). */
|
|
158
183
|
getVolume(): number;
|
|
184
|
+
private isAudioTrack;
|
|
185
|
+
private getParticipantId;
|
|
186
|
+
private subscribeParticipantTrack;
|
|
187
|
+
subscribeParticipantAudio(participantId: string, options?: {
|
|
188
|
+
autoResubscribe?: boolean;
|
|
189
|
+
}): LiveKitReceiveSubscription;
|
|
190
|
+
private clearReceiveSubscriptions;
|
|
159
191
|
playOpus(_stream: NodeJS.ReadableStream): void;
|
|
160
192
|
/**
|
|
161
193
|
* Connect to the LiveKit room using voice server and state from the gateway.
|
|
@@ -248,6 +280,17 @@ declare class VoiceManager extends EventEmitter {
|
|
|
248
280
|
* @param userId - User ID to look up
|
|
249
281
|
*/
|
|
250
282
|
getVoiceChannelId(guildId: string, userId: string): string | null;
|
|
283
|
+
/**
|
|
284
|
+
* List participant user IDs currently in a specific voice channel.
|
|
285
|
+
*/
|
|
286
|
+
listParticipantsInChannel(guildId: string, channelId: string): string[];
|
|
287
|
+
/**
|
|
288
|
+
* Subscribe to inbound audio for all known participants currently in a voice channel.
|
|
289
|
+
* Only supported for LiveKit connections.
|
|
290
|
+
*/
|
|
291
|
+
subscribeChannelParticipants(channelId: string, opts?: {
|
|
292
|
+
autoResubscribe?: boolean;
|
|
293
|
+
}): LiveKitReceiveSubscription[];
|
|
251
294
|
private handleVoiceStateUpdate;
|
|
252
295
|
private handleVoiceServerUpdate;
|
|
253
296
|
private storeConnectionId;
|
|
@@ -317,4 +360,4 @@ declare function getVoiceManager(client: Client, options?: {
|
|
|
317
360
|
shardId?: number;
|
|
318
361
|
}): VoiceManager;
|
|
319
362
|
|
|
320
|
-
export { LiveKitRtcConnection, type LiveKitRtcConnectionEvents, type VideoPlayOptions, VoiceConnection, type VoiceConnectionEvents, type VoiceConnectionLike, VoiceManager, type VoiceManagerOptions, type VoiceStateMap, getVoiceManager, joinVoiceChannel };
|
|
363
|
+
export { type LiveKitAudioFrame, type LiveKitReceiveSubscription, LiveKitRtcConnection, type LiveKitRtcConnectionEvents, type VideoPlayOptions, VoiceConnection, type VoiceConnectionEvents, type VoiceConnectionLike, VoiceManager, type VoiceManagerOptions, type VoiceStateMap, getVoiceManager, joinVoiceChannel };
|