diff options
| author | salmonik <salmonik@tuta.io> | 2026-09-09 14:36:50 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-09-09 14:36:50 +0200 |
| commit | 0d1fdab3a10b30d83da50b7f20acc18b7a350a22 (patch) | |
| tree | 2c463b26add0a50bd7150c7eeee665d315a988d2 /src/main.rs | |
| parent | first draft (diff) | |
| download | senator-sperma-0d1fdab3a10b30d83da50b7f20acc18b7a350a22.tar.gz senator-sperma-0d1fdab3a10b30d83da50b7f20acc18b7a350a22.zip | |
wire recording into voice manager, config, events, /record command
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 22 |
1 files changed, 20 insertions, 2 deletions
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; | |||
| 14 | mod events; | 14 | mod events; |
| 15 | mod lang; | 15 | mod lang; |
| 16 | mod openrouter; | 16 | mod openrouter; |
| 17 | mod recording; | ||
| 17 | mod tasks; | 18 | mod tasks; |
| 18 | mod tts; | 19 | mod tts; |
| 19 | mod voice; | 20 | mod voice; |
| @@ -185,7 +186,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 185 | let copyparty = copyparty.clone(); | 186 | let copyparty = copyparty.clone(); |
| 186 | let triggers = triggers.clone(); | 187 | let triggers = triggers.clone(); |
| 187 | Box::pin(async move { | 188 | Box::pin(async move { |
| 188 | let vm = voice::VoiceManager::new(ctx).await?; | 189 | let vm = voice::VoiceManager::new( |
| 190 | ctx, | ||
| 191 | config.recording_enabled, | ||
| 192 | config.recording_window_seconds, | ||
| 193 | ) | ||
| 194 | .await?; | ||
| 189 | 195 | ||
| 190 | let music_tracks: Arc<tokio::sync::Mutex<HashMap<u64, songbird::tracks::TrackHandle>>> = Arc::new(tokio::sync::Mutex::new(HashMap::new())); | 196 | let music_tracks: Arc<tokio::sync::Mutex<HashMap<u64, songbird::tracks::TrackHandle>>> = Arc::new(tokio::sync::Mutex::new(HashMap::new())); |
| 191 | 197 | ||
| @@ -231,10 +237,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | |||
| 231 | }) | 237 | }) |
| 232 | .build(); | 238 | .build(); |
| 233 | 239 | ||
| 240 | // Configure songbird: when recording is enabled, decode incoming voice to | ||
| 241 | // mono 48 kHz i16 so that `CoreEvent::VoiceTick` carries `decoded_voice` | ||
| 242 | // (without this, `decoded_voice` is `None` and there's nothing to record). | ||
| 243 | let mut songbird_config = songbird::Config::default(); | ||
| 244 | if config_for_client.recording_enabled { | ||
| 245 | songbird_config.decode_mode = | ||
| 246 | songbird::driver::DecodeMode::Decode(songbird::driver::DecodeConfig::new( | ||
| 247 | songbird::driver::Channels::Mono, | ||
| 248 | songbird::driver::SampleRate::Hz48000, | ||
| 249 | )); | ||
| 250 | } | ||
| 251 | |||
| 234 | let mut client = | 252 | let mut client = |
| 235 | serenity::ClientBuilder::new(&config_for_client.token, serenity::GatewayIntents::all()) | 253 | serenity::ClientBuilder::new(&config_for_client.token, serenity::GatewayIntents::all()) |
| 236 | .framework(framework) | 254 | .framework(framework) |
| 237 | .register_songbird() | 255 | .register_songbird_from_config(songbird_config) |
| 238 | .await?; | 256 | .await?; |
| 239 | 257 | ||
| 240 | client.start().await?; | 258 | client.start().await?; |
