| 708 | } |
| 709 | |
| 710 | HiftVocoderOutput run( |
| 711 | const std::vector<float> & mel, |
| 712 | int64_t frames, |
| 713 | uint64_t seed, |
| 714 | uint64_t prior_noise_values, |
| 715 | const std::vector<float> * source_random_values) { |
| 716 | std::lock_guard<std::mutex> lock(mutex_); |
| 717 | const auto f0 = predict_f0_locked(mel, frames); |
| 718 | const int64_t scale = upsample_scale(weights_->config); |
| 719 | const auto f0_upsampled = nearest_upsample_f0(f0, frames, scale); |
| 720 | const auto source = make_sine_source(*weights_, f0_upsampled, seed, prior_noise_values, source_random_values); |
| 721 | std::vector<float> window; |
| 722 | int64_t stft_frames = 0; |
| 723 | const auto source_stft = source_stft_bct(*weights_, source, stft_frames, window); |
| 724 | if (backend_runner_ != nullptr && !backend_runner_->supports(*weights_, frames, stft_frames)) { |
| 725 | backend_runner_.reset(); |
| 726 | } |
| 727 | if (backend_runner_ == nullptr) { |
| 728 | backend_runner_ = std::make_unique<BackendRunner>(*weights_, frames, stft_frames); |
| 729 | } |
| 730 | const auto post = backend_runner_->run(mel, frames, source_stft, stft_frames); |
| 731 | HiftVocoderOutput out; |
| 732 | out.waveform = waveform_from_post(*weights_, post, stft_frames, window); |
| 733 | out.batch = 1; |
| 734 | out.samples = static_cast<int64_t>(out.waveform.size()); |
| 735 | out.sample_rate = weights_->config.sampling_rate; |
| 736 | return out; |
| 737 | } |
| 738 | |
| 739 | void release_runtime_cache() { |
| 740 | std::lock_guard<std::mutex> lock(mutex_); |
nothing calls this directly
no test coverage detected