-- ************************************************** -- Provide Moho with the name of this script object -- ************************************************** ScriptName = "MS_Convert_JLS_Clip" -- ************************************************** -- General information about this script -- ************************************************** MS_Convert_JLS_Clip = {} function MS_Convert_JLS_Clip:Name() return "Convert JLipSync Clipboard Format" end function MS_Convert_JLS_Clip:Version() return "1.0" end function MS_Convert_JLS_Clip:Description() return "Convert clipboard output from David Cuny's JLipSync into Moho switch data file" end function MS_Convert_JLS_Clip:Creator() return "Myles Strous" end function MS_Convert_JLS_Clip:UILabel() return("Convert JLipSync Clipboard Format") end -- ************************************************** -- The guts of this script -- ************************************************** function MS_Convert_JLS_Clip:Run(moho) local infilename = LM.GUI.OpenFile("Select Input Clip File") if (infilename == "") then return end local f = io.open(infilename, "r") if (f == nil) then return end f:close() local outfilename = LM.GUI.SaveFile("Select Output Switch Data File") if (outfilename == "") then return end local outfile = io.open(outfilename, "w") if (outfile == nil) then return end local line_count = 0 outfile:write("MohoSwitch1\n") for line in io.lines(infilename) do if line_count == 0 then line_count = line_count + 1 else start_place, end_place, frame_number, mouthname = string.find(line, "%s+(%d+)%s+[^%s]+%s+[^%s]+%s+(%a*)") -- whitespace, frame_number, whitespace, timecode, whitespace, key, whitespace, optional keyframe (, whitespace) if mouthname ~= "" and mouthname ~= nil then outfile:write(frame_number.." "..mouthname.."\n") end end end outfile:close() end