| 481 | } |
| 482 | |
| 483 | std::vector<float> source_stft_bct( |
| 484 | const HiftVocoderWeights & weights, |
| 485 | const std::vector<float> & source, |
| 486 | int64_t & stft_frames, |
| 487 | std::vector<float> & window) { |
| 488 | const audio::STFTConfig window_config{ |
| 489 | weights.config.istft_n_fft, |
| 490 | weights.config.istft_hop, |
| 491 | weights.config.istft_n_fft, |
| 492 | true, |
| 493 | audio::STFTPadMode::Reflect, |
| 494 | audio::STFTFamily::Kokoro, |
| 495 | }; |
| 496 | window = audio::get_cached_stft_window(window_config); |
| 497 | const auto complex = audio::STFT().compute_complex( |
| 498 | source, |
| 499 | window, |
| 500 | 1, |
| 501 | static_cast<int64_t>(source.size()), |
| 502 | {weights.config.istft_n_fft, weights.config.istft_hop, weights.config.istft_n_fft}); |
| 503 | stft_frames = complex.shape[2]; |
| 504 | std::vector<float> stft(static_cast<size_t>(kHiftStftChannels * stft_frames), 0.0F); |
| 505 | for (int64_t f = 0; f < kHiftStftBins; ++f) { |
| 506 | for (int64_t t = 0; t < stft_frames; ++t) { |
| 507 | const size_t complex_index = static_cast<size_t>((f * stft_frames + t) * 2); |
| 508 | stft[static_cast<size_t>(f * stft_frames + t)] = complex.values[complex_index]; |
| 509 | stft[static_cast<size_t>((kHiftStftBins + f) * stft_frames + t)] = complex.values[complex_index + 1]; |
| 510 | } |
| 511 | } |
| 512 | return stft; |
| 513 | } |
| 514 | |
| 515 | std::vector<float> waveform_from_post( |
| 516 | const HiftVocoderWeights & weights, |
no test coverage detected