From b252c39517b9fce181d1a0fe4761404c7d981397 Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 18 Aug 2026 23:18:37 +0200 Subject: feat: local TTS via piper subprocess with Google fallback - New src/tts.rs: centralize TTS in synthesize(config, http_client, text) Piper subprocess primary, Google Translate fallback on error/missing - TTS_MODEL_PATH/TTS_VOICE env config (defaults to pl_PL-bass-high) - Fix Unknown interaction errors: spawn play_tts_in_channel in background so voice-state TTS no longer blocks the shard event loop (3s Discord limit) - Best-effort confirmation replies in /tts to prevent error cascade - Custom on_error handler: graceful interaction-expired error handling - Comprehensive tracing logging (engine, model, duration, stderr) --- src/commands/ai.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'src/commands/ai.rs') diff --git a/src/commands/ai.rs b/src/commands/ai.rs index a7a9a7e..61fb471 100644 --- a/src/commands/ai.rs +++ b/src/commands/ai.rs @@ -30,18 +30,8 @@ pub async fn senator( }) .ok_or_else(lang::err_not_in_voice)?; - let tts_url = format!( - "https://translate.google.com/translate_tts?ie=UTF-8&q={}&tl=pl&client=tw-ob", - crate::commands::tts::urlencoding(&response) - ); - let audio_data = ctx - .data() - .http_client - .get(&tts_url) - .send() - .await? - .bytes() - .await?; + let (audio_data, _) = + crate::tts::synthesize(&ctx.data().config, &ctx.data().http_client, &response).await?; let call = ctx .data() -- cgit v1.2.3