pub struct TtsModelExecutor { /* private fields */ }Expand description
Qwen3-TTS executor: text-to-speech synthesis.
Implementations§
Source§impl TtsModelExecutor
impl TtsModelExecutor
Sourcepub fn from_path(
model_path: &str,
device: CandleDevice,
dtype: DType,
) -> Result<Self>
pub fn from_path( model_path: &str, device: CandleDevice, dtype: DType, ) -> Result<Self>
Load from model directory containing:
- config.json (TalkerConfig)
- model.safetensors (Talker weights)
- speech_tokenizer/model.safetensors (Vocoder weights)
- tokenizer_config.json + vocab.json + merges.txt (text tokenizer)
Sourcepub fn synthesize(&mut self, text: &str, language: &str) -> Result<Vec<f32>>
pub fn synthesize(&mut self, text: &str, language: &str) -> Result<Vec<f32>>
Synthesize speech from text.
Returns PCM samples at 24kHz as Vec
Prompt structure (matches Python/qwen3-tts-rs): Prefill: [role_prefix(3)] + [tts_text_prefix(6) + codec_prefix(6)] + [first_text + codec_bos] Trailing: text_projection(remaining_text + tts_eos) — added per decode step
Sourcepub fn synthesize_streaming<F: FnMut(usize, &[f32])>(
&mut self,
text: &str,
language: &str,
chunk_frames: usize,
on_chunk: F,
) -> Result<Vec<Vec<f32>>>
pub fn synthesize_streaming<F: FnMut(usize, &[f32])>( &mut self, text: &str, language: &str, chunk_frames: usize, on_chunk: F, ) -> Result<Vec<Vec<f32>>>
Streaming TTS: calls on_chunk with each audio chunk as soon as it’s ready.
Each chunk is chunk_frames codec frames decoded to audio (~800ms at default 10 frames).
First chunk arrives after chunk_frames decode steps (~2-3s for 0.6B).
Sourcepub fn sample_rate(&self) -> usize
pub fn sample_rate(&self) -> usize
Get the output sample rate.
pub fn config(&self) -> &TalkerConfig
Sourcepub fn synthesize_voice_clone(
&mut self,
text: &str,
language: &str,
ref_audio_path: &str,
ref_text: &str,
) -> Result<Vec<f32>>
pub fn synthesize_voice_clone( &mut self, text: &str, language: &str, ref_audio_path: &str, ref_text: &str, ) -> Result<Vec<f32>>
Synthesize speech with voice cloning from a reference audio.
Uses ICL (in-context learning) prompting: the reference audio is encoded to codec tokens and prepended to the generation prompt, along with a speaker embedding extracted via ECAPA-TDNN.
Returns PCM samples at 24kHz as Vec
Trait Implementations§
Source§impl ModelExecutor for TtsModelExecutor
impl ModelExecutor for TtsModelExecutor
Source§fn prefill<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 PrefillInput,
) -> Pin<Box<dyn Future<Output = Result<PrefillOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn prefill<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 PrefillInput,
) -> Pin<Box<dyn Future<Output = Result<PrefillOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn decode<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 DecodeInput,
) -> Pin<Box<dyn Future<Output = Result<DecodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn decode<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 DecodeInput,
) -> Pin<Box<dyn Future<Output = Result<DecodeOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn capabilities(&self) -> ExecutorCapabilities
fn capabilities(&self) -> ExecutorCapabilities
Source§fn release_cache(&self, _: &str)
fn release_cache(&self, _: &str)
Source§fn status(&self) -> ExecutorStatus
fn status(&self) -> ExecutorStatus
PlanRuntime must return the shared
runtime’s opaque cache handle from prefill/decode and delegate release
of that authority from release_cache.Source§fn admission_limits(
&self,
) -> Result<Option<ExecutorAdmissionLimits>, FerrumError>
fn admission_limits( &self, ) -> Result<Option<ExecutorAdmissionLimits>, FerrumError>
Some; legacy executors may defer to
the engine-owned scheduler and recurrent-state limits.Source§fn resolved_model_plan(&self) -> Option<&ResolvedModelPlan>
fn resolved_model_plan(&self) -> Option<&ResolvedModelPlan>
None; PlanRuntime executors must expose the
exact plan used for provisioning and dispatch.Source§fn plan_runtime_resource_snapshot(
&self,
) -> Result<Option<PlanRuntimeResourceSnapshot>, FerrumError>
fn plan_runtime_resource_snapshot( &self, ) -> Result<Option<PlanRuntimeResourceSnapshot>, FerrumError>
LegacyEngine executors return None; PlanRuntime executors must
return Some while they are ready.Source§fn supports_native_unified_decode(&self) -> bool
fn supports_native_unified_decode(&self) -> bool
cfg(target_os) branch that
previously hard-coded “Metal/CPU lack native unified” in the hot path. Read moreSource§fn kv_capacity(&self) -> Option<usize>
fn kv_capacity(&self) -> Option<usize>
Source§fn attach_execution_event_sink(&self, _sink: Arc<dyn ExecutionEventSink>)
fn attach_execution_event_sink(&self, _sink: Arc<dyn ExecutionEventSink>)
Source§fn execution_capacity_epochs(
&self,
) -> Result<Option<ExecutorAdmissionEpochs>, FerrumError>
fn execution_capacity_epochs( &self, ) -> Result<Option<ExecutorAdmissionEpochs>, FerrumError>
None; an executor declaring
ExecutionResourceAuthority::PlanRuntime must return Some.Source§fn write_execution_capacity_snapshot(
&self,
availability: &mut Vec<CapacityAvailabilityEpoch>,
) -> Result<Option<ExecutorAdmissionEpochs>, FerrumError>
fn write_execution_capacity_snapshot( &self, availability: &mut Vec<CapacityAvailabilityEpoch>, ) -> Result<Option<ExecutorAdmissionEpochs>, FerrumError>
Source§fn register_execution_capacity_waiter(
&self,
_observed: &CapacityWaitCondition,
) -> Result<Option<ExecutorCapacityWaitRegistration>, FerrumError>
fn register_execution_capacity_waiter( &self, _observed: &CapacityWaitCondition, ) -> Result<Option<ExecutorCapacityWaitRegistration>, FerrumError>
Source§fn try_admit_prefill(
&self,
_input: ExecutorPrefillAdmission<'_>,
) -> Result<ExecutorPrefillAdmissionDecision, FerrumError>
fn try_admit_prefill( &self, _input: ExecutorPrefillAdmission<'_>, ) -> Result<ExecutorPrefillAdmissionDecision, FerrumError>
Source§fn cancel_prefill_admission(&self, _request_id: &RequestId) -> bool
fn cancel_prefill_admission(&self, _request_id: &RequestId) -> bool
Source§fn write_execution_capacity_release_sources(
&self,
_preemption: &ExecutorExecutionCapacityPreemption,
sources: &mut Vec<CapacityAvailabilitySource>,
) -> Result<bool, FerrumError>
fn write_execution_capacity_release_sources( &self, _preemption: &ExecutorExecutionCapacityPreemption, sources: &mut Vec<CapacityAvailabilitySource>, ) -> Result<bool, FerrumError>
Source§fn preempt_execution_capacity<'life0, 'async_trait>(
&'life0 self,
_preemption: ExecutorExecutionCapacityPreemption,
) -> Pin<Box<dyn Future<Output = Result<ExecutorExecutionCapacityPreemptionReceipt, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn preempt_execution_capacity<'life0, 'async_trait>(
&'life0 self,
_preemption: ExecutorExecutionCapacityPreemption,
) -> Pin<Box<dyn Future<Output = Result<ExecutorExecutionCapacityPreemptionReceipt, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn maintain_prefill_backing(
&self,
_request_id: &RequestId,
) -> Result<ExecutorPrefillMaintenanceOutcome, FerrumError>
fn maintain_prefill_backing( &self, _request_id: &RequestId, ) -> Result<ExecutorPrefillMaintenanceOutcome, FerrumError>
Source§fn reserve_kv_slots(
&self,
_requests: &[KvSlotRequest],
) -> Result<Option<KvSlotReservation>, FerrumError>
fn reserve_kv_slots( &self, _requests: &[KvSlotRequest], ) -> Result<Option<KvSlotReservation>, FerrumError>
Source§fn kv_slot_capacity_snapshot(&self) -> Option<KvSlotCapacitySnapshot>
fn kv_slot_capacity_snapshot(&self) -> Option<KvSlotCapacitySnapshot>
Source§fn recurrent_state_spec(
&self,
_request_id: &RequestId,
_input_tokens: &[TokenId],
) -> Result<Option<RecurrentStateSpec>, FerrumError>
fn recurrent_state_spec( &self, _request_id: &RequestId, _input_tokens: &[TokenId], ) -> Result<Option<RecurrentStateSpec>, FerrumError>
Source§fn prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 PrefillInput,
) -> Pin<Box<dyn Future<Output = Result<ExecutorPrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
input: &'life1 PrefillInput,
) -> Pin<Box<dyn Future<Output = Result<ExecutorPrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn batch_prefill<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [PrefillInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<PrefillOutput>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn batch_prefill<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [PrefillInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<PrefillOutput>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn batch_prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: &'life1 [PrefillInput],
) -> Pin<Box<dyn Future<Output = Result<ExecutorBatchPrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn batch_prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: &'life1 [PrefillInput],
) -> Pin<Box<dyn Future<Output = Result<ExecutorBatchPrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn plan_runtime_prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 PlanRuntimePrefillInput,
) -> Pin<Box<dyn Future<Output = Result<PlanRuntimePrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn plan_runtime_prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 PlanRuntimePrefillInput,
) -> Pin<Box<dyn Future<Output = Result<PlanRuntimePrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
ExecutionResourceAuthority::PlanRuntime. Read moreSource§fn plan_runtime_batch_prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: &'life1 [PlanRuntimePrefillInput],
) -> Pin<Box<dyn Future<Output = Result<PlanRuntimeBatchPrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn plan_runtime_batch_prefill_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: &'life1 [PlanRuntimePrefillInput],
) -> Pin<Box<dyn Future<Output = Result<PlanRuntimeBatchPrefillOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn discard_plan_runtime_prefill(
&self,
authority: PlanRuntimePrefillAuthority,
) -> Result<(), FerrumError>
fn discard_plan_runtime_prefill( &self, authority: PlanRuntimePrefillAuthority, ) -> Result<(), FerrumError>
Source§fn batch_decode<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [DecodeInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<DecodeOutput>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn batch_decode<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [DecodeInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<DecodeOutput>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn batch_decode_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [DecodeInput],
) -> Pin<Box<dyn Future<Output = Result<ExecutorBatchDecodeOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn batch_decode_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [DecodeInput],
) -> Pin<Box<dyn Future<Output = Result<ExecutorBatchDecodeOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn plan_runtime_batch_decode_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: &'life1 [PlanRuntimeDecodeInput],
) -> Pin<Box<dyn Future<Output = Result<PlanRuntimeBatchDecodeOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn plan_runtime_batch_decode_with_capacity<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: &'life1 [PlanRuntimeDecodeInput],
) -> Pin<Box<dyn Future<Output = Result<PlanRuntimeBatchDecodeOutcome, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
ExecutionResourceAuthority::PlanRuntime. Read moreSource§fn unified_decode<'life0, 'life1, 'async_trait>(
&'life0 self,
_batch: &'life1 UnifiedBatch,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<f32>>>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unified_decode<'life0, 'life1, 'async_trait>(
&'life0 self,
_batch: &'life1 UnifiedBatch,
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<f32>>>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
UnifiedBatch containing
any combination of prefill chunks (one or more q_tokens per item,
possibly continuing from pos_offset > 0) and decode steps
(q_tokens.len() == 1, is_final_chunk = true) in a single model
forward pass. Read moreSource§fn forward<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 Arc<dyn TensorLike>,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn TensorLike>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn forward<'life0, 'life1, 'async_trait>(
&'life0 self,
_input: &'life1 Arc<dyn TensorLike>,
) -> Pin<Box<dyn Future<Output = Result<Arc<dyn TensorLike>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Source§fn truncate_kv<'life0, 'life1, 'async_trait>(
&'life0 self,
_kv_cache: &'life1 Arc<dyn KvCacheHandle>,
_new_len: usize,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn truncate_kv<'life0, 'life1, 'async_trait>(
&'life0 self,
_kv_cache: &'life1 Arc<dyn KvCacheHandle>,
_new_len: usize,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
new_len.
Used by speculative decoding on partial rejection so the next
iteration sees a KV prefix that matches the accepted token stream.
Default: Ok(()) — executors that don’t cache per-sequence state
(stub, mock) are inherently tolerant; real LLM executors override.Source§fn forward_verify<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [DecodeInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<DecodeOutput>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn forward_verify<'life0, 'life1, 'async_trait>(
&'life0 self,
inputs: &'life1 [DecodeInput],
) -> Pin<Box<dyn Future<Output = Result<Vec<DecodeOutput>, FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
N+1 tokens,
producing one logits row per position. Used by speculative
decoding’s target path so we don’t pay N+1 sequential forwards. Read moreSource§fn cache_metrics_snapshot(&self) -> Option<Value>
fn cache_metrics_snapshot(&self) -> Option<Value>
Source§fn lora_metrics_snapshot(&self) -> Option<Value>
fn lora_metrics_snapshot(&self) -> Option<Value>
Source§fn prepare_startup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn prepare_startup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn warmup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn warmup<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), FerrumError>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Source§fn complete_cache(
&self,
completion: ExecutorSequenceCompletion,
) -> Result<(), FerrumError>
fn complete_cache( &self, completion: ExecutorSequenceCompletion, ) -> Result<(), FerrumError>
Auto Trait Implementations§
impl !Freeze for TtsModelExecutor
impl !RefUnwindSafe for TtsModelExecutor
impl !UnwindSafe for TtsModelExecutor
impl Send for TtsModelExecutor
impl Sync for TtsModelExecutor
impl Unpin for TtsModelExecutor
impl UnsafeUnpin for TtsModelExecutor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more