SadTalker
SadTalker copied to clipboard
generate_blink_seq_randomly does not work for 21 frames
I ran into an issue with generate_blink_seq_randomly while testing short audio inputs.
For reference, src.generate_batch.py has the following implementation of generate_blink_seq_randomly:
def generate_blink_seq_randomly(num_frames):
ratio = np.zeros((num_frames,1))
if num_frames<=20:
return ratio
frame_id = 0
while frame_id in range(num_frames):
start = random.choice(range(min(10,num_frames), min(int(num_frames/2), 70)))
if frame_id+start+5<=num_frames - 1:
ratio[frame_id+start:frame_id+start+5, 0] = [0.5, 0.9, 1.0, 0.9, 0.5]
frame_id = frame_id+start+5
else:
break
return ratio
When the number of frames is 21, int(num_frames/2) evaluates to 10 and min(10,num_frames) also evaluates to 10 meaning we get random.choice(10, 10) which is invalid and throws an error. A correct if condition would look like if int(num_frames / 2) < 11 instead of if num_frames<=20. Would submitting a PR that fixes this be appropriate?