aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-04 01:30:44 +0100
committersalmonik <salmonik@tuta.io>2026-11-04 01:30:44 +0100
commit292043102d7266b3a0665aed3c55c9d3b945754c (patch)
tree9254dc3b2083373174a6e852db95791a4da7c3c6
parentqr: cap image dimensions and allocation (diff)
downloadsenator-sperma-292043102d7266b3a0665aed3c55c9d3b945754c.tar.gz
senator-sperma-292043102d7266b3a0665aed3c55c9d3b945754c.zip
tts: attach the generated WAV without a temp file
-rw-r--r--src/commands/tts.rs14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/commands/tts.rs b/src/commands/tts.rs
index f45d2e8..28e4443 100644
--- a/src/commands/tts.rs
+++ b/src/commands/tts.rs
@@ -30,21 +30,13 @@ pub async fn tts(
30 match output { 30 match output {
31 OutputMode::File => { 31 OutputMode::File => {
32 let wav = crate::tts::encode_wav(&audio_data, 48000, 2); 32 let wav = crate::tts::encode_wav(&audio_data, 48000, 2);
33 33 // Attach the bytes directly: no temp file to leak and no panic if
34 tokio::fs::create_dir_all(crate::config::TEMP_PATH) 34 // an external cleaner removes it between write and attach.
35 .await
36 .ok();
37 let path = format!(
38 "{}/tts_{}.wav",
39 crate::config::TEMP_PATH,
40 uuid::Uuid::new_v4(),
41 );
42 tokio::fs::write(&path, &wav).await?;
43 if let Err(e) = ctx 35 if let Err(e) = ctx
44 .send( 36 .send(
45 poise::CreateReply::default() 37 poise::CreateReply::default()
46 .content(lang::L_TTS_SAVED) 38 .content(lang::L_TTS_SAVED)
47 .attachment(serenity::CreateAttachment::path(&path).await.unwrap()), 39 .attachment(serenity::CreateAttachment::bytes(wav, "tts.wav")),
48 ) 40 )
49 .await 41 .await
50 { 42 {