summaryrefslogtreecommitdiff
path: root/makima/src/tts/chatterbox.rs
diff options
context:
space:
mode:
authorsoryu <soryu@soryu.co>2026-01-28 03:49:13 +0000
committersoryu <soryu@soryu.co>2026-01-28 03:49:54 +0000
commitd0436686f047f1d82c30da26cf83f9eca6727292 (patch)
treef4f7b6bc7c6cc410d90908d3adf7c519bdf6a2ad /makima/src/tts/chatterbox.rs
parentc3de071511de5e8a8d63ea4ca47c815cb6450215 (diff)
downloadsoryu-d0436686f047f1d82c30da26cf83f9eca6727292.tar.gz
soryu-d0436686f047f1d82c30da26cf83f9eca6727292.zip
feat: add inference cancellation support for TTS generation
Add cooperative cancellation via Arc<AtomicBool> 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 <noreply@anthropic.com>
Diffstat (limited to 'makima/src/tts/chatterbox.rs')
-rw-r--r--makima/src/tts/chatterbox.rs4
1 files changed, 3 insertions, 1 deletions
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<u32>,
+ _cancel_flag: Option<Arc<AtomicBool>>,
) -> Result<Vec<AudioChunk>, TtsError> {
let samples = match reference_audio {
Some(audio) => {