feat: add local audio test mode
This commit is contained in:
@@ -8,8 +8,10 @@ import {
|
||||
NoSubscriberBehavior,
|
||||
VoiceConnectionStatus,
|
||||
createAudioPlayer,
|
||||
createAudioResource,
|
||||
entersState,
|
||||
joinVoiceChannel,
|
||||
StreamType,
|
||||
type AudioPlayer,
|
||||
type AudioReceiveStream,
|
||||
type VoiceConnection,
|
||||
@@ -21,7 +23,7 @@ import { Logger } from "../logger.js";
|
||||
import { float32ToPcm16Buffer, int16ArrayToFloat32, Stereo48kToMono16kDownsampler, takeFrame } from "./pcm.js";
|
||||
import { ConversationMemory, type UserUtterance } from "../services/conversation.js";
|
||||
import { ElevenLabsSttService } from "../services/elevenlabs-stt.js";
|
||||
import { ElevenLabsTtsService, type PreparedSpeechPlayback } from "../services/elevenlabs-tts.js";
|
||||
import { ElevenLabsTtsService, type PreparedSpeechAudio } from "../services/elevenlabs-tts.js";
|
||||
import { OpenAiLlmService } from "../services/openai-llm.js";
|
||||
|
||||
interface GuildVoiceSessionOptions {
|
||||
@@ -167,7 +169,7 @@ export class GuildVoiceSession extends EventEmitter {
|
||||
|
||||
private draining = false;
|
||||
private currentAbortController: AbortController | null = null;
|
||||
private currentPlayback: PreparedSpeechPlayback | null = null;
|
||||
private currentPlayback: PreparedSpeechAudio | null = null;
|
||||
private textChannelId?: string;
|
||||
|
||||
private constructor(private readonly options: GuildVoiceSessionOptions) {
|
||||
@@ -415,7 +417,9 @@ export class GuildVoiceSession extends EventEmitter {
|
||||
}
|
||||
|
||||
try {
|
||||
const resource = this.currentPlayback.resource;
|
||||
const resource = createAudioResource(this.currentPlayback.stream, {
|
||||
inputType: StreamType.Raw,
|
||||
});
|
||||
this.player.play(resource);
|
||||
|
||||
await entersState(this.player, AudioPlayerStatus.Playing, 20_000).catch(() => null);
|
||||
|
||||
Reference in New Issue
Block a user