3232face_pts_mean = adjust_verts (face_pts_mean )
3333teeth_verts_ = render_verts_ [478 :, :3 ]
3434head_joint = np .array ([out_size * 0.5 , out_size * 3 / 4 , - 0. ])
35- def run_audio (img_path , wavpath , output_path , template_path = None ):
35+ def run_audio (img_path , audio_path , output_path , template_path = None ):
3636 img_primer_rgba , source_img , source_crop_pts , source_crop_pts_vt , source_crop_coords = face_process (img_path , out_size )
3737
3838 # print(source_img.shape)
@@ -57,7 +57,7 @@ def run_audio(img_path, wavpath, output_path, template_path = None):
5757 tensor_source_prompt = torch .from_numpy (source_prompt / 255. ).float ().permute (2 , 0 , 1 ).unsqueeze (0 ).to (
5858 device )
5959
60- pts_audio_driving = audio_interface (wavpath )
60+ pts_audio_driving = audio_interface (audio_path )
6161 frame_num = len (pts_audio_driving )
6262 import uuid
6363 task_id = str (uuid .uuid1 ())
@@ -183,27 +183,26 @@ def run_audio(img_path, wavpath, output_path, template_path = None):
183183 videoWriter .write (frame [..., ::- 1 ])
184184 videoWriter .release ()
185185 val_video = output_path
186- wav_path = wavpath
187186 os .system (
188- "ffmpeg -i {} -i {} -c:v libx264 -pix_fmt yuv420p {}" .format (save_path , wav_path , val_video ))
187+ "ffmpeg -i {} -i {} -c:v libx264 -pix_fmt yuv420p {}" .format (save_path , audio_path , val_video ))
189188 os .remove (save_path )
190189 cv2 .destroyAllWindows ()
191190
192191def main ():
193192 # 检查命令行参数的数量
194193 if len (sys .argv ) < 4 or len (sys .argv ) > 5 :
195- print ("Usage: python interface_audio.py <img_path> <wav_path > <output_path> <template_path>" )
194+ print ("Usage: python interface_audio.py <img_path> <audio_path > <output_path> <template_path>" )
196195 sys .exit (1 ) # 参数数量不正确时退出程序
197196
198197 img_path = sys .argv [1 ]
199- wav_path = sys .argv [2 ]
198+ audio_path = sys .argv [2 ]
200199 output_path = sys .argv [3 ]
201200 if len (sys .argv ) == 4 :
202201 template_path = None
203202 else :
204203 template_path = sys .argv [4 ]
205- print (f"img path is set to: { img_path } , wav path is set to: { wav_path } , output path is set to: { output_path } " )
206- run_audio (img_path , wav_path , output_path , template_path )
204+ print (f"img path is set to: { img_path } , wav path is set to: { audio_path } , output path is set to: { output_path } " )
205+ run_audio (img_path , audio_path , output_path , template_path )
207206
208207if __name__ == "__main__" :
209208 main ()
0 commit comments