Animators Forum
Animators Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Moho (Anime Studio)
 Problems, Solutions, and General Discussion
 Papagayo Part Deux

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List
Videos: Google videoYoutubeFlash movie Metacafe videomySpace videoQuicktime movieWindows Media videoReal Video
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Kelleytoons Posted - 06/01/2012 : 09:20:31 AM
For all (any?) of you using Papagayo, I've been playing around with what to me is the biggest bug/worst frustration and I think I've finally fixed it.

With (very) short sequences PG is just fine -- for one thing, it does a much more efficient job of properly spacing out your initial text input. But even if it's not great you can easily scroll around and/or move lines with little effort.

As your sequences are longer, though, the process becomes awful. The basic issue is that the spacing algorithm doesn't work. The text bunches up at the start of the file. And because no matter how fast a PC you have the program starts to bog down with longer files, as you have to drag things out it takes a terrible amount of time.

In another thread I discuss a possible workaround: namely, doubling the length of the audio file. And while that "sort of" helps, it also suffers from problems as the audio gets longer. And it still doesn't space things out properly.

After playing extensively this last week I think I've got the ultimate solution. I programmed a LUA script (because it was the language I've spent the most time in the last few years and because it's convenient for all who run AS) that processed the Papagayo file and pads it out correctly.

I'm going to post it in the next thread, so you can cut and paste it to your menu scripts folder if you want to try it out. Here is how to use it:

First, load up your audio file and type your text as usual. Don't worry about the frame change trick, or even trying to move any of your text at all. Just get it all in and generate it.

Then go to the very end of the file and note the number of total frames -- this isn't critical to be exact, but you want to get the length as near to the end of your text as you can (since that's how it will be spaced out). Save the file.

Exit PG and then run AS. Run my script and input the number you noted, and then pick your PGO file you saved. A few seconds later you will have a new, padded PGO file.

Load this new file back into Papagayo and it should be spaced out very well -- not perfectly, because just as with the words and phonemes you will need to adjust things. But it should be a heck of a lot closer to how it should look, with a minimum amount of movement required to get things perfect.

I've tried this on several files and am VERY happy with the results. This is really the way Papagayo *should* work, and I'm going to send the results to Mike to see if he will at least consider changing PG to operate this way. In the meantime, I'm happy.

A couple of other things to note: first, this is only set to work with one voice track. You can have multiple actors (as I do) and just use the one track, but if you want separate tracks you'll need to create separate PG files (not a huge deal). If you REALLY want this LUA script to handle multiple voice tracks like PG does then it would be easy to modify it yourself (I've done all the heavy lifting). Indeed, the script is purposefully not all that efficient so it's very easy to see how it works (I'm aware there are much more condensed ways to do what I did, but LUA is so quick at handling text files I didn't try to be clever here).

Secondly, I DID uncover the PG file limit (I had always remembered there was a limit and I found it again). PG won't work with a file greater than 4000 frames. For 30fps this amounts to slightly over two minutes, for lesser frame rates it will be longer. Break your audio up into sections smaller than this and you'll be fine (really, no scene should be longer than that anyway -- although I tend to create such long scenes with camera changes built in to them).

Please -- if you use this give me feedback around it!
15   L A T E S T    R E P L I E S    (Newest First)
Kelleytoons Posted - 06/22/2017 : 2:18:50 PM
If you've never installed any scripts I would suggest you take a look at my video on how to do so (which was done a long time ago but most of it is still valid):

https://vimeo.com/6051637

In this case I think all you need do is put the Papgagyo script in your menu folder (you will have a custom folder in the new Moho that you specify where you want your scripts to be -- this was asked the first time you started Moho) and the utilities script in the utilities folder (that's assuming there is one -- I don't remember offhand if this uses my utilities or not. If the script isn't there don't worry about it).

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
npapenfus Posted - 06/22/2017 : 06:52:17 AM
Hi how and where do I need to install this script into Anime Studio?

quote:
Originally posted by Kelleytoons

Dropbox ended their support of links to the public folder. Let's see if this works now:

https://www.dropbox.com/s/lg6y4nsrhwpysug/MK_ProcessPapagayo.lua?dl=0

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley

Kelleytoons Posted - 04/09/2017 : 2:02:33 PM
Frank,

Good for you. I need to (when I've had less alcohol) take a look at all this and check it out on my MacBook Air (which these days I almost never even boot up) as well as make sure it continues to work under Windows, and I will. But in the meantime I'm glad you got it working so far (but let me know if you have any other issues).

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
ifix Posted - 04/09/2017 : 04:42:38 AM
Thanks Mike,
Unfortunately, I followed your advice without good result.
So i tried to change in your first script Windows delimiters to Mac delimiters. And the result seems good.



-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "MK_ProcessPapagayo"

-- **************************************************
-- General information about this script
-- **************************************************

MK_ProcessPapagayo = {}

function MK_ProcessPapagayo:Name()
return "Pad out Papagayo File"
end

function MK_ProcessPapagayo:Version()
return "5.0"
end

function MK_ProcessPapagayo:Description()
return "Pad out Papagayo File"
end

function MK_ProcessPapagayo:Creator()
return "Kelleytoons.com"
end

function MK_ProcessPapagayo:UILabel()
return("Pad Papagayo File")
end


-- **************************************************
-- The guts of this script
-- **************************************************


function MK_ProcessPapagayo:Run(moho)

local path = LM.GUI.OpenFile("Select PGO File")
if (path == "") then
return
end

local f = io.open(path, "r")
if (f == nil) then
return
end


local words = 0
local lines = 0
local phonemes = 0
local counter = 0
local filebytes = 0
local wholeline = ""
local line = ""
local wordbytes = 0
local endline = ""
local audiofile = ""
local finalfinal = ""
local thisfps = 25
while true do
line = f:read("*l")
if line == nil then break end
counter = counter + 1
if (counter == 4) then
filebytes = tonumber(line)
end
if (counter == 3) then
thisfps = tonumber(line)
end
if (counter == 2) then
audiofile = line
end
if (string.find (line,"\t",1)) ~= nil then
if (string.find (line,"\t\t\t\t",1)) ~= nil then -- individual phonemes
phonemes = phonemes + 1
elseif (string.find (line,"\t\t\t",1)) ~= nil then -- words
words = words + 1
elseif (string.find (line,"\t\t",1)) ~= nil then -- lines?
wholeline = (string.sub(line,3))
line = f:read("*l")
local startline = (string.sub(line,3))
line = f:read("*l")
endline = string.sub(line,3)
line = f:read("*l")
lines = lines + 1
end
end
end
print ("lines = " .. lines)
if (lines < 2) then
print ("You must have at least two lines to pad them!")
return
end
wordbytes = tonumber(endline)

print ("FPS in file is " .. thisfps)
local mylayer = moho:LayerAsAudio(moho:CreateNewLayer(MOHO.LT_AUDIO))
mylayer:SetName("Testes")
-- find path only

print ("Audio file is " .. audiofile)
if (string.find (audiofile,"/",1)) ~= nil then
print ("We found a path in the path")
finalfinal = audiofile
else
print ("No path")
local reversepath = string.reverse(path)
print ("reversepath is " .. reversepath)
local filecut = string.match(reversepath,"/(.*)$")
print ("Filecut is " .. filecut)
local finalpath = string.reverse(filecut) .. "/" .. audiofile
print ("Finalpath is " .. finalpath)
finalfinal = string.gsub(finalpath,"/","////")
end
print ("Setting FPS")
moho.document:SetFps(thisfps)
print ("Loading in " .. finalfinal)

mylayer:SetAudioFile(finalfinal)
local dur = mylayer:LayerDuration()
if dur < 0 then
return
end

local j = 0.000
while math.floor(mylayer:GetAmplitude(j,.1) * 100) == 0 do
j = j + .1
end


local startpad = math.floor(j * thisfps)
print ("Audio starts at frame " .. startpad)

j = dur / thisfps

while math.floor(mylayer:GetAmplitude(j,.1) * 100) == 0 do
j = j - .1
end

dur = math.floor(j * thisfps)
print ("Audio ends at frame " .. dur)

moho:DeleteLayer(mylayer)

filebytes = dur - startpad


print ("Original Papagayo file ends at " .. wordbytes)
local numbertopad = math.floor((filebytes - wordbytes)/(tonumber(lines)-1))
print ("Number to pad between lines is " .. numbertopad)
f:close() --Close the file


local f = io.open(path, "r")
if (f == nil) then
return
end

path = path .. "_Padded.pgo"
print ("Output file is " .. path)

local f2 = io.open(path, "w")
if (f == nil) then
return
end
local holdphoneme = ""
local padcounter = startpad
padcounter = padcounter - numbertopad
j = 0
-- Now write out the new file
while true do
line = f:read("*l")
if line == nil then break end
if (string.find (line,"\t",1)) ~= nil then
if (string.find (line,"\t\t\t\t",1)) ~= nil then -- individual phonemes
local linephoneme = ""
linephoneme = string.match(line,"%a+")
--if linephoneme ~= holdphoneme then -- remove this if loop if you don't want to cull dupes
-- replace certain phonemes with others
if linephoneme == "U" then
linephoneme = "O"
elseif linephoneme == "WQ" then
linephoneme = "O"
end
local phonemestart = ""
phonemestart = string.match(line,"%d+")
local p_number = tonumber(phonemestart) + padcounter
f2:write("\t\t\t\t" .. p_number .. " " .. linephoneme .. "\n")
holdphoneme = linephoneme
--end -- cull dupes loop end * keep stuff in middle but remove if/end if you want
elseif (string.find (line,"\t\t\t",1)) ~= nil then -- words
local lineword = ""
holdphoneme = ""
lineword = string.match(line,"[%a%p]+")
holdphoneme = ""
f2:write("\t\t\t" .. lineword .. " ")
local w_number = 0
counter = 1
for w in string.gmatch(line, "%d+") do
if counter ~= 3 then
w_number = tonumber(w) + padcounter
else
w_number = tonumber(w)
end
counter = counter + 1
f2:write(w_number .. " ")
end
f2:write("\n")
elseif (string.find (line,"\t\t",1)) ~= nil then -- lines
j = j + 1
padcounter = padcounter + numbertopad
wholeline = (string.sub(line,3))
f2:write(line .. "\n")
line = f:read("*l")
local startline = tonumber((string.sub(line,3))) + padcounter
f2:write("\t\t" .. startline .. "\n")
line = f:read("*l")
endline = tonumber(string.sub(line,3)) + padcounter
if (j == lines) then
endline = dur
end
f2:write("\t\t" .. endline .. "\n")
line = f:read("*l")
f2:write(line .. "\n")
else
f2:write(line .. "\n")
end
else
f2:write(line .. "\n")
end
end


f:close() --Close the file
f2:close()
end



frank
Kelleytoons Posted - 04/08/2017 : 4:48:42 PM
Okay, anyone with a Mac might want to try this out (and I need to make sure it still works with a PC). I won't be able to test this out again for a while:

(Just copy and past this into an ascii editor, like notepad, and save it out as a .lua file -- after I test it, perhaps tomorrow, I'll post it in the link).



-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "MK_ProcessPapagayo"

-- **************************************************
-- General information about this script
-- **************************************************

MK_ProcessPapagayo = {}

function MK_ProcessPapagayo:Name()
return "Pad out Papagayo File"
end

function MK_ProcessPapagayo:Version()
return "5.0"
end

function MK_ProcessPapagayo:Description()
return "Pad out Papagayo File"
end

function MK_ProcessPapagayo:Creator()
return "Kelleytoons.com"
end

function MK_ProcessPapagayo:UILabel()
return("Pad Papagayo File")
end


-- **************************************************
-- The guts of this script
-- **************************************************


function MK_ProcessPapagayo:Run(moho)


local path = LM.GUI.OpenFile("Select PGO File")
if (path == "") then
return
end

local f = io.open(path, "r")
if (f == nil) then
return
end


local words = 0
local lines = 0
local phonemes = 0
local counter = 0
local filebytes = 0
local wholeline = ""
local line = ""
local wordbytes = 0
local endline = ""
local audiofile = ""
local finalfinal = ""
local thisfps = 30
while true do
line = f:read("*l")
if line == nil then break end
counter = counter + 1
if (counter == 4) then
filebytes = tonumber(line)
end
if (counter == 3) then
thisfps = tonumber(line)
end
if (counter == 2) then
audiofile = line
end
if (string.find (line,"\t",1)) ~= nil then
if (string.find (line,"\t\t\t\t",1)) ~= nil then -- individual phonemes
phonemes = phonemes + 1
elseif (string.find (line,"\t\t\t",1)) ~= nil then -- words
words = words + 1
elseif (string.find (line,"\t\t",1)) ~= nil then -- lines?
wholeline = (string.sub(line,3))
line = f:read("*l")
local startline = (string.sub(line,3))
line = f:read("*l")
endline = string.sub(line,3)
line = f:read("*l")
lines = lines + 1
end
end
end
print ("lines = " .. lines)
if (lines < 2) then
print ("You must have at least two lines to pad them!")
return
end
wordbytes = tonumber(endline)

print ("FPS in file is " .. thisfps)
local mylayer = moho:LayerAsAudio(moho:CreateNewLayer(MOHO.LT_AUDIO))
mylayer:SetName("Testes")
-- find path only

local path = moho:UserAppDir()
local pc = string.find(path,"\\")
local mac = string.find(path,"/")
local delim = ""
if mac ~= nil then
delim = "/"
end

if pc ~= nil then
delim = "\\"
end

print ("Audio file is " .. audiofile)
if (string.find (audiofile,delim,1)) ~= nil then
print ("We found a path in the path")
finalfinal = audiofile
else
print ("No path")
local reversepath = string.reverse(path)
print ("reversepath is " .. reversepath)
local filecut = string.match(reversepath,delim .. "(.*)$")
print ("Filecut is " .. filecut)
local finalpath = string.reverse(filecut) .. delim .. audiofile
print ("Finalpath is " .. finalpath)
finalfinal = string.gsub(finalpath,delim,delim .. delim)
end
print ("Setting FPS")
moho.document:SetFps(thisfps)
print ("Loading in " .. finalfinal)

mylayer:SetAudioFile(finalfinal)
local dur = mylayer:LayerDuration()
if dur < 0 then
return
end

local j = 0.000
while math.floor(mylayer:GetAmplitude(j,.1) * 100) == 0 do
j = j + .1
end


local startpad = math.floor(j * thisfps)
print ("Audio starts at frame " .. startpad)

j = dur / thisfps

while math.floor(mylayer:GetAmplitude(j,.1) * 100) == 0 do
j = j - .1
end

dur = math.floor(j * thisfps)
print ("Audio ends at frame " .. dur)

moho:DeleteLayer(mylayer)

filebytes = dur - startpad


print ("Original Papagayo file ends at " .. wordbytes)
local numbertopad = math.floor((filebytes - wordbytes)/(tonumber(lines)-1))
print ("Number to pad between lines is " .. numbertopad)
f:close() --Close the file


local f = io.open(path, "r")
if (f == nil) then
return
end

path = path .. "_Padded.pgo"
print ("Output file is " .. path)

local f2 = io.open(path, "w")
if (f == nil) then
return
end
local holdphoneme = ""
local padcounter = startpad
padcounter = padcounter - numbertopad
j = 0
-- Now write out the new file
while true do
line = f:read("*l")
if line == nil then break end
if (string.find (line,"\t",1)) ~= nil then
if (string.find (line,"\t\t\t\t",1)) ~= nil then -- individual phonemes
local linephoneme = ""
linephoneme = string.match(line,"%a+")
--if linephoneme ~= holdphoneme then -- remove this if loop if you don't want to cull dupes
-- replace certain phonemes with others
if linephoneme == "U" then
linephoneme = "O"
elseif linephoneme == "WQ" then
linephoneme = "O"
end
local phonemestart = ""
phonemestart = string.match(line,"%d+")
local p_number = tonumber(phonemestart) + padcounter
f2:write("\t\t\t\t" .. p_number .. " " .. linephoneme .. "\n")
holdphoneme = linephoneme
--end -- cull dupes loop end * keep stuff in middle but remove if/end if you want
elseif (string.find (line,"\t\t\t",1)) ~= nil then -- words
local lineword = ""
holdphoneme = ""
lineword = string.match(line,"[%a%p]+")
holdphoneme = ""
f2:write("\t\t\t" .. lineword .. " ")
local w_number = 0
counter = 1
for w in string.gmatch(line, "%d+") do
if counter ~= 3 then
w_number = tonumber(w) + padcounter
else
w_number = tonumber(w)
end
counter = counter + 1
f2:write(w_number .. " ")
end
f2:write("\n")
elseif (string.find (line,"\t\t",1)) ~= nil then -- lines
j = j + 1
padcounter = padcounter + numbertopad
wholeline = (string.sub(line,3))
f2:write(line .. "\n")
line = f:read("*l")
local startline = tonumber((string.sub(line,3))) + padcounter
f2:write("\t\t" .. startline .. "\n")
line = f:read("*l")
endline = tonumber(string.sub(line,3)) + padcounter
if (j == lines) then
endline = dur
end
f2:write("\t\t" .. endline .. "\n")
line = f:read("*l")
f2:write(line .. "\n")
else
f2:write(line .. "\n")
end
else
f2:write(line .. "\n")
end
end


f:close() --Close the file
f2:close()
end


"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
Kelleytoons Posted - 04/08/2017 : 4:33:34 PM
Wes,

But I need to SEEK the delimiters -- so it's not enough to just use them (and in point of fact would end up confusing things, since the seeking won't return what I am then putting in).

Thanks, Paul, for my code <g>.

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
SynthSin75 Posted - 04/08/2017 : 3:16:15 PM
Mac delimiters work in Windows paths, but not vice versa. So I just always use the Mac delimiters. Save on having to escape the Windows delimiters with "\\" too.

-Wes
hayasidist Posted - 04/08/2017 : 1:49:12 PM
Mike:



	local path = moho:UserAppDir()
	local pc = string.find(path,"\\")
	local mac = string.find(path,"/")
	local delim = ""
	if mac ~= nil then
		delim =  "/"
	end

	if pc ~= nil then
		delim = "\\"
	end


an old friend of mine once said "if you have a plant in your garden that you love, make sure you share it (cuttings / bulb / seed ...) with someone - so if yours dies you'll have your friend's one from which to regrow...

Your code... safely kept (and used!) and now returned!
Kelleytoons Posted - 04/08/2017 : 1:06:46 PM
Sigh -- yes, Mac is a problem (because the way it handles folder designations it's backassward from Windows). I *thought* I had accounted for this, but perhaps I did that in another script and maybe up until now no one has ever tried it on a Mac.

I'll see if I can fix that - in essence the issue is the backslash and forward slashes are changed in Mac v. Windows, so a directory parse will be incorrect since it looks for one or the other. In at least one script I account for this by reading whether you are on a Mac or not (and don't ask me how I did that, as I don't remember) and if you are on a Mac I substitute the correct character. Let me look at this this afternoon and I'll post back here with what I find.

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
ifix Posted - 04/08/2017 : 02:11:32 AM
Hi Mike
Thanks for your answer. And sorry for my bad english.
VOIX is a french word. it seems Voice.
I am on mac
Entire folder path is : hard disk/VOIX/
But anyway i put the folder files, the result is same. with Anime studio pro 9.5 or Moho pro 12

frank
Kelleytoons Posted - 04/07/2017 : 10:59:00 PM
First, on Windows or a Mac? Second, what is the full path to your files (the entire folder path including the file names).

Offhand it seems to be having problems with the full path -- is your entire file name "TEST VOIX MINIKEUMS 2.wav"? What is VOIX? Is that a word, or are you using symbols there? I'd try removing that and just go with "TEST MINIKEUMS 2.WAV".

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
ifix Posted - 04/07/2017 : 5:19:43 PM
Hi Mike,

I have a problem with the script downloaded yesterday.
I have the two files .pgo and .wav in the same folder.
But this is the console message :
lines = 6
FPS in file is 25
Audio file is TEST VOIX MINIKEUMS 2.wav
No path
reversepath is ogp.4TSET/XIOV/
...Anime Studio Pro/scripts/menu/MK_ProcessPapagayo.lua:117:attempt to concatenate local 'filecut' (a nil value)

Thanks for you help

frank
Kelleytoons Posted - 04/06/2017 : 08:47:00 AM
Okay, I'll change the link in the first part of this thread. Thanks for letting me know.

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley
ifix Posted - 04/06/2017 : 02:53:57 AM
It's Ok now,
Thank you very much

frank
Kelleytoons Posted - 04/05/2017 : 9:03:33 PM
Dropbox ended their support of links to the public folder. Let's see if this works now:

https://www.dropbox.com/s/lg6y4nsrhwpysug/MK_ProcessPapagayo.lua?dl=0

"Look, I made a hat...
Where there never was a hat"


-Mike "ex-genius" Kelley

Animators Forum © Kelleytoons Go To Top Of Page
Powered By: Snitz Forums 2000 Version 3.4.07