diff --git a/inference/inferPreprocess.hpp b/inference/inferPreprocess.hpp index d8985be..2cbf5cb 100644 --- a/inference/inferPreprocess.hpp +++ b/inference/inferPreprocess.hpp @@ -173,3 +173,20 @@ std::vector F0PreProcess::GetF0AndOtherInput(const double* audio, int delete[] O0f; return Of0; } + +inline std::vector getAligments(size_t specLen, size_t hubertLen) +{ + std::vector mel2ph(specLen + 1, 0); + + size_t startFrame = 0; + const double ph_durs = static_cast(specLen) / static_cast(hubertLen); + for (size_t iph = 0; iph < hubertLen; ++iph) + { + const auto endFrame = static_cast(round(static_cast(iph) * ph_durs + ph_durs)); + for (auto j = startFrame; j < endFrame + 1; ++j) + mel2ph[j] = static_cast(iph) + 1; + startFrame = endFrame + 1; + } + + return mel2ph; +}