| 117 | throw std::runtime_error("RoFormer config num_overlap must be positive"); |
| 118 | } |
| 119 | chunk_size_ = config.chunk_size; |
| 120 | const int64_t overlap = runtime::parse_positive_i64_option( |
| 121 | RuntimeSessionBase::options().options, |
| 122 | {config.family + ".num_overlap"}, |
| 123 | config.inference_num_overlap); |
| 124 | if (overlap > chunk_size_) { |
| 125 | throw std::runtime_error(config.family + ".num_overlap must not exceed chunk_size"); |
| 126 | } |
| 127 | step_ = chunk_size_ / overlap; |
| 128 | fade_size_ = chunk_size_ / 10; |
| 129 | border_ = chunk_size_ - step_; |
| 130 | if (step_ <= 0) { |
| 131 | throw std::runtime_error("RoFormer chunk step must be positive"); |
| 132 | } |
| 133 | chunk_window_ = engine::audio::make_linear_fade_window(chunk_size_, fade_size_); |
| 134 | first_chunk_window_ = chunk_window_; |
| 135 | std::fill(first_chunk_window_.begin(), first_chunk_window_.begin() + fade_size_, 1.0f); |
| 136 | last_chunk_window_ = chunk_window_; |
| 137 | std::fill(last_chunk_window_.end() - fade_size_, last_chunk_window_.end(), 1.0f); |
| 138 | only_chunk_window_ = first_chunk_window_; |
| 139 | std::fill(only_chunk_window_.end() - fade_size_, only_chunk_window_.end(), 1.0f); |
| 140 | chunk_planar_work_.resize(static_cast<size_t>(config.channels * chunk_size_)); |
| 141 | assets_->tensor_source->release_storage(); |
| 142 | } |
| 143 | |
| 144 | RoformerSession::~RoformerSession() = default; |
| 145 | |
| 146 | std::string RoformerSession::family() const { |
| 147 | return assets_->config.family; |
| 148 | } |
| 149 | |
| 150 | runtime::VoiceTaskKind RoformerSession::task_kind() const { |
| 151 | return task_.task; |
| 152 | } |
| 153 | |
| 154 | runtime::RunMode RoformerSession::run_mode() const { |
| 155 | return task_.mode; |
| 156 | } |
| 157 | |
| 158 | void RoformerSession::prepare(const runtime::SessionPreparationRequest & request) { |
| 159 | if (!request.audio.has_value()) { |
nothing calls this directly
no test coverage detected