From 0d1fdab3a10b30d83da50b7f20acc18b7a350a22 Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 9 Sep 2026 14:36:50 +0200 Subject: wire recording into voice manager, config, events, /record command --- src/main.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 5ab33ab..8225751 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ mod error; mod events; mod lang; mod openrouter; +mod recording; mod tasks; mod tts; mod voice; @@ -185,7 +186,12 @@ async fn main() -> Result<(), Box> { let copyparty = copyparty.clone(); let triggers = triggers.clone(); Box::pin(async move { - let vm = voice::VoiceManager::new(ctx).await?; + let vm = voice::VoiceManager::new( + ctx, + config.recording_enabled, + config.recording_window_seconds, + ) + .await?; let music_tracks: Arc>> = Arc::new(tokio::sync::Mutex::new(HashMap::new())); @@ -231,10 +237,22 @@ async fn main() -> Result<(), Box> { }) .build(); + // Configure songbird: when recording is enabled, decode incoming voice to + // mono 48 kHz i16 so that `CoreEvent::VoiceTick` carries `decoded_voice` + // (without this, `decoded_voice` is `None` and there's nothing to record). + let mut songbird_config = songbird::Config::default(); + if config_for_client.recording_enabled { + songbird_config.decode_mode = + songbird::driver::DecodeMode::Decode(songbird::driver::DecodeConfig::new( + songbird::driver::Channels::Mono, + songbird::driver::SampleRate::Hz48000, + )); + } + let mut client = serenity::ClientBuilder::new(&config_for_client.token, serenity::GatewayIntents::all()) .framework(framework) - .register_songbird() + .register_songbird_from_config(songbird_config) .await?; client.start().await?; -- cgit v1.2.3