Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 19 additions & 23 deletions code/videoDrawer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,11 @@ def setPhoneme(i):
START_FORCE_OPEN = (prevPhoneme == 't' or prevPhoneme == 'y')
END_FORCE_OPEN = (nextPhoneme == 't' or nextPhoneme == 'y')
OPEN_TRACKS = [
[[1],[2],[2],[2]],
[[2,1],[1,2],[2,1],[3,2]],
[[1,2,1],[1,3,2],[2,3,1],[2,3,2]],
[[1,3,2,1],[1,2,3,2],[2,3,2,1],[2,3,3,2]]]
[[1],[2],[2],[2]],
[[2,1],[1,2],[2,1],[3,2]],
[[1,2,1],[1,3,2],[2,3,1],[2,3,2]],
[[1,3,2,1],[1,2,3,2],[2,3,2,1],[2,3,3,2]]
]
if frameLen >= 5:
startSize = 1
endSize = 1
Expand Down Expand Up @@ -176,7 +177,7 @@ def setPhoneme(i):
phonemesPerFrame[nextFrame-1] += 1

def timestepToFrames(timestep):
return max(0,int(timestep*FRAME_RATE-2))
return max(0, int(timestep*FRAME_RATE-2))

def stateOf(p):
global indicesOn
Expand All @@ -203,9 +204,8 @@ def frameOf(p, offset):
USE_BILLBOARDS = (args.use_billboards == "T")
ENABLE_JIGGLING = (args.jiggly_transitions == "T")

f = open(INPUT_FILE+"_schedule.csv","r+")
scheduleLines = f.read().split("\nSECTION\n")
f.close()
with open(INPUT_FILE+"_schedule.csv","r+") as f:
scheduleLines = f.read().split("\nSECTION\n")

schedules = [None]*PARTS_COUNT
for i in range(PARTS_COUNT):
Expand All @@ -216,35 +216,31 @@ def frameOf(p, offset):
lastTimestamp = float(lastParts[0])
FRAME_COUNT = timestepToFrames(lastTimestamp+1)
phonemeTimeline = []
for i in range(len(schedules[4])):
parts = schedules[4][i].split(",")
timestamp = float(parts[0])
framestamp = timestepToFrames(timestamp)
for elem in schedules[4]:
timestamp, _, phoneme = elem.split(",")
framestamp = timestepToFrames(float(timestamp))
if i >= 1 and framestamp <= phonemeTimeline[-1][1]: # we have a 0-frame phoneme! Try to fix it.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index i is used here but you removed it

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh dear, you're right

if i >= 2 and phonemeTimeline[-2][1] <= framestamp-2:
phonemeTimeline[-1][1] = framestamp-1 # shift previous one back
else:
framestamp += 1 # shift current one forward
phoneme = parts[2]
phonemeTimeline.append([phoneme,framestamp])
phonemeTimeline.append(["end",FRAME_COUNT])
phonemeTimeline.append([phoneme, framestamp])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phoneme is never set anymore

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix with phoneme = parts[2] as original had it

phonemeTimeline.append(["end", FRAME_COUNT])
phonemesPerFrame = np.zeros(FRAME_COUNT,dtype='int32')
for i in range(len(phonemeTimeline)-1):
setPhoneme(i)

f = open(INPUT_FILE+".txt","r+")
origScript = f.read().split("\n")
f.close()
with open(INPUT_FILE+".txt","r+") as f:
origScript = f.read().split("\n")
#while "" in origStr:
# origStr.remove("")

with open("code/mouthCoordinates.csv","r+") as f:
mouthCoordinatesStr = f.read().split("\n")

f = open("code/mouthCoordinates.csv","r+")
mouthCoordinatesStr = f.read().split("\n")
f.close()
MOUTH_COOR = np.zeros((POSE_COUNT,5))
for i in range(len(mouthCoordinatesStr)):
parts = mouthCoordinatesStr[i].split(",")
for i, string in enumerate(mouthCoordinatesStr):
parts = string.split(",")
for j in range(5):
MOUTH_COOR[i,j] = float(parts[j])
MOUTH_COOR[:,0:2] *= 3 #upscale for 1080p, not 360p
Expand Down