Compare commits

..

1 Commits

Author SHA1 Message Date
jocelyn
afeeb3bb78 [ADD]add logic of loop frame 2025-06-13 13:52:57 +08:00
2 changed files with 27 additions and 4 deletions

View File

@ -117,6 +117,7 @@ class AudioInferenceHandler(AudioHandler):
img_batch = []
index_list = []
# for i in range(batch_size):
# TODO: 推理状态下获取循环帧逻辑
for i in range(len(mel_batch)):
# idx = mirror_index(length, index + i)
idx = human_status.get_index()

View File

@ -1,8 +1,5 @@
#encoding = utf8
import logging
from utils.loop_frame_tool import play_in_loop_v2
from enum import Enum
@ -20,6 +17,9 @@ class HumanStatus:
self._current_frame = 0
self._is_talking = False
self.last_frame_talking_status = "silent" # 记录上一帧讲话状态
self.next_frame_talking_status = "silent"
def get_status(self):
return self._status
@ -51,6 +51,28 @@ class HumanStatus:
self._current_frame = (self._current_frame + 1) % self._total_frames
return index
def get_index_v2(self):
"""
"""
frame_config = []
audio_frame_length = batch_size = 5
is_silent = True if not self._is_talking else False
first_speak = True if self._is_talking and self.last_frame_talking_status == "silent" else False
last_speak = True if self.last_frame_talking_status == "talk" and self.next_frame_talking_status == "silent" else False
start_idx_list, last_direction = play_in_loop_v2(
frame_config,
startfrom,
audio_frame_length,
last_direction,
is_silent,
first_speak,# 刚开始讲话 向讲话移动
last_speak, # 讲话结束 向静默移动
)
startfrom = start_idx_list[-1]
# 一次返回一个batch帧号
return start_idx_list
def start_talking(self):
self._is_talking = True