| 54 | throw std::runtime_error("Seed-VC length regulator requires non-empty token ids"); |
| 55 | } |
| 56 | if (static_cast<int64_t>(token_ids.size()) != expected_count) { |
| 57 | throw std::runtime_error("Seed-VC length regulator token count mismatch"); |
| 58 | } |
| 59 | for (const int32_t token : token_ids) { |
| 60 | if (token < 0 || token >= codebook_size) { |
| 61 | throw std::runtime_error("Seed-VC length regulator token id is outside the codebook"); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | std::vector<float> build_sequence_mask( |
| 67 | const std::vector<int64_t> & lengths, |
| 68 | int64_t output_tokens, |
| 69 | int64_t channels) { |
| 70 | if (output_tokens <= 0 || channels <= 0) { |
| 71 | throw std::runtime_error("Seed-VC length regulator mask dimensions must be positive"); |
| 72 | } |
| 73 | std::vector<float> mask(static_cast<size_t>(lengths.size() * output_tokens * channels), 0.0F); |
| 74 | for (size_t batch = 0; batch < lengths.size(); ++batch) { |
| 75 | const int64_t valid = lengths[batch]; |
| 76 | if (valid <= 0 || valid > output_tokens) { |
| 77 | throw std::runtime_error("Seed-VC length regulator output length is out of range"); |
| 78 | } |
| 79 | for (int64_t token = 0; token < valid; ++token) { |
| 80 | const size_t base = (batch * static_cast<size_t>(output_tokens) + static_cast<size_t>(token)) * |
| 81 | static_cast<size_t>(channels); |