Fix/smooth mouth (#412)

* 1. 修复了musetalk方案中,当数字人说话状态变化时,嘴部画面跳变问题;
2. 新增现代美观的前端dashboard.html,集成了对话与朗读功能;
3. 修复了“'weights_only' is an invalid keyword argument for load()”报错。

* bugfix:修复视频连接状态不更新的bug

* feature:新增可选是否启用musereal中的混合过度选项

* 参照fix log修复log

---------

Co-authored-by: marstaos <liu.marstaos@outlook.com>
main
Marstaos 4 months ago committed by GitHub
parent 2e0e5d8330
commit a55de002fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

4
.gitignore vendored

@ -16,6 +16,10 @@ pretrained
.DS_Store .DS_Store
workspace/log_ngp.txt workspace/log_ngp.txt
.idea .idea
keep_gpu.py
models/
*.log
prepared_data/
models/ models/
*.log *.log
dist dist

@ -267,7 +267,9 @@ class MuseReal(BaseReal):
def process_frames(self,quit_event,loop=None,audio_track=None,video_track=None): def process_frames(self,quit_event,loop=None,audio_track=None,video_track=None):
# 新增状态跟踪变量 enable_transition = True # 设置为False禁用过渡效果True启用
if enable_transition:
self.last_speaking = False self.last_speaking = False
self.transition_start = time.time() self.transition_start = time.time()
self.transition_duration = 0.1 # 过渡时间 self.transition_duration = 0.1 # 过渡时间
@ -280,6 +282,7 @@ class MuseReal(BaseReal):
except queue.Empty: except queue.Empty:
continue continue
if enable_transition:
# 检测状态变化 # 检测状态变化
current_speaking = not (audio_frames[0][1]!=0 and audio_frames[1][1]!=0) current_speaking = not (audio_frames[0][1]!=0 and audio_frames[1][1]!=0)
if current_speaking != self.last_speaking: if current_speaking != self.last_speaking:
@ -297,6 +300,7 @@ class MuseReal(BaseReal):
else: else:
target_frame = self.frame_list_cycle[idx] target_frame = self.frame_list_cycle[idx]
if enable_transition:
# 说话→静音过渡 # 说话→静音过渡
if time.time() - self.transition_start < self.transition_duration and self.last_speaking_frame is not None: if time.time() - self.transition_start < self.transition_duration and self.last_speaking_frame is not None:
alpha = min(1.0, (time.time() - self.transition_start) / self.transition_duration) alpha = min(1.0, (time.time() - self.transition_start) / self.transition_duration)
@ -305,6 +309,8 @@ class MuseReal(BaseReal):
combine_frame = target_frame combine_frame = target_frame
# 缓存静音帧 # 缓存静音帧
self.last_silent_frame = combine_frame.copy() self.last_silent_frame = combine_frame.copy()
else:
combine_frame = target_frame
else: else:
self.speaking = True self.speaking = True
bbox = self.coord_list_cycle[idx] bbox = self.coord_list_cycle[idx]
@ -318,8 +324,9 @@ class MuseReal(BaseReal):
mask = self.mask_list_cycle[idx] mask = self.mask_list_cycle[idx]
mask_crop_box = self.mask_coords_list_cycle[idx] mask_crop_box = self.mask_coords_list_cycle[idx]
# 静音→说话过渡
current_frame = get_image_blending(ori_frame,res_frame,bbox,mask,mask_crop_box) current_frame = get_image_blending(ori_frame,res_frame,bbox,mask,mask_crop_box)
if enable_transition:
# 静音→说话过渡
if time.time() - self.transition_start < self.transition_duration and self.last_silent_frame is not None: if time.time() - self.transition_start < self.transition_duration and self.last_silent_frame is not None:
alpha = min(1.0, (time.time() - self.transition_start) / self.transition_duration) alpha = min(1.0, (time.time() - self.transition_start) / self.transition_duration)
combine_frame = cv2.addWeighted(self.last_silent_frame, 1-alpha, current_frame, alpha, 0) combine_frame = cv2.addWeighted(self.last_silent_frame, 1-alpha, current_frame, alpha, 0)
@ -327,6 +334,8 @@ class MuseReal(BaseReal):
combine_frame = current_frame combine_frame = current_frame
# 缓存说话帧 # 缓存说话帧
self.last_speaking_frame = combine_frame.copy() self.last_speaking_frame = combine_frame.copy()
else:
combine_frame = current_frame
image = combine_frame image = combine_frame
new_frame = VideoFrame.from_ndarray(image, format="bgr24") new_frame = VideoFrame.from_ndarray(image, format="bgr24")

Loading…
Cancel
Save