| 89 | } |
| 90 | |
| 91 | std::vector<models::WhisperAlignmentResult> |
| 92 | align(const StorageView& features, |
| 93 | Ids start_sequence, |
| 94 | BatchIds text_tokens, |
| 95 | const std::variant<size_t, std::vector<size_t>>& num_frames, |
| 96 | size_t median_filter_width) { |
| 97 | const size_t batch_size = text_tokens.size(); |
| 98 | |
| 99 | std::vector<size_t> batch_num_frames; |
| 100 | if (num_frames.index() == 0) |
| 101 | batch_num_frames.resize(batch_size, std::get<size_t>(num_frames)); |
| 102 | else |
| 103 | batch_num_frames = std::get<std::vector<size_t>>(num_frames); |
| 104 | std::shared_lock lock(_mutex); |
| 105 | assert_model_is_ready(); |
| 106 | |
| 107 | auto futures = _pool->align(features, |
| 108 | std::move(start_sequence), |
| 109 | std::move(text_tokens), |
| 110 | std::move(batch_num_frames), |
| 111 | median_filter_width); |
| 112 | return wait_on_futures(std::move(futures)); |
| 113 | } |
| 114 | }; |
| 115 | |
| 116 | |