From 5eea9f2fef1a840f9c9e6ec6d471fe4f87f1d1fd Mon Sep 17 00:00:00 2001 From: salmonik Date: Wed, 9 Sep 2026 12:50:56 +0200 Subject: make /grajcuj w\ compress finally work as compressing a file and then /grajcuj'ing Signed-off-by: salmonik --- src/commands/music.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/commands/music.rs') diff --git a/src/commands/music.rs b/src/commands/music.rs index 6acac00..019a015 100644 --- a/src/commands/music.rs +++ b/src/commands/music.rs @@ -305,8 +305,23 @@ async fn play_impl( } }; - info!("degrading audio ({} bytes)", audio_bytes.len()); - let degraded = crate::voice::degrade_audio(&audio_bytes).await?; + info!("compressing audio ({} bytes)", audio_bytes.len()); + let compressed_bytes = + crate::commands::utilities::compress_audio_bytes(&audio_bytes, &src.display_name) + .await + .ok_or_else(|| Error::Custom("compression failed".into()))?; + info!("compressed to {} bytes", compressed_bytes.len()); + + // Decode the compressed OGG via ffmpeg (symphonia lacks Opus support). + // Write to temp file, then stream through ffmpeg to raw PCM. + let compressed_path = format!( + "{}/play_compressed_{}.ogg", + crate::config::TEMP_PATH, + uuid::Uuid::new_v4() + ); + let _ = tokio::fs::create_dir_all(crate::config::TEMP_PATH).await; + tokio::fs::write(&compressed_path, &compressed_bytes).await?; + let decoded = crate::voice::ffmpeg_decode_file(&compressed_path).await?; // Deferred stop: only interrupt current track now that we're ready. { @@ -320,7 +335,7 @@ async fn play_impl( .voice_manager .connect(guild_id, channel_id) .await?; - input = degraded; + input = decoded; } else { // ── Normal path: stop first, then stream/download ────────── { -- cgit v1.2.3