From d0436686f047f1d82c30da26cf83f9eca6727292 Mon Sep 17 00:00:00 2001 From: soryu Date: Wed, 28 Jan 2026 03:49:13 +0000 Subject: feat: add inference cancellation support for TTS generation Add cooperative cancellation via Arc cancel flag that threads through TtsEngine::generate -> Qwen3Tts -> GenerationContext. The autoregressive loop and streaming decoder check the flag each iteration and break early when set. The speak WebSocket handler creates a per-session flag, passes it to generate, and sets it on Cancel/Stop/Close messages. Co-Authored-By: Claude Opus 4.5 --- makima/src/tts/chatterbox.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'makima/src/tts/chatterbox.rs') diff --git a/makima/src/tts/chatterbox.rs b/makima/src/tts/chatterbox.rs index e26bc06..712910f 100644 --- a/makima/src/tts/chatterbox.rs +++ b/makima/src/tts/chatterbox.rs @@ -6,7 +6,8 @@ use std::borrow::Cow; use std::fs; use std::path::{Path, PathBuf}; -use std::sync::Mutex; +use std::sync::atomic::AtomicBool; +use std::sync::{Arc, Mutex}; use hf_hub::api::sync::Api; use ndarray::{Array2, Array3, Array4, ArrayD, IxDyn}; @@ -427,6 +428,7 @@ impl TtsEngine for ChatterboxTTS { text: &str, reference_audio: Option<&[f32]>, reference_sample_rate: Option, + _cancel_flag: Option>, ) -> Result, TtsError> { let samples = match reference_audio { Some(audio) => { -- cgit v1.2.3