add infer support for audio2motion
This commit is contained in:
1 parent
0b46d9f3eb
commit
23fdd42edd
23 files changed
+824
-74
No files matched your search
+9
-24
@@ -40,7 +40,8 @@ def infer_one(path_audio, model, processor, extractor, save_npy):
|
||||
|
||||
# load raw speech
|
||||
raw_speech, sample_rate = torchaudio.load(path_audio)
|
||||
raw_speech = raw_speech.numpy()
|
||||
# raw_speech = raw_speech.numpy()
|
||||
|
||||
print(f"raw_speech shape = {raw_speech.shape}, sr = {sample_rate}, duration = {(len(raw_speech[0])/sample_rate)}")
|
||||
|
||||
if len(raw_speech.shape) == 2:
|
||||
@@ -49,8 +50,10 @@ def infer_one(path_audio, model, processor, extractor, save_npy):
|
||||
if sample_rate != 16000:
|
||||
resampler = torchaudio.transforms.Resample(sample_rate, 16_000)
|
||||
raw_speech = resampler(raw_speech).squeeze().numpy()
|
||||
sample_rate = 16000
|
||||
sample_rate = 16000
|
||||
print(f"resampling: raw_speech shape = {raw_speech.shape}, sr = {16000}, duration = {(len(raw_speech)/16000)}")
|
||||
else:
|
||||
raw_speech = raw_speech.numpy()
|
||||
|
||||
# padding to
|
||||
len_align = (raw_speech.shape[0] // (16000 // 50) ) * (16000 // 50)
|
||||
@@ -84,7 +87,8 @@ def infer_one(path_audio, model, processor, extractor, save_npy):
|
||||
|
||||
# inference
|
||||
path_save = f"{path_audio.stem}_infer_{Path(opt.MODEL.path_checkpoint).stem}_epoch_{opt.MODEL.load_epoch:03d}"
|
||||
model.infer(cond, raw_speech, path_save)
|
||||
# model.infer(cond, raw_speech, path_save)
|
||||
model.infer(cond, raw_speech[np.newaxis, :], path_save)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
@@ -112,8 +116,8 @@ if __name__ == "__main__":
|
||||
|
||||
# path_folder = Path("/mfs/dylan/tts/wav")
|
||||
# path_folder = Path("/mfs/dylan/tts/wav_sen")
|
||||
path_folder = Path("./data/test/tts-scenes")
|
||||
opt.OUTPUT_DIR = path_folder.joinpath("inference_video_actor5_with_npy")
|
||||
path_folder = Path("./data/sentencee5_ac5")
|
||||
opt.OUTPUT_DIR = path_folder.joinpath("audio2motion_actor6_result")
|
||||
opt.OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
save_npy = True
|
||||
|
||||
@@ -131,23 +135,4 @@ if __name__ == "__main__":
|
||||
# except:
|
||||
# print("\n continue ! > ipath_audio",ipath_audio)
|
||||
|
||||
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_60_120s.wav")
|
||||
|
||||
# path_audio = Path("./data/test/cut_NVP.wav")
|
||||
# path_audio = Path("./data/test/cut_LSP.wav")
|
||||
# path_audio = Path("/yrfs/cf/data/render/obama_train.wav")
|
||||
# path_audio = Path("/yrfs/lsen/DATA/Obama/processing/Bringing-Our-Workplace-Policies-into-the-21st-Century/audio/audio_trim_120s.wav")
|
||||
# path_audio = Path("/yrfs/lsen/DATA/Obama/processing/Celebrating-Independence-Day/audio/audio_trim_60_120s.wav")
|
||||
|
||||
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P09/audio/audio_trim_120s.wav")
|
||||
# path_audio = Path("/yrfs/lsen/DATA/LuoXData/processing2/2021-P22/audio/audio_trim.wav")
|
||||
|
||||
# path_audio = Path("/ssdata1/lsen/CODE/Audio2Motion/data/test/test_pangzi_zh_cut15.wav")
|
||||
# path_audio = Path("/ssdata1/lsen/CODE/Audio2Motion/data/test/P74_lite.mp3")
|
||||
|
||||
# path_audio = Path("/ssdata1/lsen/CODE/voca/data/audio/test_video_15.wav")
|
||||
# path_audio = Path("/ssdata1/lsen/CODE/voca/data/audio/cut_lsz.wav")
|
||||
# path_audio = Path("/ssdata1/lsen/CODE/voca/data/audio/obama.wav")
|
||||
|
||||
# data extract audio
|
||||
# Load data_audio and extract features
|
||||
Reference in new issue
Block a user