| 1689 | "heartmula.codec.cuda_sampling_policy", |
| 1690 | "HeartCodec", |
| 1691 | engine::sampling::TorchCudaSamplingPolicyFailureMode::StrictCuda); |
| 1692 | const int64_t original_frames = frames; |
| 1693 | auto working_codes = frame_major_to_bqt_codes(codes, frames, codebooks); |
| 1694 | const int64_t first_latent_length = 0; |
| 1695 | const int64_t first_latent_codes_length = 0; |
| 1696 | const int64_t min_code_samples = static_cast<int64_t>(options.codec_duration * 12.5F); |
| 1697 | const int64_t hop_code_samples = (min_code_samples / 93) * 80; |
| 1698 | const int64_t ovlp_code_samples = min_code_samples - hop_code_samples; |
| 1699 | const int64_t ovlp_frames = ovlp_code_samples * 2; |
| 1700 | if (min_code_samples <= 0 || hop_code_samples <= 0) { |
| 1701 | throw std::runtime_error("HeartCodec detokenize duration creates invalid chunking"); |
| 1702 | } |
| 1703 | const int64_t target_len = static_cast<int64_t>( |
| 1704 | (static_cast<float>(original_frames - first_latent_codes_length) / 12.5F) * static_cast<float>(config.sample_rate)); |
| 1705 | if (frames < min_code_samples) { |
| 1706 | working_codes = repeat_codes_to_length(working_codes, codebooks, frames, min_code_samples); |