#pragma once #include "engine/framework/assets/tensor_source.h" #include "engine/framework/core/backend.h" #include "engine/models/qwen3_tts/assets.h" #include "engine/models/qwen3_tts/types.h" #include #include #include #include #include #include #include namespace engine::models::qwen3_tts { enum class Qwen3TalkerPromptMode { VoiceClone, VoiceDesign, CustomVoice, }; struct Qwen3TalkerPrefill { Qwen3TalkerPromptMode prompt_mode = Qwen3TalkerPromptMode::VoiceClone; std::vector input_ids; std::vector instruct_ids; std::vector reference_ids; std::optional reference_codes = std::nullopt; std::optional speaker_embedding = std::nullopt; std::string speaker; std::string language = "Auto"; bool icl_mode = false; bool x_vector_only_mode = false; }; struct Qwen3TalkerCodes { Qwen3SpeechCodes generated_codes; Qwen3SpeechCodes decoder_input_codes; }; void validate_qwen3_talker_voice_clone_prefill( const Qwen3TalkerPrefill & prefill, int64_t hidden_size); class Qwen3TalkerWeightsRuntime; class Qwen3TalkerStepRuntime; class Qwen3TalkerStepRuntime { public: class Impl; explicit Qwen3TalkerStepRuntime(std::unique_ptr impl); ~Qwen3TalkerStepRuntime(); Qwen3TalkerCodes generate( const Qwen3TalkerPrefill & prefill, const Qwen3TTSGenerationOptions & options, float repetition_penalty = 1.05F, const std::function &)> & on_frame = {}); int64_t release_cached_step_graph(); private: std::unique_ptr impl_; }; class Qwen3Talker { public: explicit Qwen3Talker(Qwen3TTSTalkerConfig config); const Qwen3TTSTalkerConfig & config() const noexcept; std::shared_ptr create_weights_runtime( std::shared_ptr assets, const core::BackendConfig & backend_config, size_t graph_arena_bytes, size_t talker_constant_context_bytes, size_t code_predictor_constant_context_bytes, engine::assets::TensorStorageType weight_storage_type, Qwen3TTSPerfMode perf_mode, int64_t kv_cache_alignment = 1, bool packed_projections = false, ggml_type kv_cache_type = GGML_TYPE_F32, bool optimized_kv_cache_write = false) const; std::shared_ptr create_step_runtime( std::shared_ptr weights, int64_t prompt_capacity, int64_t generation_capacity) const; private: Qwen3TTSTalkerConfig config_; }; } // namespace engine::models::qwen3_tts