| 814 | voice_state, |
| 815 | acoustic_config, |
| 816 | capacities.prompt_capacity, |
| 817 | voice_state.current_end, |
| 818 | capacities.generation_capacity, |
| 819 | graph_capacity_.flow_weights_view_context_bytes, |
| 820 | graph_capacity_.flow_step_graph_context_bytes); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | GenerationResult PocketTTSSession::generate(const GenerationRequest & request) { |
| 825 | validate_generation_request(request); |
| 826 | if (!manifest_) { |
| 827 | throw std::runtime_error("PocketTTS session is missing model assets"); |
| 828 | } |
| 829 | const auto & manifest = *manifest_; |
| 830 | |
| 831 | const auto started_inference = std::chrono::steady_clock::now(); |
| 832 | const int64_t text_chunk_size = request.text_chunk_size.value_or(kDefaultTextChunkSize); |
| 833 | const auto chunks = engine::text::split_text_chunks(request.text, text_chunk_size); |
| 834 | engine::debug::trace_log_scalar("pocket_tts.text_chunk_size", text_chunk_size); |
| 835 | engine::debug::trace_log_scalar("pocket_tts.text_chunk_count", static_cast<int64_t>(chunks.size())); |
| 836 | const auto voice_plan = resolve_voice_conditioning_plan(model_dir_, request); |
| 837 | |
| 838 | VoiceConditioningResult voice_state; |
| 839 | const double voice_conditioner_ms = engine::debug::measure_ms([&]() { |
| 840 | voice_state.plan = voice_plan; |
| 841 | voice_state.acoustic_state = resolve_prepared_voice_state(voice_state.plan); |
| 842 | }); |
| 843 | |
| 844 | std::vector<float> audio; |
| 845 | double text_conditioner_ms = 0.0; |
| 846 | double acoustic_prepare_ms = 0.0; |
| 847 | double acoustic_generate_ms = 0.0; |
| 848 | double audio_decode_ms = 0.0; |
| 849 | |
| 850 | for (const auto & chunk : chunks) { |
| 851 | TextConditioningResult text_state; |
| 852 | text_conditioner_ms += engine::debug::measure_ms([&]() { |
| 853 | text_state = text_conditioner_.prepare(manifest, weights_->host, chunk); |
| 854 | }); |
| 855 | const AcousticGenerationConfig acoustic_config = resolve_acoustic_generation_config( |
| 856 | manifest, |
| 857 | text_state, |
| 858 | request, |
| 859 | acoustic_model_.config().latent_size); |
| 860 | const int64_t prompt_steps = static_cast<int64_t>( |
| 861 | text_state.text_embeddings.size() / static_cast<size_t>(acoustic_model_.config().hidden_size)); |
| 862 | const AcousticCapacitySelection capacities = select_acoustic_capacities(prompt_steps, acoustic_config.max_steps); |
| 863 | |
| 864 | AcousticPreparedRuntime acoustic_runtime; |
| 865 | acoustic_prepare_ms += engine::debug::measure_ms([&]() { |
| 866 | acoustic_runtime = acoustic_model_.prepare_runtime( |
| 867 | execution_context().backend(), |
| 868 | options().backend.threads, |
| 869 | manifest, |
| 870 | *weights_, |
| 871 | text_state.text_embeddings, |
| 872 | voice_state.acoustic_state, |
| 873 | acoustic_config, |
nothing calls this directly
no test coverage detected