From f88e201c3499196f0a309076cdd80c447eba580f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=9D=CE=B1=CF=81=CE=BF=CF=85=CF=83=CE=AD=C2=B7=CE=BC?= =?UTF-8?q?=C2=B7=CE=B3=CE=B9=CE=BF=CF=85=CE=BC=CE=B5=CE=BC=CE=AF=C2=B7?= =?UTF-8?q?=CE=A7=CE=B9=CE=BD=CE=B1=CE=BA=CE=AC=CE=BD=CE=BD=CE=B1?= <40709280+NaruseMioShirakana@users.noreply.github.com> Date: Fri, 7 Apr 2023 23:51:13 +0800 Subject: [PATCH] Update inferPreprocess.hpp --- inference/inferPreprocess.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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; +}