diff options
| author | salmonik <salmonik@tuta.io> | 2026-09-09 12:50:56 +0200 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-09-09 12:50:56 +0200 |
| commit | 5eea9f2fef1a840f9c9e6ec6d471fe4f87f1d1fd (patch) | |
| tree | 8172563321f0737df9426bbd577c0a18bef9471f /src/commands/music.rs | |
| parent | feat: piper now not a subprocess, cache system for TTS (diff) | |
| download | senator-sperma-5eea9f2fef1a840f9c9e6ec6d471fe4f87f1d1fd.tar.gz senator-sperma-5eea9f2fef1a840f9c9e6ec6d471fe4f87f1d1fd.zip | |
make /grajcuj w\ compress finally work as compressing a file and then
/grajcuj'ing
Signed-off-by: salmonik <salmonik@tuta.io>
Diffstat (limited to 'src/commands/music.rs')
| -rw-r--r-- | src/commands/music.rs | 21 |
1 files changed, 18 insertions, 3 deletions
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( | |||
| 305 | } | 305 | } |
| 306 | }; | 306 | }; |
| 307 | 307 | ||
| 308 | info!("degrading audio ({} bytes)", audio_bytes.len()); | 308 | info!("compressing audio ({} bytes)", audio_bytes.len()); |
| 309 | let degraded = crate::voice::degrade_audio(&audio_bytes).await?; | 309 | let compressed_bytes = |
| 310 | crate::commands::utilities::compress_audio_bytes(&audio_bytes, &src.display_name) | ||
| 311 | .await | ||
| 312 | .ok_or_else(|| Error::Custom("compression failed".into()))?; | ||
| 313 | info!("compressed to {} bytes", compressed_bytes.len()); | ||
| 314 | |||
| 315 | // Decode the compressed OGG via ffmpeg (symphonia lacks Opus support). | ||
| 316 | // Write to temp file, then stream through ffmpeg to raw PCM. | ||
| 317 | let compressed_path = format!( | ||
| 318 | "{}/play_compressed_{}.ogg", | ||
| 319 | crate::config::TEMP_PATH, | ||
| 320 | uuid::Uuid::new_v4() | ||
| 321 | ); | ||
| 322 | let _ = tokio::fs::create_dir_all(crate::config::TEMP_PATH).await; | ||
| 323 | tokio::fs::write(&compressed_path, &compressed_bytes).await?; | ||
| 324 | let decoded = crate::voice::ffmpeg_decode_file(&compressed_path).await?; | ||
| 310 | 325 | ||
| 311 | // Deferred stop: only interrupt current track now that we're ready. | 326 | // Deferred stop: only interrupt current track now that we're ready. |
| 312 | { | 327 | { |
| @@ -320,7 +335,7 @@ async fn play_impl( | |||
| 320 | .voice_manager | 335 | .voice_manager |
| 321 | .connect(guild_id, channel_id) | 336 | .connect(guild_id, channel_id) |
| 322 | .await?; | 337 | .await?; |
| 323 | input = degraded; | 338 | input = decoded; |
| 324 | } else { | 339 | } else { |
| 325 | // ── Normal path: stop first, then stream/download ────────── | 340 | // ── Normal path: stop first, then stream/download ────────── |
| 326 | { | 341 | { |
