add audio2mesh_ar

This commit is contained in:
Sen Liang committed 2022-03-14 18:13:13 +08:00
1 parent ded9b27f71
commit e0f24982d1
46 files changed
+3917 -325

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
import numpy as np
from scipy import interpolate
def resample_by_nsteps(feat, nsteps_tgt):
"""
feat, (nframes, ... ) (with source_fps)
"""
nsteps_src = feat.shape[0]
data_idx = np.arange(0, nsteps_src, 1)
samp_idx = np.arange(0, nsteps_src-1, (nsteps_src - 1) / nsteps_tgt)
# print(f"data_idx = {list(data_idx)} \nsmap_idx = {list(samp_idx)}")
# sample function
func = interpolate.interp1d(data_idx, y=feat, axis=0)
data_interpolate = func(samp_idx)
return data_interpolate
def convert_fps(data, source_fps = 30, target_fps=25):
"""
data, (nframes, ... ) (with source_fps)
"""
nsize = data.shape[0]
data_idx = np.arange(0, nsize, 1)
samp_idx = np.arange(0, nsize-1, 1.0*source_fps/target_fps)
func = interpolate.interp1d(data_idx, data=data, axis=0)
data_interpolate = func(samp_idx)
if source_fps < target_fps:
data_interpolate = np.concatenate([data_interpolate, data[-1:]])
return data_interpolate
# def