Address remaining review items (queue, selfbot v6 API, ldconfig, resample)
Some checks failed
Release / semantic-release (push) Successful in 22s
tests / Unit tests (Linux, Python 3.11) (push) Successful in 9m56s
Release / build-linux (push) Failing after 7m15s
Release / build-windows (push) Has been cancelled
Release / build-macos (arm64, macos-latest) (push) Has been cancelled
Release / build-macos (x64, macos-15-intel) (push) Has been cancelled
Release / release-main (push) Has been cancelled
Release / release-develop (push) Has been cancelled

- voice.ts: reply playback is now a FIFO queue (AudioPlayerStatus.Idle drains
  it) so concurrent speakers no longer cut each other's replies off.
- selfbot.ts: rewritten against the REAL @dank074/discord-video-stream v6 API
  (verified from its d.ts): prepareStream(input, opts, signal)->{command,output},
  playStream(output, streamer, {type:"go-live"}, signal), Streamer.joinVoice.
  x11grab via customInputOptions; optional NVENC encode (RTX 5050) via exported
  `nvenc`. package.json pinned to ^6.0.0 (was a wrong ^4.2.1).
- Dockerfile: dropped the hardcoded python3.12 LD_LIBRARY_PATH. faster-whisper
  >=1.1 self-locates the pip CUDA libs; ldconfig (full path, glob) registers
  them as a robust fallback. Verified: ld.so cache lists libcublas/libcudnn and
  GPU whisper works with LD_LIBRARY_PATH empty.
- bridge: STT resample 48k->16k upgraded from nearest-neighbor to linear
  (np.interp).

Verified: tsc clean, image builds, GPU whisper OK via ldconfig, compose valid.
This commit is contained in:
javis-bot
2026-06-09 18:47:25 +09:00
parent 964123682f
commit b56c9c7721
7 changed files with 417 additions and 50 deletions

View File

@@ -15,6 +15,7 @@ import {
createAudioResource,
EndBehaviorType,
StreamType,
AudioPlayerStatus,
VoiceConnection,
VoiceConnectionStatus,
entersState,
@@ -65,6 +66,9 @@ export class VoiceSession {
private connection: VoiceConnection;
private player: AudioPlayer;
private listening = new Set<string>();
/** Pending reply clips. Played one at a time so concurrent speakers don't
* cut each other's replies off. */
private playQueue: Buffer[] = [];
/** Optional callback to surface transcripts/replies to a text channel. */
onTurn?: (info: { user: string; transcript: string; reply: string }) => void;
@@ -79,6 +83,8 @@ export class VoiceSession {
});
this.player = createAudioPlayer();
this.connection.subscribe(this.player);
// Drain the queue when the current clip finishes.
this.player.on(AudioPlayerStatus.Idle, () => this.pump());
this.attachReceiver();
}
@@ -128,9 +134,17 @@ export class VoiceSession {
}
}
/** Play a WAV buffer into the channel. */
/** Queue a WAV buffer for playback (FIFO, one clip at a time). */
play(wav: Buffer) {
const resource = createAudioResource(Readable.from(wav), {
this.playQueue.push(wav);
this.pump();
}
private pump() {
if (this.player.state.status !== AudioPlayerStatus.Idle) return;
const next = this.playQueue.shift();
if (!next) return;
const resource = createAudioResource(Readable.from(next), {
inputType: StreamType.Arbitrary,
});
this.player.play(resource);