| 465 | } |
| 466 | |
| 467 | int64_t semantic_downsample_factor(const OmniVoiceAudioTokenizerConfig & config) { |
| 468 | const double factor = |
| 469 | static_cast<double>(checked_positive(config.hop_length, "hop_length")) / |
| 470 | (static_cast<double>(checked_positive(config.sample_rate, "sample_rate")) / |
| 471 | static_cast<double>(checked_positive(config.semantic_sample_rate, "semantic_sample_rate"))) / |
| 472 | static_cast<double>(checked_positive(config.downsample_factor, "downsample_factor")); |
| 473 | const auto rounded = static_cast<int64_t>(std::llround(factor)); |
| 474 | if (rounded <= 0 || std::fabs(factor - static_cast<double>(rounded)) > 1.0e-6) { |
| 475 | throw std::runtime_error("OmniVoice semantic_downsample_factor is not an integer"); |
| 476 | } |
| 477 | return rounded; |
| 478 | } |
| 479 | |
| 480 | int64_t semantic_feature_frames(const OmniVoiceAudioTokenizerConfig & config, int64_t semantic_samples) { |
| 481 | const auto & semantic = config.semantic_model; |
no test coverage detected